Safe Haskell | None |
---|---|
Language | Haskell2010 |
Ouroboros.Consensus.Storage.ChainDB.Impl.LgrDB
Description
Thin wrapper around the LedgerDB
Synopsis
- data LgrDB m blk
- type LedgerDB' blk = LedgerDB ( ExtLedgerState blk)
- type LgrDbSerialiseConstraints blk = ( Serialise ( HeaderHash blk), EncodeDisk blk ( LedgerState blk), DecodeDisk blk ( LedgerState blk), EncodeDisk blk ( AnnTip blk), DecodeDisk blk ( AnnTip blk), EncodeDisk blk ( ChainDepState ( BlockProtocol blk)), DecodeDisk blk ( ChainDepState ( BlockProtocol blk)))
-
data
LgrDbArgs
f m blk =
LgrDbArgs
{
- lgrDiskPolicy :: DiskPolicy
- lgrGenesis :: HKD f (m ( ExtLedgerState blk))
- lgrHasFS :: SomeHasFS m
- lgrTopLevelConfig :: HKD f ( TopLevelConfig blk)
- lgrTraceLedger :: Tracer m ( LedgerDB' blk)
- lgrTracer :: Tracer m ( TraceEvent blk)
- defaultArgs :: Applicative m => SomeHasFS m -> DiskPolicy -> LgrDbArgs Defaults m blk
- openDB :: forall m blk. ( IOLike m, LedgerSupportsProtocol blk, LgrDbSerialiseConstraints blk, InspectLedger blk, HasCallStack ) => LgrDbArgs Identity m blk -> Tracer m ( ReplayGoal blk -> TraceReplayEvent blk) -> ImmutableDB m blk -> ( RealPoint blk -> m blk) -> m ( LgrDB m blk, Word64 )
- decorateReplayTracerWithGoal :: Point blk -> Tracer m ( TraceReplayEvent blk) -> Tracer m ( ReplayGoal blk -> TraceReplayEvent blk)
- currentPoint :: forall blk. UpdateLedger blk => LedgerDB' blk -> Point blk
- getCurrent :: IOLike m => LgrDB m blk -> STM m ( LedgerDB' blk)
- getDiskPolicy :: LgrDB m blk -> DiskPolicy
- setCurrent :: IOLike m => LgrDB m blk -> LedgerDB' blk -> STM m ()
- takeSnapshot :: forall m blk. ( IOLike m, LgrDbSerialiseConstraints blk, HasHeader blk, IsLedger ( LedgerState blk)) => LgrDB m blk -> m ( Maybe ( DiskSnapshot , RealPoint blk))
- trimSnapshots :: forall m blk. ( MonadCatch m, HasHeader blk) => LgrDB m blk -> m [ DiskSnapshot ]
- data ValidateResult blk
- validate :: forall m blk. ( IOLike m, LedgerSupportsProtocol blk, HasCallStack ) => LgrDB m blk -> LedgerDB' blk -> BlockCache blk -> Word64 -> ( UpdateLedgerDbTraceEvent blk -> m ()) -> [ Header blk] -> m ( ValidateResult blk)
- garbageCollectPrevApplied :: IOLike m => LgrDB m blk -> SlotNo -> STM m ()
- getPrevApplied :: IOLike m => LgrDB m blk -> STM m ( Set ( RealPoint blk))
- data DiskPolicy = DiskPolicy { }
- data DiskSnapshot
- data ExceededRollback = ExceededRollback { }
-
data
AnnLedgerError
l blk =
AnnLedgerError
{
- annLedgerState :: LedgerDB l
- annLedgerErrRef :: RealPoint blk
- annLedgerErr :: LedgerErr l
- ledgerDbCurrent :: GetTip l => LedgerDB l -> l
-
data
TraceEvent
blk
- = InvalidSnapshot DiskSnapshot ( InitFailure blk)
- | TookSnapshot DiskSnapshot ( RealPoint blk)
- | DeletedSnapshot DiskSnapshot
-
data
TraceReplayEvent
blk
- = ReplayFromGenesis ( ReplayGoal blk)
- | ReplayFromSnapshot DiskSnapshot ( RealPoint blk) ( ReplayStart blk) ( ReplayGoal blk)
- | ReplayedBlock ( RealPoint blk) [ LedgerEvent blk] ( ReplayStart blk) ( ReplayGoal blk)
- mkLgrDB :: StrictTVar m ( LedgerDB' blk) -> StrictTVar m ( Set ( RealPoint blk)) -> ( RealPoint blk -> m blk) -> LgrDbArgs Identity m blk -> LgrDB m blk
Documentation
Thin wrapper around the ledger database
Instances
type LedgerDB' blk = LedgerDB ( ExtLedgerState blk) Source #
type LgrDbSerialiseConstraints blk = ( Serialise ( HeaderHash blk), EncodeDisk blk ( LedgerState blk), DecodeDisk blk ( LedgerState blk), EncodeDisk blk ( AnnTip blk), DecodeDisk blk ( AnnTip blk), EncodeDisk blk ( ChainDepState ( BlockProtocol blk)), DecodeDisk blk ( ChainDepState ( BlockProtocol blk))) Source #
EncodeDisk
and
DecodeDisk
constraints needed for the LgrDB.
Initialization
data LgrDbArgs f m blk Source #
Constructors
LgrDbArgs | |
Fields
|
defaultArgs :: Applicative m => SomeHasFS m -> DiskPolicy -> LgrDbArgs Defaults m blk Source #
Default arguments
Arguments
:: forall m blk. ( IOLike m, LedgerSupportsProtocol blk, LgrDbSerialiseConstraints blk, InspectLedger blk, HasCallStack ) | |
=> LgrDbArgs Identity m blk |
Stateless initializaton arguments |
-> Tracer m ( ReplayGoal blk -> TraceReplayEvent blk) |
Used to trace the progress while replaying blocks against the ledger. |
-> ImmutableDB m blk |
Reference to the immutable DB After reading a snapshot from disk, the ledger DB will be brought up to date with tip of the immutable DB. The corresponding ledger state can then be used as the starting point for chain selection in the ChainDB driver. |
-> ( RealPoint blk -> m blk) |
Read a block from disk The block may be in the immutable DB or in the volatile DB; the ledger DB does not know where the boundary is at any given point. |
-> m ( LgrDB m blk, Word64 ) |
Open the ledger DB
In addition to the ledger DB also returns the number of immutable blocks that were replayed.
TraceReplayEvent
decorator
decorateReplayTracerWithGoal Source #
Arguments
:: Point blk |
Tip of the ImmutableDB |
-> Tracer m ( TraceReplayEvent blk) | |
-> Tracer m ( ReplayGoal blk -> TraceReplayEvent blk) |
Add the tip of the Immutable DB to the trace event
Between the tip of the immutable DB and the point of the starting block, the node could (if it so desired) easily compute a "percentage complete".
Wrappers
currentPoint :: forall blk. UpdateLedger blk => LedgerDB' blk -> Point blk Source #
getDiskPolicy :: LgrDB m blk -> DiskPolicy Source #
setCurrent :: IOLike m => LgrDB m blk -> LedgerDB' blk -> STM m () Source #
PRECONDITION: The new
LedgerDB
must be the result of calling either
ledgerDbSwitch
or
ledgerDbPushMany
on the current
LedgerDB
.
takeSnapshot :: forall m blk. ( IOLike m, LgrDbSerialiseConstraints blk, HasHeader blk, IsLedger ( LedgerState blk)) => LgrDB m blk -> m ( Maybe ( DiskSnapshot , RealPoint blk)) Source #
trimSnapshots :: forall m blk. ( MonadCatch m, HasHeader blk) => LgrDB m blk -> m [ DiskSnapshot ] Source #
Validation
data ValidateResult blk Source #
Constructors
ValidateSuccessful ( LedgerDB' blk) | |
ValidateLedgerError ( AnnLedgerError' blk) | |
ValidateExceededRollBack ExceededRollback |
Arguments
:: forall m blk. ( IOLike m, LedgerSupportsProtocol blk, HasCallStack ) | |
=> LgrDB m blk | |
-> LedgerDB' blk |
This is used as the starting point for validation, not the one
in the
|
-> BlockCache blk | |
-> Word64 |
How many blocks to roll back |
-> ( UpdateLedgerDbTraceEvent blk -> m ()) | |
-> [ Header blk] | |
-> m ( ValidateResult blk) |
Previously applied blocks
garbageCollectPrevApplied :: IOLike m => LgrDB m blk -> SlotNo -> STM m () Source #
Remove all points with a slot older than the given slot from the set of previously applied points.
Re-exports
data DiskPolicy Source #
On-disk policy
We only write ledger states that are older than
k
blocks to disk (that is,
snapshots that are guaranteed valid). The on-disk policy determines how often
we write to disk and how many checkpoints we keep.
Constructors
DiskPolicy | |
Fields
|
Instances
data DiskSnapshot Source #
Instances
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.
Constructors
ExceededRollback | |
Fields |
data AnnLedgerError l blk Source #
Annotated ledger errors
Constructors
AnnLedgerError | |
Fields
|
Instances
Monad m => ThrowsLedgerError ( ExceptT ( AnnLedgerError l blk) m) l blk Source # | |
Defined in Ouroboros.Consensus.Storage.LedgerDB.InMemory Methods throwLedgerError :: LedgerDB l -> RealPoint blk -> LedgerErr l -> ExceptT ( AnnLedgerError l blk) m a Source # |
ledgerDbCurrent :: GetTip l => LedgerDB l -> l Source #
The ledger state at the tip of the chain
data TraceEvent blk Source #
Constructors
InvalidSnapshot DiskSnapshot ( InitFailure blk) |
An on disk snapshot was skipped because it was invalid. |
TookSnapshot DiskSnapshot ( RealPoint blk) |
A snapshot was written to disk. |
DeletedSnapshot DiskSnapshot |
An old or invalid on-disk snapshot was deleted |
Instances
data TraceReplayEvent blk Source #
Events traced while replaying blocks against the ledger to bring it up to date w.r.t. the tip of the ImmutableDB during initialisation. As this process takes a while, we trace events to inform higher layers of our progress.
Constructors
ReplayFromGenesis ( ReplayGoal blk) |
There were no LedgerDB snapshots on disk, so we're replaying all blocks starting from Genesis against the initial ledger. |
ReplayFromSnapshot | |
Fields
|
|
ReplayedBlock | |
Fields
|