ouroboros-consensus-0.18.0.0: Consensus layer for the Ouroboros blockchain protocol
Safe HaskellSafe-Inferred
LanguageHaskell2010

Ouroboros.Consensus.Storage.LedgerDB.Update

Description

Accessors for the LedgerDB and management

This module defines the operations that can be done on a LedgerDB, as well as the procedures to apply a block to a LedgerDB and pushing the resulting LedgerState into the DB.

Synopsis

LedgerDB management

ledgerDbWithAnchorGetTip l ⇒ l → LedgerDB l Source #

Ledger DB starting at the specified ledger state

Applying blocks

data AnnLedgerError l blk Source #

Annotated ledger errors

Constructors

AnnLedgerError 

Fields

Instances

Instances details
Monad m ⇒ ThrowsLedgerError (ExceptT (AnnLedgerError l blk) m) l blk Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.Update

Methods

throwLedgerErrorLedgerDB l → RealPoint blk → LedgerErr l → ExceptT (AnnLedgerError l blk) m a Source #

data Ap m l blk c where Source #

Ap is used to pass information about blocks to ledger DB updates

The constructors serve two purposes:

  • Specify the various parameters a. Are we passing the block by value or by reference? b. Are we applying or reapplying the block?
  • Compute the constraint c on the monad m in order to run the query: a. If we are passing a block by reference, we must be able to resolve it. b. If we are applying rather than reapplying, we might have ledger errors.

Constructors

ReapplyVal ∷ blk → Ap m l blk () 
ApplyVal ∷ blk → Ap m l blk (ThrowsLedgerError m l blk) 
ReapplyRefRealPoint blk → Ap m l blk (ResolvesBlocks m blk) 
ApplyRefRealPoint blk → Ap m l blk (ResolvesBlocks m blk, ThrowsLedgerError m l blk) 
Weaken ∷ (c' ⇒ c) ⇒ Ap m l blk c → Ap m l blk c'

Weaken increases the constraint on the monad m.

This is primarily useful when combining multiple Aps in a single homogeneous structure.

data ExceededRollback Source #

Exceeded maximum rollback supported by the current ledger DB state

Under normal circumstances this will not arise. It can really only happen in the presence of data corruption (or when switching to a shorter fork, but that is disallowed by all currently known Ouroboros protocols).

Records both the supported and the requested rollback.

class Monad m ⇒ ThrowsLedgerError m l blk where Source #

Methods

throwLedgerErrorLedgerDB l → RealPoint blk → LedgerErr l → m a Source #

Instances

Instances details
Monad m ⇒ ThrowsLedgerError (ExceptT (AnnLedgerError l blk) m) l blk Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.Update

Methods

throwLedgerErrorLedgerDB l → RealPoint blk → LedgerErr l → ExceptT (AnnLedgerError l blk) m a Source #

Block resolution

type ResolveBlock m blk = RealPoint blk → m blk Source #

Resolve a block

Resolving a block reference to the actual block lives in m because it might need to read the block from disk (and can therefore not be done inside an STM transaction).

NOTE: The ledger DB will only ask the ChainDB for blocks it knows must exist. If the ChainDB is unable to fulfill the request, data corruption must have happened and the ChainDB should trigger validation mode.

class Monad m ⇒ ResolvesBlocks m blk | m → blk where Source #

Monads in which we can resolve blocks

To guide type inference, we insist that we must be able to infer the type of the block we are resolving from the type of the monad.

Instances

Instances details
Monad m ⇒ ResolvesBlocks (ExceptT e (ReaderT (ResolveBlock m blk) m)) blk Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.Update

Monad m ⇒ ResolvesBlocks (ReaderT (ResolveBlock m blk) m) blk Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.Update

defaultResolveBlocksResolveBlock m blk → ReaderT (ResolveBlock m blk) m a → m a Source #

Updates

ledgerDbBimapAnchorable (WithOrigin SlotNo) a b ⇒ (l → a) → (l → b) → LedgerDB l → AnchoredSeq (WithOrigin SlotNo) a b Source #

Transform the underlying AnchoredSeq using the given functions.

ledgerDbPruneGetTip l ⇒ SecurityParamLedgerDB l → LedgerDB l Source #

Prune snapshots until at we have at most k snapshots in the LedgerDB, excluding the snapshots stored at the anchor.

ledgerDbPush ∷ ∀ m c l blk. (ApplyBlock l blk, Monad m, c) ⇒ LedgerDbCfg l → Ap m l blk c → LedgerDB l → m (LedgerDB l) Source #

ledgerDbSwitch Source #

Arguments

∷ (ApplyBlock l blk, Monad m, c) 
LedgerDbCfg l 
Word64

How many blocks to roll back

→ (UpdateLedgerDbTraceEvent blk → m ()) 
→ [Ap m l blk c]

New blocks to apply

LedgerDB l 
→ m (Either ExceededRollback (LedgerDB l)) 

Switch to a fork

Pure API

ledgerDbPush'ApplyBlock l blk ⇒ LedgerDbCfg l → blk → LedgerDB l → LedgerDB l Source #

ledgerDbPushMany'ApplyBlock l blk ⇒ LedgerDbCfg l → [blk] → LedgerDB l → LedgerDB l Source #

ledgerDbSwitch' ∷ ∀ l blk. ApplyBlock l blk ⇒ LedgerDbCfg l → Word64 → [blk] → LedgerDB l → Maybe (LedgerDB l) Source #

Trace

newtype PushGoal blk Source #

Constructors

PushGoal 

Fields

Instances

Instances details
StandardHash blk ⇒ Show (PushGoal blk) Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.Update

Methods

showsPrecIntPushGoal blk → ShowS #

showPushGoal blk → String #

showList ∷ [PushGoal blk] → ShowS #

StandardHash blk ⇒ Eq (PushGoal blk) Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.Update

Methods

(==)PushGoal blk → PushGoal blk → Bool #

(/=)PushGoal blk → PushGoal blk → Bool #

newtype PushStart blk Source #

Constructors

PushStart 

Fields

Instances

Instances details
StandardHash blk ⇒ Show (PushStart blk) Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.Update

Methods

showsPrecIntPushStart blk → ShowS #

showPushStart blk → String #

showList ∷ [PushStart blk] → ShowS #

StandardHash blk ⇒ Eq (PushStart blk) Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.Update

Methods

(==)PushStart blk → PushStart blk → Bool #

(/=)PushStart blk → PushStart blk → Bool #

newtype Pushing blk Source #

Constructors

Pushing 

Fields

Instances

Instances details
StandardHash blk ⇒ Show (Pushing blk) Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.Update

Methods

showsPrecIntPushing blk → ShowS #

showPushing blk → String #

showList ∷ [Pushing blk] → ShowS #

StandardHash blk ⇒ Eq (Pushing blk) Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.Update

Methods

(==)Pushing blk → Pushing blk → Bool #

(/=)Pushing blk → Pushing blk → Bool #

data UpdateLedgerDbTraceEvent blk Source #

Constructors

StartedPushingBlockToTheLedgerDb

Event fired when we are about to push a block to the LedgerDB

Fields

  • !(PushStart blk)

    Point from which we started pushing new blocks

  • (PushGoal blk)

    Point to which we are updating the ledger, the last event StartedPushingBlockToTheLedgerDb will have Pushing and PushGoal wrapping over the same RealPoint

  • !(Pushing blk)

    Point which block we are about to push

Instances

Instances details
Generic (UpdateLedgerDbTraceEvent blk) Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.Update

Associated Types

type Rep (UpdateLedgerDbTraceEvent blk) ∷ TypeType #

StandardHash blk ⇒ Show (UpdateLedgerDbTraceEvent blk) Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.Update

StandardHash blk ⇒ Eq (UpdateLedgerDbTraceEvent blk) Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.Update

type Rep (UpdateLedgerDbTraceEvent blk) Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.Update

type Rep (UpdateLedgerDbTraceEvent blk) = D1 ('MetaData "UpdateLedgerDbTraceEvent" "Ouroboros.Consensus.Storage.LedgerDB.Update" "ouroboros-consensus-0.18.0.0-inplace" 'False) (C1 ('MetaCons "StartedPushingBlockToTheLedgerDb" 'PrefixI 'False) (S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (PushStart blk)) :*: (S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (PushGoal blk)) :*: S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Pushing blk)))))