Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
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 {
- lgrDiskPolicyArgs ∷ DiskPolicyArgs
- lgrGenesis ∷ HKD f (m (ExtLedgerState blk))
- lgrHasFS ∷ HKD f (SomeHasFS m)
- lgrConfig ∷ HKD f (LedgerDbCfg (ExtLedgerState blk))
- lgrTracer ∷ Tracer m (TraceSnapshotEvent blk)
- defaultArgs ∷ Applicative m ⇒ Incomplete LgrDbArgs m blk
- openDB ∷ ∀ m blk. (IOLike m, LedgerSupportsProtocol blk, LgrDbSerialiseConstraints blk, InspectLedger blk, HasCallStack) ⇒ Complete LgrDbArgs 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 ∷ ∀ 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 ∷ ∀ m blk. (IOLike m, LgrDbSerialiseConstraints blk, HasHeader blk, IsLedger (LedgerState blk)) ⇒ LgrDB m blk → m (Maybe (DiskSnapshot, RealPoint blk))
- trimSnapshots ∷ ∀ m blk. (MonadCatch m, HasHeader blk) ⇒ LgrDB m blk → m [DiskSnapshot]
- data ValidateResult blk
- validate ∷ ∀ 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 AnnLedgerError l blk = AnnLedgerError {
- annLedgerState ∷ LedgerDB l
- annLedgerErrRef ∷ RealPoint blk
- annLedgerErr ∷ LedgerErr l
- data DiskPolicy = DiskPolicy {
- onDiskNumSnapshots ∷ Word
- onDiskShouldTakeSnapshot ∷ TimeSinceLast DiffTime → Word64 → Bool
- onDiskShouldChecksumSnapshots ∷ Flag "DoDiskSnapshotChecksum"
- data DiskSnapshot
- data ExceededRollback = ExceededRollback {}
- data TraceReplayEvent blk
- = ReplayFromGenesis (ReplayGoal blk)
- | ReplayFromSnapshot DiskSnapshot (ReplayStart blk) (ReplayGoal blk)
- | ReplayedBlock (RealPoint blk) [LedgerEvent blk] (ReplayStart blk) (ReplayGoal blk)
- data TraceSnapshotEvent blk
- ledgerDbCurrent ∷ GetTip l ⇒ LedgerDB l → l
- mkLgrDB ∷ StrictTVar m (LedgerDB' blk) → StrictTVar m (Set (RealPoint blk)) → (RealPoint blk → m blk) → Complete LgrDbArgs m blk → SecurityParam → 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 #
LgrDbArgs | |
|
defaultArgs ∷ Applicative m ⇒ Incomplete LgrDbArgs m blk Source #
Default arguments
∷ ∀ m blk. (IOLike m, LedgerSupportsProtocol blk, LgrDbSerialiseConstraints blk, InspectLedger blk, HasCallStack) | |
⇒ Complete LgrDbArgs 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 #
∷ 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 ∷ ∀ 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 ∷ ∀ m blk. (IOLike m, LgrDbSerialiseConstraints blk, HasHeader blk, IsLedger (LedgerState blk)) ⇒ LgrDB m blk → m (Maybe (DiskSnapshot, RealPoint blk)) Source #
trimSnapshots ∷ ∀ m blk. (MonadCatch m, HasHeader blk) ⇒ LgrDB m blk → m [DiskSnapshot] Source #
Validation
data ValidateResult blk Source #
∷ ∀ 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 AnnLedgerError l blk Source #
Annotated ledger errors
AnnLedgerError | |
|
Instances
Monad m ⇒ ThrowsLedgerError (ExceptT (AnnLedgerError l blk) m) l blk Source # | |
Defined in Ouroboros.Consensus.Storage.LedgerDB.Update throwLedgerError ∷ LedgerDB l → RealPoint blk → LedgerErr l → ExceptT (AnnLedgerError l blk) m a Source # |
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.
DiskPolicy | |
|
Instances
data DiskSnapshot Source #
Name of a disk snapshot.
The snapshot itself might not yet exist on disk.
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.
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.
ReplayFromGenesis | There were no LedgerDB snapshots on disk, so we're replaying all blocks starting from Genesis against the initial ledger. |
| |
ReplayFromSnapshot | |
| |
ReplayedBlock | |
|
Instances
data TraceSnapshotEvent blk Source #
InvalidSnapshot DiskSnapshot (SnapshotFailure blk) | An on disk snapshot was skipped because it was invalid. |
TookSnapshot DiskSnapshot (RealPoint blk) EnclosingTimed | A snapshot was written to disk. |
DeletedSnapshot DiskSnapshot | An old or invalid on-disk snapshot was deleted. |
SnapshotMissingChecksum DiskSnapshot | The checksum file for a snapshot was missing and was not checked |
Instances
ledgerDbCurrent ∷ GetTip l ⇒ LedgerDB l → l Source #
The ledger state at the tip of the chain
Exported for testing purposes
mkLgrDB ∷ StrictTVar m (LedgerDB' blk) → StrictTVar m (Set (RealPoint blk)) → (RealPoint blk → m blk) → Complete LgrDbArgs m blk → SecurityParam → LgrDB m blk Source #
For testing purposes