cardano-ledger-shelley-1.14.0.0: Shelley Ledger Executable Model
Safe HaskellSafe-Inferred
LanguageHaskell2010

Cardano.Ledger.Shelley.API.Mempool

Description

Interface to the Shelley ledger for the purposes of managing a Shelley mempool.

Synopsis

Documentation

applyTx ∷ (ApplyTx era, MonadError (ApplyTxError era) m) ⇒ GlobalsMempoolEnv era → MempoolState era → Tx era → m (MempoolState era, Validated (Tx era)) Source #

Validate a transaction against a mempool state using default STS options and return both the new mempool state and a "validated" TxInBlock.

The meaning of being "validated" depends on the era. In general, a TxInBlock has had all checks run, and can now only fail due to checks which depend on the state; most notably, that UTxO inputs disappear.

class (EraTx era, Eq (ApplyTxError era), Show (ApplyTxError era), Typeable (ApplyTxError era), STS (EraRule "LEDGER" era), BaseM (EraRule "LEDGER" era) ~ ShelleyBase, Environment (EraRule "LEDGER" era) ~ LedgerEnv era, State (EraRule "LEDGER" era) ~ MempoolState era, Signal (EraRule "LEDGER" era) ~ Tx era) ⇒ ApplyTx era where Source #

Minimal complete definition

Nothing

Methods

applyTxOpts ∷ ∀ ep m. (MonadError (ApplyTxError era) m, EventReturnTypeRep ep) ⇒ ApplySTSOpts ep → GlobalsMempoolEnv era → MempoolState era → Tx era → m (EventReturnType ep (EraRule "LEDGER" era) (MempoolState era, Validated (Tx era))) Source #

Validate a transaction against a mempool state and for given STS options, and return the new mempool state, a "validated" TxInBlock and, depending on the passed options, the emitted events.

reapplyTxMonadError (ApplyTxError era) m ⇒ GlobalsMempoolEnv era → MempoolState era → Validated (Tx era) → m (MempoolState era) Source #

Reapply a previously validated Tx.

This applies the (validated) transaction to a new mempool state. It may fail due to the mempool state changing (for example, a needed output having already been spent). It should not fail due to any static check (such as cryptographic checks).

Implementations of this function may optionally skip the performance of any static checks. This is not required, but strongly encouraged since this function will be called each time the mempool revalidates transactions against a new mempool state.

newtype ApplyTxError era Source #

Constructors

ApplyTxError (NonEmpty (PredicateFailure (EraRule "LEDGER" era))) 

Instances

Instances details
Show (PredicateFailure (EraRule "LEDGER" era)) ⇒ Show (ApplyTxError era) Source # 
Instance details

Defined in Cardano.Ledger.Shelley.API.Mempool

(Era era, DecCBOR (PredicateFailure (EraRule "LEDGER" era))) ⇒ FromCBOR (ApplyTxError era) Source # 
Instance details

Defined in Cardano.Ledger.Shelley.API.Mempool

(Era era, EncCBOR (PredicateFailure (EraRule "LEDGER" era))) ⇒ ToCBOR (ApplyTxError era) Source # 
Instance details

Defined in Cardano.Ledger.Shelley.API.Mempool

Methods

toCBORApplyTxError era → Encoding Source #

encodedSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy (ApplyTxError era) → Size Source #

encodedListSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy [ApplyTxError era] → Size Source #

(Era era, DecCBOR (PredicateFailure (EraRule "LEDGER" era))) ⇒ DecCBOR (ApplyTxError era) Source # 
Instance details

Defined in Cardano.Ledger.Shelley.API.Mempool

(Era era, EncCBOR (PredicateFailure (EraRule "LEDGER" era))) ⇒ EncCBOR (ApplyTxError era) Source # 
Instance details

Defined in Cardano.Ledger.Shelley.API.Mempool

Methods

encCBORApplyTxError era → Encoding Source #

encodedSizeExpr ∷ (∀ t. EncCBOR t ⇒ Proxy t → Size) → Proxy (ApplyTxError era) → Size Source #

encodedListSizeExpr ∷ (∀ t. EncCBOR t ⇒ Proxy t → Size) → Proxy [ApplyTxError era] → Size Source #

Eq (PredicateFailure (EraRule "LEDGER" era)) ⇒ Eq (ApplyTxError era) Source # 
Instance details

Defined in Cardano.Ledger.Shelley.API.Mempool

Methods

(==)ApplyTxError era → ApplyTxError era → Bool Source #

(/=)ApplyTxError era → ApplyTxError era → Bool Source #

data Validated tx Source #

A newtype which indicates that a transaction has been validated against some chain state.

Instances

Instances details
Show tx ⇒ Show (Validated tx) Source # 
Instance details

Defined in Cardano.Ledger.Shelley.API.Mempool

Methods

showsPrecIntValidated tx → ShowS Source #

showValidated tx → String Source #

showList ∷ [Validated tx] → ShowS Source #

NFData tx ⇒ NFData (Validated tx) Source # 
Instance details

Defined in Cardano.Ledger.Shelley.API.Mempool

Methods

rnfValidated tx → () Source #

Eq tx ⇒ Eq (Validated tx) Source # 
Instance details

Defined in Cardano.Ledger.Shelley.API.Mempool

Methods

(==)Validated tx → Validated tx → Bool Source #

(/=)Validated tx → Validated tx → Bool Source #

NoThunks tx ⇒ NoThunks (Validated tx) Source # 
Instance details

Defined in Cardano.Ledger.Shelley.API.Mempool

extractTxValidated tx → tx Source #

Extract the underlying unvalidated Tx.

translateValidated ∷ ∀ era f. TranslateEra era f ⇒ TranslationContext era → Validated (f (PreviousEra era)) → Except (TranslationError era f) (Validated (f era)) Source #

Translate a validated transaction across eras.

This is not a TranslateEra instance since Validated is not itself era-parametrised.

Exports for testing

type MempoolEnv era = LedgerEnv era Source #

applyTxsTransition ∷ ∀ era m. (ApplyTx era, MonadError (ApplyTxError era) m) ⇒ GlobalsMempoolEnv era → Seq (Tx era) → MempoolState era → m (MempoolState era) Source #

Deprecated: Use applyTxOpts and mkMempoolEnv instead

Exports for compatibility

applyTxs ∷ (ApplyTx era, MonadError (ApplyTxError era) m, EraGov era) ⇒ GlobalsSlotNoSeq (Tx era) → NewEpochState era → m (NewEpochState era) Source #

Deprecated: Use applyTxOpts and mkMempoolEnv instead

Old applyTxs

mkMempoolEnvEraGov era ⇒ NewEpochState era → SlotNoMempoolEnv era Source #

Construct the environment used to validate transactions from the full ledger state.

Note that this function also takes a slot. During slot validation, the slot given here is the slot of the block containing the transactions. This slot is used for quite a number of things, but in general these do not determine the validity of the transaction. There are two exceptions:

  • Each transaction has a ttl (time-to-live) value. If the slot is beyond this value, then the transaction is invalid.
  • If the transaction contains a protocol update proposal, then it may only be included until a certain number of slots before the end of the epoch. A protocol update proposal submitted after this is considered invalid.

mkMempoolStateNewEpochState era → MempoolState era Source #

Construct a mempool state from the wider ledger state.

The given mempool state may then be evolved using applyTxs, but should be regenerated when the ledger state gets updated (e.g. through application of a new block).

overNewEpochStateFunctor f ⇒ (MempoolState era → f (MempoolState era)) → NewEpochState era → f (NewEpochState era) Source #

Transform a function over mempool states to one over the full NewEpochState.