ouroboros-consensus-0.26.0.0: Consensus layer for the Ouroboros blockchain protocol
Safe HaskellNone
LanguageHaskell2010

Ouroboros.Consensus.Storage.LedgerDB.Forker

Synopsis

Forker API

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.

data Forker (m ∷ TypeType) (l ∷ LedgerStateKind) blk Source #

An independent handle to a point in the LedgerDB, which can be advanced to evaluate forks in the chain.

Constructors

Forker 

Fields

  • forkerClose ∷ !(m ())

    Close the current forker (idempotent).

    Other functions on forkers should throw a ClosedForkError once the forker is closed.

    Note: always use this functions before the forker is forgotten! Otherwise, cleanup of (on-disk) state might not be prompt or guaranteed.

    This function should release any resources that are held by the forker, and not by the LedgerDB.

  • forkerReadTables ∷ !(LedgerTables l KeysMK → m (LedgerTables l ValuesMK))

    Read ledger tables from disk.

  • forkerRangeReadTables ∷ !(RangeQueryPrevious l → m (LedgerTables l ValuesMK))

    Range-read ledger tables from disk.

    This range read will return as many values as the QueryBatchSize that was passed when opening the LedgerDB.

  • forkerGetLedgerState ∷ !(STM m (l EmptyMK))

    Get the full ledger state without tables.

    If an empty ledger state is all you need, use getVolatileTip, getImmutableTip, or getPastLedgerState instead of using a Forker.

  • forkerReadStatistics ∷ !(m (Maybe Statistics))

    Get statistics about the current state of the handle if possible.

    Returns Nothing if the implementation is backed by lsm-tree.

  • forkerPush ∷ !(l DiffMK → m ())

    Advance the fork handle by pushing a new ledger state to the tip of the current fork.

  • forkerCommit ∷ !(STM m ())

    Commit the fork, which was constructed using forkerPush, as the current version of the LedgerDB.

Instances

Instances details
(GetTip l, HeaderHash l ~ HeaderHash blk, MonadSTM m) ⇒ GetTipSTM m (Forker m l blk) Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.Forker

Methods

getTipSTMForker m l blk → STM m (Point (Forker m l blk)) Source #

type HeaderHash (Forker m l blk ∷ Type) Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.Forker

type HeaderHash (Forker m l blk ∷ Type) = HeaderHash l

type Forker' (m ∷ TypeType) blk = Forker m (ExtLedgerState blk) blk Source #

newtype ForkerKey Source #

An identifier for a Forker. See ldbForkers.

Constructors

ForkerKey Word16 

Instances

Instances details
Enum ForkerKey Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.Forker

Num ForkerKey Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.Forker

Show ForkerKey Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.Forker

Methods

showsPrecIntForkerKeyShowS #

showForkerKeyString #

showList ∷ [ForkerKey] → ShowS #

Eq ForkerKey Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.Forker

Methods

(==)ForkerKeyForkerKeyBool #

(/=)ForkerKeyForkerKeyBool #

Ord ForkerKey Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.Forker

NoThunks ForkerKey Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.Forker

data GetForkerError Source #

Errors that can be thrown while acquiring forkers.

Constructors

PointNotOnChain

The requested point was not found in the LedgerDB, but the point is recent enough that the point is not in the immutable part of the chain, i.e. it belongs to an unselected fork.

PointTooOld !(Maybe ExceededRollback)

The requested point was not found in the LedgerDB because the point older than the immutable tip.

data RangeQuery (l ∷ LedgerStateKind) Source #

Constructors

RangeQuery 

Fields

newtype Statistics Source #

This type captures the size of the ledger tables at a particular point in the LedgerDB.

This is for now the only metric that was requested from other components, but this type might be augmented in the future with more statistics.

Constructors

Statistics 

Fields

forkerCurrentPoint ∷ ∀ (l ∷ LedgerStateKind) blk (m ∷ TypeType). (GetTip l, HeaderHash l ~ HeaderHash blk, Functor (STM m)) ⇒ Forker m l blk → STM m (Point blk) Source #

Read only

data ReadOnlyForker (m ∷ TypeType) (l ∷ LedgerStateKind) blk Source #

Read-only Forker.

These forkers are not allowed to commit. They are used everywhere except in Chain Selection. In particular they are now used in:

  • LocalStateQuery server, via getReadOnlyForkerAtPoint
  • Forging loop.
  • Mempool.

Instances

Instances details
type HeaderHash (ReadOnlyForker m l blk ∷ Type) Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.Forker

type HeaderHash (ReadOnlyForker m l blk ∷ Type) = HeaderHash l

type ReadOnlyForker' (m ∷ TypeType) blk = ReadOnlyForker m (ExtLedgerState blk) blk Source #

readOnlyForker ∷ ∀ (m ∷ TypeType) (l ∷ LedgerStateKind) blk. Forker m l blk → ReadOnlyForker m l blk Source #

Tracing

Validation

data AnnLedgerError (m ∷ TypeType) (l ∷ LedgerStateKind) blk Source #

Annotated ledger errors

Constructors

AnnLedgerError 

Fields

type AnnLedgerError' (m ∷ TypeType) blk = AnnLedgerError m (ExtLedgerState blk) blk Source #

type ResolveBlock (m ∷ TypeType) 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.

data ValidateArgs (m ∷ TypeType) blk Source #

Constructors

ValidateArgs 

Fields

data ValidateResult (m ∷ TypeType) (l ∷ LedgerStateKind) blk Source #

When validating a sequence of blocks, these are the possible outcomes.

validate ∷ (IOLike m, LedgerSupportsProtocol blk, HasCallStack) ⇒ ComputeLedgerEventsValidateArgs m blk → m (ValidateResult' m blk) Source #

Tracing

newtype PushGoal blk Source #

Constructors

PushGoal 

Fields

Instances

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

Defined in Ouroboros.Consensus.Storage.LedgerDB.Forker

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.Forker

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.Forker

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.Forker

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.Forker

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.Forker

Methods

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

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

data TraceValidateEvent blk Source #

Constructors

StartedPushingBlockToTheLedgerDb

Event fired when we are about to push a block to a forker

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 (TraceValidateEvent blk) Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.Forker

Associated Types

type Rep (TraceValidateEvent blk) 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.Forker

type Rep (TraceValidateEvent blk) = D1 ('MetaData "TraceValidateEvent" "Ouroboros.Consensus.Storage.LedgerDB.Forker" "ouroboros-consensus-0.26.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)))))
StandardHash blk ⇒ Show (TraceValidateEvent blk) Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.Forker

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

Defined in Ouroboros.Consensus.Storage.LedgerDB.Forker

type Rep (TraceValidateEvent blk) Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.Forker

type Rep (TraceValidateEvent blk) = D1 ('MetaData "TraceValidateEvent" "Ouroboros.Consensus.Storage.LedgerDB.Forker" "ouroboros-consensus-0.26.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)))))