Safe Haskell | None |
---|---|
Language | Haskell2010 |
Ouroboros.Consensus.Storage.ChainDB.Impl
Synopsis
-
data
ChainDbArgs
f m blk =
ChainDbArgs
{
- cdbHasFSImmutableDB :: SomeHasFS m
- cdbHasFSVolatileDB :: SomeHasFS m
- cdbHasFSLgrDB :: SomeHasFS m
- cdbImmutableDbValidation :: ValidationPolicy
- cdbVolatileDbValidation :: BlockValidationPolicy
- cdbMaxBlocksPerFile :: BlocksPerFile
- cdbDiskPolicy :: DiskPolicy
- cdbTopLevelConfig :: HKD f ( TopLevelConfig blk)
- cdbChunkInfo :: HKD f ChunkInfo
- cdbCheckIntegrity :: HKD f (blk -> Bool )
- cdbGenesis :: HKD f (m ( ExtLedgerState blk))
- cdbCheckInFuture :: HKD f ( CheckInFuture m blk)
- cdbImmutableDbCacheConfig :: CacheConfig
- cdbTracer :: Tracer m ( TraceEvent blk)
- cdbTraceLedger :: Tracer m ( LedgerDB' blk)
- cdbRegistry :: HKD f ( ResourceRegistry m)
- cdbGcDelay :: DiffTime
- cdbGcInterval :: DiffTime
- cdbBlocksToAddSize :: Word
- class ( ImmutableDbSerialiseConstraints blk, LgrDbSerialiseConstraints blk, VolatileDbSerialiseConstraints blk, EncodeDiskDep ( NestedCtxt Header ) blk) => SerialiseDiskConstraints blk
- defaultArgs :: forall m blk. Monad m => ( RelativeMountPoint -> SomeHasFS m) -> DiskPolicy -> ChainDbArgs Defaults m blk
- openDB :: forall m blk. ( IOLike m, LedgerSupportsProtocol blk, InspectLedger blk, HasHardForkHistory blk, ConvertRawHash blk, SerialiseDiskConstraints blk) => ChainDbArgs Identity m blk -> m ( ChainDB m blk)
- withDB :: forall m blk a. ( IOLike m, LedgerSupportsProtocol blk, InspectLedger blk, HasHardForkHistory blk, ConvertRawHash blk, SerialiseDiskConstraints blk) => ChainDbArgs Identity m blk -> ( ChainDB m blk -> m a) -> m a
- data TraceReplayEvent blk
-
data
NewTipInfo
blk =
NewTipInfo
{
- newTipPoint :: RealPoint blk
- newTipEpoch :: EpochNo
- newTipSlotInEpoch :: Word64
- newTipTrigger :: RealPoint blk
-
data
TraceAddBlockEvent
blk
- = IgnoreBlockOlderThanK ( RealPoint blk)
- | IgnoreBlockAlreadyInVolatileDB ( RealPoint blk)
- | IgnoreInvalidBlock ( RealPoint blk) ( InvalidBlockReason blk)
- | AddedBlockToQueue ( RealPoint blk) ( Enclosing' Word )
- | PoppedBlockFromQueue ( Enclosing' ( RealPoint blk))
- | BlockInTheFuture ( RealPoint blk) SlotNo
- | AddedBlockToVolatileDB ( RealPoint blk) BlockNo IsEBB Enclosing
- | TryAddToCurrentChain ( RealPoint blk)
- | TrySwitchToAFork ( RealPoint blk) ( ChainDiff ( HeaderFields blk))
- | StoreButDontChange ( RealPoint blk)
- | AddedToCurrentChain [ LedgerEvent blk] ( NewTipInfo blk) ( AnchoredFragment ( Header blk)) ( AnchoredFragment ( Header blk))
- | SwitchedToAFork [ LedgerEvent blk] ( NewTipInfo blk) ( AnchoredFragment ( Header blk)) ( AnchoredFragment ( Header blk))
- | AddBlockValidation ( TraceValidationEvent blk)
- | ChainSelectionForFutureBlock ( RealPoint blk)
- | PipeliningEvent ( TracePipeliningEvent blk)
- | ChangingSelection ( Point blk)
- data TraceCopyToImmutableDBEvent blk
-
data
TraceEvent
blk
- = TraceAddBlockEvent ( TraceAddBlockEvent blk)
- | TraceFollowerEvent ( TraceFollowerEvent blk)
- | TraceCopyToImmutableDBEvent ( TraceCopyToImmutableDBEvent blk)
- | TraceGCEvent ( TraceGCEvent blk)
- | TraceInitChainSelEvent ( TraceInitChainSelEvent blk)
- | TraceOpenEvent ( TraceOpenEvent blk)
- | TraceIteratorEvent ( TraceIteratorEvent blk)
- | TraceLedgerEvent ( TraceEvent blk)
- | TraceLedgerReplayEvent ( TraceReplayEvent blk)
- | TraceImmutableDBEvent ( TraceEvent blk)
- | TraceVolatileDBEvent ( TraceEvent blk)
-
data
TraceFollowerEvent
blk
- = NewFollower
- | FollowerNoLongerInMem ( FollowerRollState blk)
- | FollowerSwitchToMem ( Point blk) ( WithOrigin SlotNo )
- | FollowerNewImmIterator ( Point blk) ( WithOrigin SlotNo )
- data TraceGCEvent blk
- data TraceInitChainSelEvent blk
-
data
TraceIteratorEvent
blk
- = UnknownRangeRequested ( UnknownRange blk)
- | StreamFromVolatileDB ( StreamFrom blk) ( StreamTo blk) [ RealPoint blk]
- | StreamFromImmutableDB ( StreamFrom blk) ( StreamTo blk)
- | StreamFromBoth ( StreamFrom blk) ( StreamTo blk) [ RealPoint blk]
- | BlockMissingFromVolatileDB ( RealPoint blk)
- | BlockWasCopiedToImmutableDB ( RealPoint blk)
- | BlockGCedFromVolatileDB ( RealPoint blk)
- | SwitchBackToVolatileDB
-
data
TraceOpenEvent
blk
- = StartedOpeningDB
- | OpenedDB ( Point blk) ( Point blk)
- | ClosedDB ( Point blk) ( Point blk)
- | StartedOpeningImmutableDB
- | OpenedImmutableDB ( Point blk) ChunkNo
- | StartedOpeningVolatileDB
- | OpenedVolatileDB
- | StartedOpeningLgrDB
- | OpenedLgrDB
-
data
TracePipeliningEvent
blk
- = SetTentativeHeader ( Header blk) Enclosing
- | TrapTentativeHeader ( Header blk)
- | OutdatedTentativeHeader ( Header blk)
-
data
TraceValidationEvent
blk
- = InvalidBlock ( ExtValidationError blk) ( RealPoint blk)
- | ValidCandidate ( AnchoredFragment ( Header blk))
- | CandidateContainsFutureBlocks ( AnchoredFragment ( Header blk)) [ Header blk]
- | CandidateContainsFutureBlocksExceedingClockSkew ( AnchoredFragment ( Header blk)) [ Header blk]
- | UpdateLedgerDbTraceEvent ( UpdateLedgerDbTraceEvent blk)
- newtype RelativeMountPoint = RelativeMountPoint FilePath
- type ImmutableDbSerialiseConstraints blk = ( EncodeDisk blk blk, DecodeDisk blk ( ByteString -> blk), DecodeDiskDep ( NestedCtxt Header ) blk, ReconstructNestedCtxt Header blk, HasBinaryBlockInfo 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)))
- type VolatileDbSerialiseConstraints blk = ( EncodeDisk blk blk, DecodeDisk blk ( ByteString -> blk), DecodeDiskDep ( NestedCtxt Header ) blk, HasNestedContent Header blk, HasBinaryBlockInfo blk)
-
data
Internal
m blk =
Internal
{
- intCopyToImmutableDB :: m ( WithOrigin SlotNo )
- intGarbageCollect :: SlotNo -> m ()
- intUpdateLedgerSnapshots :: m ()
- intAddBlockRunner :: m Void
- intKillBgThreads :: StrictTVar m (m ())
- openDBInternal :: forall m blk. ( IOLike m, LedgerSupportsProtocol blk, InspectLedger blk, HasHardForkHistory blk, ConvertRawHash blk, SerialiseDiskConstraints blk) => ChainDbArgs Identity m blk -> Bool -> m ( ChainDB m blk, Internal m blk)
Initialization
data ChainDbArgs f m blk Source #
Constructors
ChainDbArgs | |
Fields
|
class ( ImmutableDbSerialiseConstraints blk, LgrDbSerialiseConstraints blk, VolatileDbSerialiseConstraints blk, EncodeDiskDep ( NestedCtxt Header ) blk) => SerialiseDiskConstraints blk Source #
All the serialisation related constraints needed by the ChainDB.
Instances
defaultArgs :: forall m blk. Monad m => ( RelativeMountPoint -> SomeHasFS m) -> DiskPolicy -> ChainDbArgs Defaults m blk Source #
Default arguments
See
defaultArgs
,
defaultArgs
,
defaultArgs
,
and
defaultSpecificArgs
for a list of which fields are not given a default
and must therefore be set explicitly.
openDB :: forall m blk. ( IOLike m, LedgerSupportsProtocol blk, InspectLedger blk, HasHardForkHistory blk, ConvertRawHash blk, SerialiseDiskConstraints blk) => ChainDbArgs Identity m blk -> m ( ChainDB m blk) Source #
withDB :: forall m blk a. ( IOLike m, LedgerSupportsProtocol blk, InspectLedger blk, HasHardForkHistory blk, ConvertRawHash blk, SerialiseDiskConstraints blk) => ChainDbArgs Identity m blk -> ( ChainDB m blk -> m a) -> m a Source #
Trace types
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.
Instances
data NewTipInfo blk Source #
Information about the new tip of the current chain.
NOTE: the fields of this record are intentionally lazy to prevent the forcing of this information in case it doesn't have to be traced. However, this means that the tracer processing this message must not hold on to it, otherwise it leaks memory.
Constructors
NewTipInfo | |
Fields
|
Instances
data TraceAddBlockEvent blk Source #
Trace type for the various events that occur when adding a block.
Constructors
IgnoreBlockOlderThanK ( RealPoint blk) |
A block with a
|
IgnoreBlockAlreadyInVolatileDB ( RealPoint blk) |
A block that is already in the Volatile DB was ignored. |
IgnoreInvalidBlock ( RealPoint blk) ( InvalidBlockReason blk) |
A block that is know to be invalid was ignored. |
AddedBlockToQueue ( RealPoint blk) ( Enclosing' Word ) |
The block was added to the queue and will be added to the ChainDB by the background thread. The size of the queue is included. |
PoppedBlockFromQueue ( Enclosing' ( RealPoint blk)) |
The block popped from the queue and will imminently be added to the ChainDB. |
BlockInTheFuture ( RealPoint blk) SlotNo |
The block is from the future, i.e., its slot number is greater than the current slot (the second argument). |
AddedBlockToVolatileDB ( RealPoint blk) BlockNo IsEBB Enclosing |
A block was added to the Volatile DB |
TryAddToCurrentChain ( RealPoint blk) |
The block fits onto the current chain, we'll try to use it to extend our chain. |
TrySwitchToAFork ( RealPoint blk) ( ChainDiff ( HeaderFields blk)) |
The block fits onto some fork, we'll try to switch to that fork (if it is preferable to our chain). |
StoreButDontChange ( RealPoint blk) |
The block doesn't fit onto any other block, so we store it and ignore it. |
AddedToCurrentChain [ LedgerEvent blk] ( NewTipInfo blk) ( AnchoredFragment ( Header blk)) ( AnchoredFragment ( Header blk)) |
The new block fits onto the current chain (first fragment) and we have successfully used it to extend our (new) current chain (second fragment). |
SwitchedToAFork [ LedgerEvent blk] ( NewTipInfo blk) ( AnchoredFragment ( Header blk)) ( AnchoredFragment ( Header blk)) |
The new block fits onto some fork and we have switched to that fork (second fragment), as it is preferable to our (previous) current chain (first fragment). |
AddBlockValidation ( TraceValidationEvent blk) |
An event traced during validating performed while adding a block. |
ChainSelectionForFutureBlock ( RealPoint blk) |
Run chain selection for a block that was previously from the future. This is done for all blocks from the future each time a new block is added. |
PipeliningEvent ( TracePipeliningEvent blk) |
The tentative header (in the context of diffusion pipelining) has been updated. |
ChangingSelection ( Point blk) |
Herald of
|
Instances
data TraceCopyToImmutableDBEvent blk Source #
Constructors
CopiedBlockToImmutableDB ( Point blk) |
A block was successfully copied to the ImmutableDB. |
NoBlocksToCopyToImmutableDB |
There are no block to copy to the ImmutableDB. |
Instances
data TraceEvent blk Source #
Trace type for the various events of the ChainDB.
Constructors
TraceAddBlockEvent ( TraceAddBlockEvent blk) | |
TraceFollowerEvent ( TraceFollowerEvent blk) | |
TraceCopyToImmutableDBEvent ( TraceCopyToImmutableDBEvent blk) | |
TraceGCEvent ( TraceGCEvent blk) | |
TraceInitChainSelEvent ( TraceInitChainSelEvent blk) | |
TraceOpenEvent ( TraceOpenEvent blk) | |
TraceIteratorEvent ( TraceIteratorEvent blk) | |
TraceLedgerEvent ( TraceEvent blk) | |
TraceLedgerReplayEvent ( TraceReplayEvent blk) | |
TraceImmutableDBEvent ( TraceEvent blk) | |
TraceVolatileDBEvent ( TraceEvent blk) |
Instances
data TraceFollowerEvent blk Source #
Constructors
NewFollower |
A new follower was created. |
FollowerNoLongerInMem ( FollowerRollState blk) |
The follower was in the
|
FollowerSwitchToMem |
The follower was in the
|
Fields
|
|
FollowerNewImmIterator |
The follower is in the
|
Fields
|
Instances
data TraceGCEvent blk Source #
Constructors
ScheduledGC SlotNo Time |
A garbage collection for the given
|
PerformedGC SlotNo |
A garbage collection for the given
|
Instances
data TraceInitChainSelEvent blk Source #
Constructors
StartedInitChainSelection |
An event traced when inital chain selection has started during the initialization of ChainDB |
InitalChainSelected |
An event traced when inital chain has been selected |
InitChainSelValidation ( TraceValidationEvent blk) |
An event traced during validation performed while performing initial chain selection. |
Instances
data TraceIteratorEvent blk Source #
Constructors
UnknownRangeRequested ( UnknownRange blk) |
An unknown range was requested, see
|
StreamFromVolatileDB ( StreamFrom blk) ( StreamTo blk) [ RealPoint blk] |
Stream only from the VolatileDB. |
StreamFromImmutableDB ( StreamFrom blk) ( StreamTo blk) |
Stream only from the ImmutableDB. |
StreamFromBoth ( StreamFrom blk) ( StreamTo blk) [ RealPoint blk] |
Stream from both the VolatileDB and the ImmutableDB. |
BlockMissingFromVolatileDB ( RealPoint blk) |
A block is no longer in the VolatileDB because it has been garbage collected. It might now be in the ImmutableDB if it was part of the current chain. |
BlockWasCopiedToImmutableDB ( RealPoint blk) |
A block that has been garbage collected from the VolatileDB is now found and streamed from the ImmutableDB. |
BlockGCedFromVolatileDB ( RealPoint blk) |
A block is no longer in the VolatileDB and isn't in the ImmutableDB either; it wasn't part of the current chain. |
SwitchBackToVolatileDB |
We have streamed one or more blocks from the ImmutableDB that were part of the VolatileDB when initialising the iterator. Now, we have to look back in the VolatileDB again because the ImmutableDB doesn't have the next block we're looking for. |
Instances
data TraceOpenEvent blk Source #
Constructors
StartedOpeningDB |
The ChainDB started the process of opening. |
OpenedDB |
The ChainDB was opened. |
ClosedDB |
The ChainDB was closed. |
StartedOpeningImmutableDB |
The ImmutableDB started the process of opening. |
OpenedImmutableDB |
The ImmutableDB was opened. |
StartedOpeningVolatileDB |
The VolatileDB started opening. |
OpenedVolatileDB |
The VolatileDB was opened. |
StartedOpeningLgrDB |
The LedgerDB started opening. |
OpenedLgrDB |
The LedgerDB was opened. |
Instances
data TracePipeliningEvent blk Source #
Constructors
SetTentativeHeader ( Header blk) Enclosing |
A new tentative header got set. |
TrapTentativeHeader ( Header blk) |
The body of tentative block turned out to be invalid. |
OutdatedTentativeHeader ( Header blk) |
We selected a new (better) chain, which cleared the previous tentative header. |
Instances
Eq ( Header blk) => Eq ( TracePipeliningEvent blk) Source # | |
Defined in Ouroboros.Consensus.Storage.ChainDB.Impl.Types Methods (==) :: TracePipeliningEvent blk -> TracePipeliningEvent blk -> Bool Source # (/=) :: TracePipeliningEvent blk -> TracePipeliningEvent blk -> Bool Source # |
|
Show ( Header blk) => Show ( TracePipeliningEvent blk) Source # | |
|
data TraceValidationEvent blk Source #
Constructors
InvalidBlock ( ExtValidationError blk) ( RealPoint blk) |
A point was found to be invalid. |
ValidCandidate ( AnchoredFragment ( Header blk)) |
A candidate chain was valid. |
CandidateContainsFutureBlocks |
Candidate contains headers from the future which do no exceed the clock skew. |
Fields
|
|
CandidateContainsFutureBlocksExceedingClockSkew |
Candidate contains headers from the future which exceed the clock skew, making them invalid. |
Fields
|
|
UpdateLedgerDbTraceEvent ( UpdateLedgerDbTraceEvent blk) |
Instances
Re-exported for convenience
newtype RelativeMountPoint Source #
A relative path for a
MountPoint
The root is determined by context.
Constructors
RelativeMountPoint FilePath |
type ImmutableDbSerialiseConstraints blk = ( EncodeDisk blk blk, DecodeDisk blk ( ByteString -> blk), DecodeDiskDep ( NestedCtxt Header ) blk, ReconstructNestedCtxt Header blk, HasBinaryBlockInfo blk) Source #
EncodeDisk
and
DecodeDisk
constraints needed for the ImmutableDB.
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.
type VolatileDbSerialiseConstraints blk = ( EncodeDisk blk blk, DecodeDisk blk ( ByteString -> blk), DecodeDiskDep ( NestedCtxt Header ) blk, HasNestedContent Header blk, HasBinaryBlockInfo blk) Source #
EncodeDisk
and
DecodeDisk
constraints needed for the VolatileDB.
Internals for testing purposes
Constructors
Internal | |
Fields
|
Arguments
:: forall m blk. ( IOLike m, LedgerSupportsProtocol blk, InspectLedger blk, HasHardForkHistory blk, ConvertRawHash blk, SerialiseDiskConstraints blk) | |
=> ChainDbArgs Identity m blk | |
-> Bool |
|
-> m ( ChainDB m blk, Internal m blk) |