Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Mempool capacity, size and transaction size datatypes.
This module also defines how to manually override the mempool capacity.
import Ouroboros.Consensus.Mempool.Capacity (Capacity) import qualified Ouroboros.Consensus.Mempool.Capacity as Capacity
Synopsis
- newtype MempoolCapacityBytes = MempoolCapacityBytes {}
- data MempoolCapacityBytesOverride
- computeMempoolCapacity ∷ LedgerSupportsMempool blk ⇒ TickedLedgerState blk → MempoolCapacityBytesOverride → MempoolCapacityBytes
- mkCapacityBytesOverride ∷ Word32 → MempoolCapacityBytesOverride
- data MempoolSize = MempoolSize {
- msNumTxs ∷ !Word32
- msNumBytes ∷ !Word32
- newtype ByteSize = ByteSize {}
- class BoundedMeasure (TxMeasure blk) ⇒ TxLimits blk where
- type TxMeasure blk
- txMeasure ∷ Validated (GenTx blk) → TxMeasure blk
- txsBlockCapacity ∷ Ticked (LedgerState blk) → TxMeasure blk
- (<=) ∷ Measure a ⇒ a → a → Bool
- data TxOverrides blk
- applyOverrides ∷ TxLimits blk ⇒ TxOverrides blk → TxMeasure blk → TxMeasure blk
- getOverrides ∷ TxOverrides blk → TxMeasure blk
- mkOverrides ∷ TxMeasure blk → TxOverrides blk
- noOverridesMeasure ∷ BoundedMeasure a ⇒ a
Mempool capacity
newtype MempoolCapacityBytes Source #
Represents the maximum number of bytes worth of transactions that a
Mempool
can contain.
Instances
data MempoolCapacityBytesOverride Source #
An override for the default MempoolCapacityBytes
which is 2x the
maximum transaction capacity
NoMempoolCapacityBytesOverride | Use 2x the maximum transaction capacity of a block. This will change dynamically with the protocol parameters adopted in the current ledger. |
MempoolCapacityBytesOverride !MempoolCapacityBytes | Use the following |
computeMempoolCapacity ∷ LedgerSupportsMempool blk ⇒ TickedLedgerState blk → MempoolCapacityBytesOverride → MempoolCapacityBytes Source #
If no override is provided, calculate the default mempool capacity as 2x the current ledger's maximum transaction capacity of a block.
mkCapacityBytesOverride ∷ Word32 → MempoolCapacityBytesOverride Source #
Create an override for the mempool capacity using the provided number of bytes.
Mempool Size
data MempoolSize Source #
The size of a mempool.
MempoolSize | |
|
Instances
Monoid MempoolSize Source # | |
Defined in Ouroboros.Consensus.Mempool.Capacity mappend ∷ MempoolSize → MempoolSize → MempoolSize # mconcat ∷ [MempoolSize] → MempoolSize # | |
Semigroup MempoolSize Source # | |
Defined in Ouroboros.Consensus.Mempool.Capacity (<>) ∷ MempoolSize → MempoolSize → MempoolSize # sconcat ∷ NonEmpty MempoolSize → MempoolSize # stimes ∷ Integral b ⇒ b → MempoolSize → MempoolSize # | |
Show MempoolSize Source # | |
Defined in Ouroboros.Consensus.Mempool.Capacity showsPrec ∷ Int → MempoolSize → ShowS # show ∷ MempoolSize → String # showList ∷ [MempoolSize] → ShowS # | |
Eq MempoolSize Source # | |
Defined in Ouroboros.Consensus.Mempool.Capacity (==) ∷ MempoolSize → MempoolSize → Bool # (/=) ∷ MempoolSize → MempoolSize → Bool # |
Transaction size
class BoundedMeasure (TxMeasure blk) ⇒ TxLimits blk where Source #
Each block has its limits of how many transactions it can hold. That limit is compared against the sum of measurements taken of each of the transactions in that block.
How we measure the transaction depends of the era that this transaction belongs to (more specifically it depends on the block type to which this transaction will be added). For initial eras (like Byron and initial generations of Shelley based eras) this measure was simply a ByteSize (block could not be bigger then given size - in bytes - specified by the ledger state). In future eras (starting with Alonzo) this measure was a bit more complex as it had to take other factors into account (like execution units). For details please see the individual instances for the TxLimits.
(<=) ∷ Measure a ⇒ a → a → Bool Source #
Is every component of the first value less-than-or-equal-to the corresponding component of the second value?
Restricting more strongly than the ledger's limits
data TxOverrides blk Source #
An override that lowers a capacity limit
Specifically, we use this override to let the node operator limit the total
TxMeasure
of transactions in blocks even more severely than would the
ledger state's txsBlockCapacity
. The forge logic will use the min
(ie the lattice's meet
operator) to combine this override with the capacity
given by the ledger state. More concretely, that will typically be a
componentwise minimum operation, along each of the components/dimensions of
.TxMeasure
blk
This newtype wrapper distinguishes the intention of this particular
TxMeasure
as such an override. We use TxMeasure
in different ways in this
code base. The newtype also allows us to distinguish the one most appropriate
monoid among many offered by the TxLimits
superclass constraints: it is the
monoid induced by the bounded meet-semilattice (see BoundedMeasure
) that is
relevant to the notion of overriding the ledger's block capacity.
Instances
TxLimits blk ⇒ Monoid (TxOverrides blk) Source # | |
Defined in Ouroboros.Consensus.Mempool.Capacity mempty ∷ TxOverrides blk # mappend ∷ TxOverrides blk → TxOverrides blk → TxOverrides blk # mconcat ∷ [TxOverrides blk] → TxOverrides blk # | |
TxLimits blk ⇒ Semigroup (TxOverrides blk) Source # | |
Defined in Ouroboros.Consensus.Mempool.Capacity (<>) ∷ TxOverrides blk → TxOverrides blk → TxOverrides blk # sconcat ∷ NonEmpty (TxOverrides blk) → TxOverrides blk # stimes ∷ Integral b ⇒ b → TxOverrides blk → TxOverrides blk # |
applyOverrides ∷ TxLimits blk ⇒ TxOverrides blk → TxMeasure blk → TxMeasure blk Source #
Apply the override
getOverrides ∷ TxOverrides blk → TxMeasure blk Source #
mkOverrides ∷ TxMeasure blk → TxOverrides blk Source #
Smart constructor for Overrides
.
noOverridesMeasure ∷ BoundedMeasure a ⇒ a Source #
applyOverrides
noOverrides
m = m