{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DerivingVia #-}
{-# LANGUAGE ExistentialQuantification #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE UndecidableInstances #-}
module Ouroboros.Consensus.Mempool.API
(
Mempool (..)
, MempoolTimeoutConfig (..)
, ExnMempoolTimeout (..)
, AddTxOnBehalfOf (..)
, MempoolAddTxResult (..)
, addLocalTxs
, addTxs
, isMempoolTxAdded
, isMempoolTxRejected
, mempoolTxAddedToMaybe
, ForgeLedgerState (..)
, DiffTimeMeasure (..)
, MempoolSnapshot (..)
, TxMeasureWithDiffTime (..)
, forgetTxMeasureWithDiffTime
, SizeInBytes
, TicketNo
, zeroTicketNo
) where
import Control.ResourceRegistry
import Data.DerivingVia (InstantiatedAt (..))
import qualified Data.List.NonEmpty as NE
import Data.Measure (Measure)
import qualified Data.Measure
import GHC.Generics (Generic)
import NoThunks.Class
import Ouroboros.Consensus.Block (ChainHash, Point, SlotNo)
import Ouroboros.Consensus.Ledger.Abstract
import Ouroboros.Consensus.Ledger.SupportsMempool
import qualified Ouroboros.Consensus.Mempool.Capacity as Cap
import Ouroboros.Consensus.Mempool.TxSeq (TicketNo, zeroTicketNo)
import Ouroboros.Consensus.Util.IOLike
import Ouroboros.Network.Protocol.TxSubmission2.Type (SizeInBytes)
data Mempool m blk = Mempool
{ forall (m :: * -> *) blk.
Mempool m blk
-> AddTxOnBehalfOf -> GenTx blk -> m (MempoolAddTxResult blk)
addTx ::
AddTxOnBehalfOf ->
GenTx blk ->
m (MempoolAddTxResult blk)
, forall (m :: * -> *) blk.
Mempool m blk -> NonEmpty (GenTxId blk) -> m ()
removeTxsEvenIfValid :: NE.NonEmpty (GenTxId blk) -> m ()
, forall (m :: * -> *) blk.
Mempool m blk -> STM m (MempoolSnapshot blk)
getSnapshot :: STM m (MempoolSnapshot blk)
, forall (m :: * -> *) blk.
Mempool m blk
-> SlotNo
-> TickedLedgerState blk DiffMK
-> (LedgerTables (LedgerState blk) KeysMK
-> m (LedgerTables (LedgerState blk) ValuesMK))
-> m (MempoolSnapshot blk)
getSnapshotFor ::
SlotNo ->
TickedLedgerState blk DiffMK ->
(LedgerTables (LedgerState blk) KeysMK -> m (LedgerTables (LedgerState blk) ValuesMK)) ->
m (MempoolSnapshot blk)
, forall (m :: * -> *) blk. Mempool m blk -> STM m (TxMeasure blk)
getCapacity :: STM m (TxMeasure blk)
, forall (m :: * -> *) blk.
Mempool m blk -> forall a. String -> m a -> m (Thread m a)
testForkMempoolThread :: forall a. String -> m a -> m (Thread m a)
, forall (m :: * -> *) blk.
Mempool m blk
-> DiffTime
-> AddTxOnBehalfOf
-> GenTx blk
-> m (Maybe (MempoolAddTxResult blk))
testTryAddTx ::
DiffTime ->
AddTxOnBehalfOf ->
GenTx blk ->
m (Maybe (MempoolAddTxResult blk))
, forall (m :: * -> *) blk. Mempool m blk -> m (MempoolSnapshot blk)
testSyncWithLedger :: m (MempoolSnapshot blk)
}
data MempoolTimeoutConfig = MempoolTimeoutConfig
{ MempoolTimeoutConfig -> DiffTime
mempoolTimeoutSoft :: DiffTime
, MempoolTimeoutConfig -> DiffTime
mempoolTimeoutHard :: DiffTime
, MempoolTimeoutConfig -> DiffTime
mempoolTimeoutCapacity :: DiffTime
}
deriving (MempoolTimeoutConfig -> MempoolTimeoutConfig -> Bool
(MempoolTimeoutConfig -> MempoolTimeoutConfig -> Bool)
-> (MempoolTimeoutConfig -> MempoolTimeoutConfig -> Bool)
-> Eq MempoolTimeoutConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: MempoolTimeoutConfig -> MempoolTimeoutConfig -> Bool
== :: MempoolTimeoutConfig -> MempoolTimeoutConfig -> Bool
$c/= :: MempoolTimeoutConfig -> MempoolTimeoutConfig -> Bool
/= :: MempoolTimeoutConfig -> MempoolTimeoutConfig -> Bool
Eq, Int -> MempoolTimeoutConfig -> ShowS
[MempoolTimeoutConfig] -> ShowS
MempoolTimeoutConfig -> String
(Int -> MempoolTimeoutConfig -> ShowS)
-> (MempoolTimeoutConfig -> String)
-> ([MempoolTimeoutConfig] -> ShowS)
-> Show MempoolTimeoutConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> MempoolTimeoutConfig -> ShowS
showsPrec :: Int -> MempoolTimeoutConfig -> ShowS
$cshow :: MempoolTimeoutConfig -> String
show :: MempoolTimeoutConfig -> String
$cshowList :: [MempoolTimeoutConfig] -> ShowS
showList :: [MempoolTimeoutConfig] -> ShowS
Show)
data MempoolAddTxResult blk
=
MempoolTxAdded !(Validated (GenTx blk))
|
MempoolTxRejected !(GenTx blk) !(ApplyTxErr blk)
deriving instance
(Eq (GenTx blk), Eq (Validated (GenTx blk)), Eq (ApplyTxErr blk)) => Eq (MempoolAddTxResult blk)
deriving instance
(Show (GenTx blk), Show (Validated (GenTx blk)), Show (ApplyTxErr blk)) =>
Show (MempoolAddTxResult blk)
mempoolTxAddedToMaybe :: MempoolAddTxResult blk -> Maybe (Validated (GenTx blk))
mempoolTxAddedToMaybe :: forall blk. MempoolAddTxResult blk -> Maybe (Validated (GenTx blk))
mempoolTxAddedToMaybe (MempoolTxAdded Validated (GenTx blk)
vtx) = Validated (GenTx blk) -> Maybe (Validated (GenTx blk))
forall a. a -> Maybe a
Just Validated (GenTx blk)
vtx
mempoolTxAddedToMaybe MempoolAddTxResult blk
_ = Maybe (Validated (GenTx blk))
forall a. Maybe a
Nothing
isMempoolTxAdded :: MempoolAddTxResult blk -> Bool
isMempoolTxAdded :: forall blk. MempoolAddTxResult blk -> Bool
isMempoolTxAdded MempoolTxAdded{} = Bool
True
isMempoolTxAdded MempoolAddTxResult blk
_ = Bool
False
isMempoolTxRejected :: MempoolAddTxResult blk -> Bool
isMempoolTxRejected :: forall blk. MempoolAddTxResult blk -> Bool
isMempoolTxRejected MempoolTxRejected{} = Bool
True
isMempoolTxRejected MempoolAddTxResult blk
_ = Bool
False
addTxs ::
forall m blk t.
(MonadSTM m, Traversable t) =>
Mempool m blk ->
t (GenTx blk) ->
m (t (MempoolAddTxResult blk))
addTxs :: forall (m :: * -> *) blk (t :: * -> *).
(MonadSTM m, Traversable t) =>
Mempool m blk -> t (GenTx blk) -> m (t (MempoolAddTxResult blk))
addTxs Mempool m blk
mempool = (GenTx blk -> m (MempoolAddTxResult blk))
-> t (GenTx blk) -> m (t (MempoolAddTxResult blk))
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> t a -> m (t b)
mapM (Mempool m blk
-> AddTxOnBehalfOf -> GenTx blk -> m (MempoolAddTxResult blk)
forall (m :: * -> *) blk.
Mempool m blk
-> AddTxOnBehalfOf -> GenTx blk -> m (MempoolAddTxResult blk)
addTx Mempool m blk
mempool AddTxOnBehalfOf
AddTxForRemotePeer)
addLocalTxs ::
forall m blk t.
(MonadSTM m, Traversable t) =>
Mempool m blk ->
t (GenTx blk) ->
m (t (MempoolAddTxResult blk))
addLocalTxs :: forall (m :: * -> *) blk (t :: * -> *).
(MonadSTM m, Traversable t) =>
Mempool m blk -> t (GenTx blk) -> m (t (MempoolAddTxResult blk))
addLocalTxs Mempool m blk
mempool = (GenTx blk -> m (MempoolAddTxResult blk))
-> t (GenTx blk) -> m (t (MempoolAddTxResult blk))
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> t a -> m (t b)
mapM (Mempool m blk
-> AddTxOnBehalfOf -> GenTx blk -> m (MempoolAddTxResult blk)
forall (m :: * -> *) blk.
Mempool m blk
-> AddTxOnBehalfOf -> GenTx blk -> m (MempoolAddTxResult blk)
addTx Mempool m blk
mempool AddTxOnBehalfOf
AddTxForLocalClient)
data AddTxOnBehalfOf = AddTxForRemotePeer | AddTxForLocalClient
data ForgeLedgerState blk
=
ForgeInKnownSlot SlotNo (TickedLedgerState blk DiffMK)
|
ForgeInUnknownSlot (LedgerState blk EmptyMK)
data MempoolSnapshot blk = MempoolSnapshot
{ forall blk.
MempoolSnapshot blk
-> [(Validated (GenTx blk), TicketNo, TxMeasure blk)]
snapshotTxs :: [(Validated (GenTx blk), TicketNo, TxMeasure blk)]
, forall blk.
MempoolSnapshot blk
-> TicketNo -> [(Validated (GenTx blk), TicketNo, TxMeasure blk)]
snapshotTxsAfter :: TicketNo -> [(Validated (GenTx blk), TicketNo, TxMeasure blk)]
, forall blk.
MempoolSnapshot blk
-> TxMeasure blk
-> ([Validated (GenTx blk)], TxMeasureWithDiffTime blk)
snapshotTake :: TxMeasure blk -> ([Validated (GenTx blk)], TxMeasureWithDiffTime blk)
, forall blk.
MempoolSnapshot blk -> TicketNo -> Maybe (Validated (GenTx blk))
snapshotLookupTx :: TicketNo -> Maybe (Validated (GenTx blk))
, forall blk. MempoolSnapshot blk -> GenTxId blk -> Bool
snapshotHasTx :: GenTxId blk -> Bool
, forall blk. MempoolSnapshot blk -> MempoolSize
snapshotMempoolSize :: Cap.MempoolSize
, forall blk. MempoolSnapshot blk -> SlotNo
snapshotSlotNo :: SlotNo
, forall blk.
MempoolSnapshot blk -> ChainHash (TickedLedgerState blk)
snapshotStateHash :: ChainHash (TickedLedgerState blk)
, forall blk. MempoolSnapshot blk -> Point blk
snapshotPoint :: Point blk
}
data TxMeasureWithDiffTime blk = MkTxMeasureWithDiffTime !(TxMeasure blk) !DiffTimeMeasure
deriving stock (forall x.
TxMeasureWithDiffTime blk -> Rep (TxMeasureWithDiffTime blk) x)
-> (forall x.
Rep (TxMeasureWithDiffTime blk) x -> TxMeasureWithDiffTime blk)
-> Generic (TxMeasureWithDiffTime blk)
forall x.
Rep (TxMeasureWithDiffTime blk) x -> TxMeasureWithDiffTime blk
forall x.
TxMeasureWithDiffTime blk -> Rep (TxMeasureWithDiffTime blk) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall blk x.
Rep (TxMeasureWithDiffTime blk) x -> TxMeasureWithDiffTime blk
forall blk x.
TxMeasureWithDiffTime blk -> Rep (TxMeasureWithDiffTime blk) x
$cfrom :: forall blk x.
TxMeasureWithDiffTime blk -> Rep (TxMeasureWithDiffTime blk) x
from :: forall x.
TxMeasureWithDiffTime blk -> Rep (TxMeasureWithDiffTime blk) x
$cto :: forall blk x.
Rep (TxMeasureWithDiffTime blk) x -> TxMeasureWithDiffTime blk
to :: forall x.
Rep (TxMeasureWithDiffTime blk) x -> TxMeasureWithDiffTime blk
Generic
deriving instance Eq (TxMeasure blk) => Eq (TxMeasureWithDiffTime blk)
deriving instance Ord (TxMeasure blk) => Ord (TxMeasureWithDiffTime blk)
deriving instance Show (TxMeasure blk) => Show (TxMeasureWithDiffTime blk)
deriving via
(InstantiatedAt Measure (TxMeasureWithDiffTime blk))
instance
Measure (TxMeasure blk) => Semigroup (TxMeasureWithDiffTime blk)
deriving via
(InstantiatedAt Measure (TxMeasureWithDiffTime blk))
instance
Measure (TxMeasure blk) => Monoid (TxMeasureWithDiffTime blk)
forgetTxMeasureWithDiffTime :: TxMeasureWithDiffTime blk -> TxMeasure blk
forgetTxMeasureWithDiffTime :: forall blk. TxMeasureWithDiffTime blk -> TxMeasure blk
forgetTxMeasureWithDiffTime (MkTxMeasureWithDiffTime TxMeasure blk
x DiffTimeMeasure
_) = TxMeasure blk
x
deriving instance NoThunks (TxMeasure blk) => NoThunks (TxMeasureWithDiffTime blk)
binopViaTuple ::
((TxMeasure x, DiffTimeMeasure) -> (TxMeasure y, DiffTimeMeasure) -> (TxMeasure z, DiffTimeMeasure)) ->
TxMeasureWithDiffTime x ->
TxMeasureWithDiffTime y ->
TxMeasureWithDiffTime z
binopViaTuple :: forall x y z.
((TxMeasure x, DiffTimeMeasure)
-> (TxMeasure y, DiffTimeMeasure)
-> (TxMeasure z, DiffTimeMeasure))
-> TxMeasureWithDiffTime x
-> TxMeasureWithDiffTime y
-> TxMeasureWithDiffTime z
binopViaTuple (TxMeasure x, DiffTimeMeasure)
-> (TxMeasure y, DiffTimeMeasure) -> (TxMeasure z, DiffTimeMeasure)
f (MkTxMeasureWithDiffTime TxMeasure x
a DiffTimeMeasure
b) (MkTxMeasureWithDiffTime TxMeasure y
p DiffTimeMeasure
q) =
let (TxMeasure z
x, DiffTimeMeasure
y) = (TxMeasure x, DiffTimeMeasure)
-> (TxMeasure y, DiffTimeMeasure) -> (TxMeasure z, DiffTimeMeasure)
f (TxMeasure x
a, DiffTimeMeasure
b) (TxMeasure y
p, DiffTimeMeasure
q)
in TxMeasure z -> DiffTimeMeasure -> TxMeasureWithDiffTime z
forall blk.
TxMeasure blk -> DiffTimeMeasure -> TxMeasureWithDiffTime blk
MkTxMeasureWithDiffTime TxMeasure z
x DiffTimeMeasure
y
instance Measure (TxMeasure blk) => Measure (TxMeasureWithDiffTime blk) where
zero :: TxMeasureWithDiffTime blk
zero = TxMeasure blk -> DiffTimeMeasure -> TxMeasureWithDiffTime blk
forall blk.
TxMeasure blk -> DiffTimeMeasure -> TxMeasureWithDiffTime blk
MkTxMeasureWithDiffTime TxMeasure blk
forall a. Measure a => a
Data.Measure.zero DiffTimeMeasure
forall a. Measure a => a
Data.Measure.zero
plus :: TxMeasureWithDiffTime blk
-> TxMeasureWithDiffTime blk -> TxMeasureWithDiffTime blk
plus = ((TxMeasure blk, DiffTimeMeasure)
-> (TxMeasure blk, DiffTimeMeasure)
-> (TxMeasure blk, DiffTimeMeasure))
-> TxMeasureWithDiffTime blk
-> TxMeasureWithDiffTime blk
-> TxMeasureWithDiffTime blk
forall x y z.
((TxMeasure x, DiffTimeMeasure)
-> (TxMeasure y, DiffTimeMeasure)
-> (TxMeasure z, DiffTimeMeasure))
-> TxMeasureWithDiffTime x
-> TxMeasureWithDiffTime y
-> TxMeasureWithDiffTime z
binopViaTuple (TxMeasure blk, DiffTimeMeasure)
-> (TxMeasure blk, DiffTimeMeasure)
-> (TxMeasure blk, DiffTimeMeasure)
forall a. Measure a => a -> a -> a
Data.Measure.plus
min :: TxMeasureWithDiffTime blk
-> TxMeasureWithDiffTime blk -> TxMeasureWithDiffTime blk
min = ((TxMeasure blk, DiffTimeMeasure)
-> (TxMeasure blk, DiffTimeMeasure)
-> (TxMeasure blk, DiffTimeMeasure))
-> TxMeasureWithDiffTime blk
-> TxMeasureWithDiffTime blk
-> TxMeasureWithDiffTime blk
forall x y z.
((TxMeasure x, DiffTimeMeasure)
-> (TxMeasure y, DiffTimeMeasure)
-> (TxMeasure z, DiffTimeMeasure))
-> TxMeasureWithDiffTime x
-> TxMeasureWithDiffTime y
-> TxMeasureWithDiffTime z
binopViaTuple (TxMeasure blk, DiffTimeMeasure)
-> (TxMeasure blk, DiffTimeMeasure)
-> (TxMeasure blk, DiffTimeMeasure)
forall a. Measure a => a -> a -> a
Data.Measure.min
max :: TxMeasureWithDiffTime blk
-> TxMeasureWithDiffTime blk -> TxMeasureWithDiffTime blk
max = ((TxMeasure blk, DiffTimeMeasure)
-> (TxMeasure blk, DiffTimeMeasure)
-> (TxMeasure blk, DiffTimeMeasure))
-> TxMeasureWithDiffTime blk
-> TxMeasureWithDiffTime blk
-> TxMeasureWithDiffTime blk
forall x y z.
((TxMeasure x, DiffTimeMeasure)
-> (TxMeasure y, DiffTimeMeasure)
-> (TxMeasure z, DiffTimeMeasure))
-> TxMeasureWithDiffTime x
-> TxMeasureWithDiffTime y
-> TxMeasureWithDiffTime z
binopViaTuple (TxMeasure blk, DiffTimeMeasure)
-> (TxMeasure blk, DiffTimeMeasure)
-> (TxMeasure blk, DiffTimeMeasure)
forall a. Measure a => a -> a -> a
Data.Measure.max
instance HasByteSize (TxMeasure blk) => HasByteSize (TxMeasureWithDiffTime blk) where
txMeasureByteSize :: TxMeasureWithDiffTime blk -> ByteSize32
txMeasureByteSize = TxMeasure blk -> ByteSize32
forall a. HasByteSize a => a -> ByteSize32
txMeasureByteSize (TxMeasure blk -> ByteSize32)
-> (TxMeasureWithDiffTime blk -> TxMeasure blk)
-> TxMeasureWithDiffTime blk
-> ByteSize32
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TxMeasureWithDiffTime blk -> TxMeasure blk
forall blk. TxMeasureWithDiffTime blk -> TxMeasure blk
forgetTxMeasureWithDiffTime
instance TxMeasureMetrics (TxMeasure blk) => TxMeasureMetrics (TxMeasureWithDiffTime blk) where
txMeasureMetricTxSizeBytes :: TxMeasureWithDiffTime blk -> ByteSize32
txMeasureMetricTxSizeBytes = TxMeasure blk -> ByteSize32
forall msr. TxMeasureMetrics msr => msr -> ByteSize32
txMeasureMetricTxSizeBytes (TxMeasure blk -> ByteSize32)
-> (TxMeasureWithDiffTime blk -> TxMeasure blk)
-> TxMeasureWithDiffTime blk
-> ByteSize32
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TxMeasureWithDiffTime blk -> TxMeasure blk
forall blk. TxMeasureWithDiffTime blk -> TxMeasure blk
forgetTxMeasureWithDiffTime
txMeasureMetricExUnitsMemory :: TxMeasureWithDiffTime blk -> Natural
txMeasureMetricExUnitsMemory = TxMeasure blk -> Natural
forall msr. TxMeasureMetrics msr => msr -> Natural
txMeasureMetricExUnitsMemory (TxMeasure blk -> Natural)
-> (TxMeasureWithDiffTime blk -> TxMeasure blk)
-> TxMeasureWithDiffTime blk
-> Natural
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TxMeasureWithDiffTime blk -> TxMeasure blk
forall blk. TxMeasureWithDiffTime blk -> TxMeasure blk
forgetTxMeasureWithDiffTime
txMeasureMetricExUnitsSteps :: TxMeasureWithDiffTime blk -> Natural
txMeasureMetricExUnitsSteps = TxMeasure blk -> Natural
forall msr. TxMeasureMetrics msr => msr -> Natural
txMeasureMetricExUnitsSteps (TxMeasure blk -> Natural)
-> (TxMeasureWithDiffTime blk -> TxMeasure blk)
-> TxMeasureWithDiffTime blk
-> Natural
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TxMeasureWithDiffTime blk -> TxMeasure blk
forall blk. TxMeasureWithDiffTime blk -> TxMeasure blk
forgetTxMeasureWithDiffTime
txMeasureMetricRefScriptsSizeBytes :: TxMeasureWithDiffTime blk -> ByteSize32
txMeasureMetricRefScriptsSizeBytes = TxMeasure blk -> ByteSize32
forall msr. TxMeasureMetrics msr => msr -> ByteSize32
txMeasureMetricRefScriptsSizeBytes (TxMeasure blk -> ByteSize32)
-> (TxMeasureWithDiffTime blk -> TxMeasure blk)
-> TxMeasureWithDiffTime blk
-> ByteSize32
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TxMeasureWithDiffTime blk -> TxMeasure blk
forall blk. TxMeasureWithDiffTime blk -> TxMeasure blk
forgetTxMeasureWithDiffTime
data DiffTimeMeasure = FiniteDiffTimeMeasure !DiffTime | InfiniteDiffTimeMeasure
deriving stock (DiffTimeMeasure -> DiffTimeMeasure -> Bool
(DiffTimeMeasure -> DiffTimeMeasure -> Bool)
-> (DiffTimeMeasure -> DiffTimeMeasure -> Bool)
-> Eq DiffTimeMeasure
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: DiffTimeMeasure -> DiffTimeMeasure -> Bool
== :: DiffTimeMeasure -> DiffTimeMeasure -> Bool
$c/= :: DiffTimeMeasure -> DiffTimeMeasure -> Bool
/= :: DiffTimeMeasure -> DiffTimeMeasure -> Bool
Eq, (forall x. DiffTimeMeasure -> Rep DiffTimeMeasure x)
-> (forall x. Rep DiffTimeMeasure x -> DiffTimeMeasure)
-> Generic DiffTimeMeasure
forall x. Rep DiffTimeMeasure x -> DiffTimeMeasure
forall x. DiffTimeMeasure -> Rep DiffTimeMeasure x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. DiffTimeMeasure -> Rep DiffTimeMeasure x
from :: forall x. DiffTimeMeasure -> Rep DiffTimeMeasure x
$cto :: forall x. Rep DiffTimeMeasure x -> DiffTimeMeasure
to :: forall x. Rep DiffTimeMeasure x -> DiffTimeMeasure
Generic, Int -> DiffTimeMeasure -> ShowS
[DiffTimeMeasure] -> ShowS
DiffTimeMeasure -> String
(Int -> DiffTimeMeasure -> ShowS)
-> (DiffTimeMeasure -> String)
-> ([DiffTimeMeasure] -> ShowS)
-> Show DiffTimeMeasure
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> DiffTimeMeasure -> ShowS
showsPrec :: Int -> DiffTimeMeasure -> ShowS
$cshow :: DiffTimeMeasure -> String
show :: DiffTimeMeasure -> String
$cshowList :: [DiffTimeMeasure] -> ShowS
showList :: [DiffTimeMeasure] -> ShowS
Show)
deriving anyclass Context -> DiffTimeMeasure -> IO (Maybe ThunkInfo)
Proxy DiffTimeMeasure -> String
(Context -> DiffTimeMeasure -> IO (Maybe ThunkInfo))
-> (Context -> DiffTimeMeasure -> IO (Maybe ThunkInfo))
-> (Proxy DiffTimeMeasure -> String)
-> NoThunks DiffTimeMeasure
forall a.
(Context -> a -> IO (Maybe ThunkInfo))
-> (Context -> a -> IO (Maybe ThunkInfo))
-> (Proxy a -> String)
-> NoThunks a
$cnoThunks :: Context -> DiffTimeMeasure -> IO (Maybe ThunkInfo)
noThunks :: Context -> DiffTimeMeasure -> IO (Maybe ThunkInfo)
$cwNoThunks :: Context -> DiffTimeMeasure -> IO (Maybe ThunkInfo)
wNoThunks :: Context -> DiffTimeMeasure -> IO (Maybe ThunkInfo)
$cshowTypeOf :: Proxy DiffTimeMeasure -> String
showTypeOf :: Proxy DiffTimeMeasure -> String
NoThunks
deriving
(Semigroup DiffTimeMeasure
DiffTimeMeasure
Semigroup DiffTimeMeasure =>
DiffTimeMeasure
-> (DiffTimeMeasure -> DiffTimeMeasure -> DiffTimeMeasure)
-> ([DiffTimeMeasure] -> DiffTimeMeasure)
-> Monoid DiffTimeMeasure
[DiffTimeMeasure] -> DiffTimeMeasure
DiffTimeMeasure -> DiffTimeMeasure -> DiffTimeMeasure
forall a.
Semigroup a =>
a -> (a -> a -> a) -> ([a] -> a) -> Monoid a
$cmempty :: DiffTimeMeasure
mempty :: DiffTimeMeasure
$cmappend :: DiffTimeMeasure -> DiffTimeMeasure -> DiffTimeMeasure
mappend :: DiffTimeMeasure -> DiffTimeMeasure -> DiffTimeMeasure
$cmconcat :: [DiffTimeMeasure] -> DiffTimeMeasure
mconcat :: [DiffTimeMeasure] -> DiffTimeMeasure
Monoid, NonEmpty DiffTimeMeasure -> DiffTimeMeasure
DiffTimeMeasure -> DiffTimeMeasure -> DiffTimeMeasure
(DiffTimeMeasure -> DiffTimeMeasure -> DiffTimeMeasure)
-> (NonEmpty DiffTimeMeasure -> DiffTimeMeasure)
-> (forall b.
Integral b =>
b -> DiffTimeMeasure -> DiffTimeMeasure)
-> Semigroup DiffTimeMeasure
forall b. Integral b => b -> DiffTimeMeasure -> DiffTimeMeasure
forall a.
(a -> a -> a)
-> (NonEmpty a -> a)
-> (forall b. Integral b => b -> a -> a)
-> Semigroup a
$c<> :: DiffTimeMeasure -> DiffTimeMeasure -> DiffTimeMeasure
<> :: DiffTimeMeasure -> DiffTimeMeasure -> DiffTimeMeasure
$csconcat :: NonEmpty DiffTimeMeasure -> DiffTimeMeasure
sconcat :: NonEmpty DiffTimeMeasure -> DiffTimeMeasure
$cstimes :: forall b. Integral b => b -> DiffTimeMeasure -> DiffTimeMeasure
stimes :: forall b. Integral b => b -> DiffTimeMeasure -> DiffTimeMeasure
Semigroup)
via (InstantiatedAt Measure DiffTimeMeasure)
instance Ord DiffTimeMeasure where
compare :: DiffTimeMeasure -> DiffTimeMeasure -> Ordering
compare = ((DiffTimeMeasure, DiffTimeMeasure) -> Ordering)
-> DiffTimeMeasure -> DiffTimeMeasure -> Ordering
forall a b c. ((a, b) -> c) -> a -> b -> c
curry (((DiffTimeMeasure, DiffTimeMeasure) -> Ordering)
-> DiffTimeMeasure -> DiffTimeMeasure -> Ordering)
-> ((DiffTimeMeasure, DiffTimeMeasure) -> Ordering)
-> DiffTimeMeasure
-> DiffTimeMeasure
-> Ordering
forall a b. (a -> b) -> a -> b
$ \case
(DiffTimeMeasure
InfiniteDiffTimeMeasure, DiffTimeMeasure
InfiniteDiffTimeMeasure) -> Ordering
EQ
(DiffTimeMeasure
InfiniteDiffTimeMeasure, DiffTimeMeasure
_) -> Ordering
GT
(DiffTimeMeasure
_, DiffTimeMeasure
InfiniteDiffTimeMeasure) -> Ordering
LT
(FiniteDiffTimeMeasure DiffTime
x, FiniteDiffTimeMeasure DiffTime
y) -> DiffTime -> DiffTime -> Ordering
forall a. Ord a => a -> a -> Ordering
compare DiffTime
x DiffTime
y
instance Measure DiffTimeMeasure where
zero :: DiffTimeMeasure
zero = DiffTime -> DiffTimeMeasure
FiniteDiffTimeMeasure DiffTime
0
plus :: DiffTimeMeasure -> DiffTimeMeasure -> DiffTimeMeasure
plus = ((DiffTimeMeasure, DiffTimeMeasure) -> DiffTimeMeasure)
-> DiffTimeMeasure -> DiffTimeMeasure -> DiffTimeMeasure
forall a b c. ((a, b) -> c) -> a -> b -> c
curry (((DiffTimeMeasure, DiffTimeMeasure) -> DiffTimeMeasure)
-> DiffTimeMeasure -> DiffTimeMeasure -> DiffTimeMeasure)
-> ((DiffTimeMeasure, DiffTimeMeasure) -> DiffTimeMeasure)
-> DiffTimeMeasure
-> DiffTimeMeasure
-> DiffTimeMeasure
forall a b. (a -> b) -> a -> b
$ \case
(DiffTimeMeasure
InfiniteDiffTimeMeasure, DiffTimeMeasure
_) -> DiffTimeMeasure
InfiniteDiffTimeMeasure
(DiffTimeMeasure
_, DiffTimeMeasure
InfiniteDiffTimeMeasure) -> DiffTimeMeasure
InfiniteDiffTimeMeasure
(FiniteDiffTimeMeasure DiffTime
x, FiniteDiffTimeMeasure DiffTime
y) ->
DiffTime -> DiffTimeMeasure
FiniteDiffTimeMeasure (DiffTime
x DiffTime -> DiffTime -> DiffTime
forall a. Num a => a -> a -> a
+ DiffTime
y)
min :: DiffTimeMeasure -> DiffTimeMeasure -> DiffTimeMeasure
min = ((DiffTimeMeasure, DiffTimeMeasure) -> DiffTimeMeasure)
-> DiffTimeMeasure -> DiffTimeMeasure -> DiffTimeMeasure
forall a b c. ((a, b) -> c) -> a -> b -> c
curry (((DiffTimeMeasure, DiffTimeMeasure) -> DiffTimeMeasure)
-> DiffTimeMeasure -> DiffTimeMeasure -> DiffTimeMeasure)
-> ((DiffTimeMeasure, DiffTimeMeasure) -> DiffTimeMeasure)
-> DiffTimeMeasure
-> DiffTimeMeasure
-> DiffTimeMeasure
forall a b. (a -> b) -> a -> b
$ \case
(DiffTimeMeasure
InfiniteDiffTimeMeasure, DiffTimeMeasure
y) -> DiffTimeMeasure
y
(DiffTimeMeasure
x, DiffTimeMeasure
InfiniteDiffTimeMeasure) -> DiffTimeMeasure
x
(FiniteDiffTimeMeasure DiffTime
x, FiniteDiffTimeMeasure DiffTime
y) ->
DiffTime -> DiffTimeMeasure
FiniteDiffTimeMeasure (DiffTime -> DiffTime -> DiffTime
forall a. Ord a => a -> a -> a
min DiffTime
x DiffTime
y)
max :: DiffTimeMeasure -> DiffTimeMeasure -> DiffTimeMeasure
max = ((DiffTimeMeasure, DiffTimeMeasure) -> DiffTimeMeasure)
-> DiffTimeMeasure -> DiffTimeMeasure -> DiffTimeMeasure
forall a b c. ((a, b) -> c) -> a -> b -> c
curry (((DiffTimeMeasure, DiffTimeMeasure) -> DiffTimeMeasure)
-> DiffTimeMeasure -> DiffTimeMeasure -> DiffTimeMeasure)
-> ((DiffTimeMeasure, DiffTimeMeasure) -> DiffTimeMeasure)
-> DiffTimeMeasure
-> DiffTimeMeasure
-> DiffTimeMeasure
forall a b. (a -> b) -> a -> b
$ \case
(DiffTimeMeasure
InfiniteDiffTimeMeasure, DiffTimeMeasure
_) -> DiffTimeMeasure
InfiniteDiffTimeMeasure
(DiffTimeMeasure
_, DiffTimeMeasure
InfiniteDiffTimeMeasure) -> DiffTimeMeasure
InfiniteDiffTimeMeasure
(FiniteDiffTimeMeasure DiffTime
x, FiniteDiffTimeMeasure DiffTime
y) ->
DiffTime -> DiffTimeMeasure
FiniteDiffTimeMeasure (DiffTime -> DiffTime -> DiffTime
forall a. Ord a => a -> a -> a
max DiffTime
x DiffTime
y)
data ExnMempoolTimeout
=
forall blk. Show (GenTx blk) => MkExnMempoolTimeout !DiffTime !(GenTx blk)
instance Show ExnMempoolTimeout where
showsPrec :: Int -> ExnMempoolTimeout -> ShowS
showsPrec Int
p (MkExnMempoolTimeout DiffTime
dur GenTx blk
txid) =
Bool -> ShowS -> ShowS
showParen
(Int
p Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
>= Int
11)
(String -> ShowS
showString String
"ExnMempoolTimeout " ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> DiffTime -> ShowS
forall a. Show a => Int -> a -> ShowS
showsPrec Int
11 DiffTime
dur ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showString String
" " ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> GenTx blk -> ShowS
forall a. Show a => Int -> a -> ShowS
showsPrec Int
11 GenTx blk
txid)
instance Exception ExnMempoolTimeout