Safe Haskell | None |
---|---|
Language | Haskell2010 |
Ouroboros.Consensus.Mempool.Impl.Types
Description
Types required for implementing the Mempool.
Synopsis
-
data
InternalState
blk =
IS
{
- isTxs :: !( TxSeq ( Validated ( GenTx blk)))
- isTxIds :: !( Set ( GenTxId blk))
- isLedgerState :: !( TickedLedgerState blk)
- isTip :: !( ChainHash blk)
- isSlotNo :: ! SlotNo
- isLastTicketNo :: ! TicketNo
- isCapacity :: ! MempoolCapacityBytes
- initInternalState :: LedgerSupportsMempool blk => MempoolCapacityBytesOverride -> TicketNo -> SlotNo -> TickedLedgerState blk -> InternalState blk
- isMempoolSize :: InternalState blk -> MempoolSize
-
data
ValidationResult
invalidTx blk =
ValidationResult
{
- vrBeforeTip :: ChainHash blk
- vrSlotNo :: SlotNo
- vrBeforeCapacity :: MempoolCapacityBytes
- vrValid :: TxSeq ( Validated ( GenTx blk))
- vrValidTxIds :: Set ( GenTxId blk)
- vrNewValid :: Maybe ( Validated ( GenTx blk))
- vrAfter :: TickedLedgerState blk
- vrInvalid :: [(invalidTx, ApplyTxErr blk)]
- vrLastTicketNo :: TicketNo
- extendVRNew :: ( LedgerSupportsMempool blk, HasTxId ( GenTx blk)) => LedgerConfig blk -> ( GenTx blk -> TxSizeInBytes ) -> WhetherToIntervene -> GenTx blk -> ValidationResult ( GenTx blk) blk -> ( Either ( ApplyTxErr blk) ( Validated ( GenTx blk)), ValidationResult ( GenTx blk) blk)
- extendVRPrevApplied :: ( LedgerSupportsMempool blk, HasTxId ( GenTx blk)) => LedgerConfig blk -> TxTicket ( Validated ( GenTx blk)) -> ValidationResult ( Validated ( GenTx blk)) blk -> ValidationResult ( Validated ( GenTx blk)) blk
- revalidateTxsFor :: ( LedgerSupportsMempool blk, HasTxId ( GenTx blk)) => MempoolCapacityBytesOverride -> LedgerConfig blk -> SlotNo -> TickedLedgerState blk -> TicketNo -> [ TxTicket ( Validated ( GenTx blk))] -> ValidationResult ( Validated ( GenTx blk)) blk
- validateIS :: ( LedgerSupportsMempool blk, HasTxId ( GenTx blk), ValidateEnvelope blk) => InternalState blk -> LedgerState blk -> LedgerConfig blk -> MempoolCapacityBytesOverride -> ValidationResult ( Validated ( GenTx blk)) blk
- validateStateFor :: ( LedgerSupportsMempool blk, HasTxId ( GenTx blk), ValidateEnvelope blk) => MempoolCapacityBytesOverride -> LedgerConfig blk -> ForgeLedgerState blk -> InternalState blk -> ValidationResult ( Validated ( GenTx blk)) blk
- tickLedgerState :: forall blk. ( UpdateLedger blk, ValidateEnvelope blk) => LedgerConfig blk -> ForgeLedgerState blk -> ( SlotNo , TickedLedgerState blk)
- internalStateFromVR :: ValidationResult invalidTx blk -> InternalState blk
- validationResultFromIS :: InternalState blk -> ValidationResult invalidTx blk
Internal State
data InternalState blk Source #
Internal state in the mempool
Constructors
IS | |
Fields
|
Instances
Arguments
:: LedgerSupportsMempool blk | |
=> MempoolCapacityBytesOverride | |
-> TicketNo |
Used for
|
-> SlotNo | |
-> TickedLedgerState blk | |
-> InternalState blk |
isMempoolSize :: InternalState blk -> MempoolSize Source #
\( O(1) \) . Return the number of transactions in the internal state of the Mempool paired with their total size in bytes.
Validation result
data ValidationResult invalidTx blk Source #
Constructors
ValidationResult | |
Fields
|
extendVRNew :: ( LedgerSupportsMempool blk, HasTxId ( GenTx blk)) => LedgerConfig blk -> ( GenTx blk -> TxSizeInBytes ) -> WhetherToIntervene -> GenTx blk -> ValidationResult ( GenTx blk) blk -> ( Either ( ApplyTxErr blk) ( Validated ( GenTx blk)), ValidationResult ( GenTx blk) blk) Source #
Extend
ValidationResult
with a new transaction (one which we have not
previously validated) that may or may not be valid in this ledger state.
PRECONDITION:
vrNewValid
is
Nothing
. In other words: new transactions
should be validated one-by-one, not by calling
extendVRNew
on its result
again.
extendVRPrevApplied :: ( LedgerSupportsMempool blk, HasTxId ( GenTx blk)) => LedgerConfig blk -> TxTicket ( Validated ( GenTx blk)) -> ValidationResult ( Validated ( GenTx blk)) blk -> ValidationResult ( Validated ( GenTx blk)) blk Source #
Extend
ValidationResult
with a previously validated transaction that
may or may not be valid in this ledger state
n.b. Even previously validated transactions may not be valid in a different
ledger state; it is
still
useful to indicate whether we have previously
validated this transaction because, if we have, we can utilize
reapplyTx
rather than
applyTx
and, therefore, skip things like cryptographic
signatures.
Arguments
:: ( LedgerSupportsMempool blk, HasTxId ( GenTx blk)) | |
=> MempoolCapacityBytesOverride | |
-> LedgerConfig blk | |
-> SlotNo | |
-> TickedLedgerState blk | |
-> TicketNo | |
-> [ TxTicket ( Validated ( GenTx blk))] | |
-> ValidationResult ( Validated ( GenTx blk)) blk |
validateIS :: ( LedgerSupportsMempool blk, HasTxId ( GenTx blk), ValidateEnvelope blk) => InternalState blk -> LedgerState blk -> LedgerConfig blk -> MempoolCapacityBytesOverride -> ValidationResult ( Validated ( GenTx blk)) blk Source #
Validate the internal state against the current ledger state and the
given
BlockSlot
, revalidating if necessary.
validateStateFor :: ( LedgerSupportsMempool blk, HasTxId ( GenTx blk), ValidateEnvelope blk) => MempoolCapacityBytesOverride -> LedgerConfig blk -> ForgeLedgerState blk -> InternalState blk -> ValidationResult ( Validated ( GenTx blk)) blk Source #
Given a (valid) internal state, validate it against the given ledger
state and
BlockSlot
.
When these match the internal state's
isTip
and
isSlotNo
, this is very
cheap, as the given internal state will already be valid against the given
inputs.
When these don't match, the transaction in the internal state will be
revalidated (
revalidateTxsFor
).
Tick ledger state
tickLedgerState :: forall blk. ( UpdateLedger blk, ValidateEnvelope blk) => LedgerConfig blk -> ForgeLedgerState blk -> ( SlotNo , TickedLedgerState blk) Source #
Tick the
LedgerState
using the given
BlockSlot
.
Conversions
internalStateFromVR :: ValidationResult invalidTx blk -> InternalState blk Source #
Construct internal state from
ValidationResult
Discards information about invalid and newly valid transactions
validationResultFromIS :: InternalState blk -> ValidationResult invalidTx blk Source #
Construct a
ValidationResult
from internal state.