| 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
- cdbParamsLgrDB :: HKD f LedgerDbParams
- cdbDiskPolicy :: HKD f 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
- defaultArgs :: FilePath -> ChainDbArgs Defaults IO blk
- class (ImmutableDbSerialiseConstraints blk, LgrDbSerialiseConstraints blk, VolatileDbSerialiseConstraints blk, EncodeDiskDep (NestedCtxt Header) blk) => SerialiseDiskConstraints 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
- openDB :: forall m blk. (IOLike m, LedgerSupportsProtocol blk, InspectLedger blk, HasHardForkHistory blk, ConvertRawHash blk, SerialiseDiskConstraints blk) => ChainDbArgs Identity m blk -> m (ChainDB m blk)
- data TraceEvent blk
- = TraceAddBlockEvent (TraceAddBlockEvent blk)
- | TraceReaderEvent (TraceReaderEvent blk)
- | TraceCopyToImmutableDBEvent (TraceCopyToImmutableDBEvent blk)
- | TraceGCEvent (TraceGCEvent blk)
- | TraceInitChainSelEvent (TraceInitChainSelEvent blk)
- | TraceOpenEvent (TraceOpenEvent blk)
- | TraceIteratorEvent (TraceIteratorEvent blk)
- | TraceLedgerEvent (TraceEvent blk)
- | TraceLedgerReplayEvent (TraceLedgerReplayEvent blk)
- | TraceImmutableDBEvent (TraceEvent blk)
- | TraceVolatileDBEvent (TraceEvent 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) Word
- | BlockInTheFuture (RealPoint blk) SlotNo
- | AddedBlockToVolatileDB (RealPoint blk) BlockNo IsEBB
- | 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)
- data TraceReaderEvent blk
- = NewReader
- | ReaderNoLongerInMem (ReaderRollState blk)
- | ReaderSwitchToMem (Point blk) (WithOrigin SlotNo)
- | ReaderNewImmIterator (Point blk) (WithOrigin SlotNo)
- data TraceCopyToImmutableDBEvent blk
- data TraceGCEvent blk
- data TraceValidationEvent blk
- = InvalidBlock (ExtValidationError blk) (RealPoint blk)
- | InvalidCandidate (AnchoredFragment (Header blk))
- | ValidCandidate (AnchoredFragment (Header blk))
- | CandidateContainsFutureBlocks (AnchoredFragment (Header blk)) [Header blk]
- | CandidateContainsFutureBlocksExceedingClockSkew (AnchoredFragment (Header blk)) [Header blk]
- data TraceInitChainSelEvent blk = InitChainSelValidation (TraceValidationEvent blk)
- data TraceOpenEvent blk
- = OpenedDB (Point blk) (Point blk)
- | ClosedDB (Point blk) (Point blk)
- | OpenedImmutableDB (Point blk) ChunkNo
- | OpenedVolatileDB
- | OpenedLgrDB
- 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
- type TraceLedgerReplayEvent blk = TraceReplayEvent blk (Point blk)
- 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)
- 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)
- data Internal m blk = Internal {
- intCopyToImmutableDB :: m (WithOrigin SlotNo)
- intGarbageCollect :: SlotNo -> m ()
- intUpdateLedgerSnapshots :: m ()
- intAddBlockRunner :: m Void
- intKillBgThreads :: StrictTVar m (m ())
Initialization
data ChainDbArgs f m blk Source #
Constructors
| ChainDbArgs | |
Fields
| |
defaultArgs :: FilePath -> ChainDbArgs Defaults IO blk Source #
Default arguments for use within IO
See defaultArgs, defaultArgs, defaultArgs,
and defaultSpecificArgs for a list of which fields are not given a default
and must therefore be set explicitly.
class (ImmutableDbSerialiseConstraints blk, LgrDbSerialiseConstraints blk, VolatileDbSerialiseConstraints blk, EncodeDiskDep (NestedCtxt Header) blk) => SerialiseDiskConstraints blk Source #
All the serialisation related constraints needed by the ChainDB.
Instances
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 #
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 #
Trace types
data TraceEvent blk Source #
Trace type for the various events of the ChainDB.
Constructors
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) 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. |
| 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 | 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. |
Instances
data TraceReaderEvent blk Source #
Constructors
| NewReader | A new reader was created. |
| ReaderNoLongerInMem (ReaderRollState blk) | The reader was in the |
| ReaderSwitchToMem | The reader was in the |
Fields
| |
| ReaderNewImmIterator | The reader is in the |
Fields
| |
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 TraceGCEvent blk Source #
Constructors
| ScheduledGC SlotNo Time | A garbage collection for the given |
| PerformedGC SlotNo | A garbage collection for the given |
Instances
data TraceValidationEvent blk Source #
Constructors
| InvalidBlock (ExtValidationError blk) (RealPoint blk) | A point was found to be invalid. |
| InvalidCandidate (AnchoredFragment (Header blk)) | A candidate chain was invalid. |
| ValidCandidate (AnchoredFragment (Header blk)) | A candidate chain was valid. |
| CandidateContainsFutureBlocks | Candidate contains headers from the future which do no exceed the clock skew. |
| CandidateContainsFutureBlocksExceedingClockSkew | Candidate contains headers from the future which exceed the clock skew, making them invalid. |
Instances
data TraceInitChainSelEvent blk Source #
Constructors
| InitChainSelValidation (TraceValidationEvent blk) | An event traced during validation performed while performing initial chain selection. |
Instances
data TraceOpenEvent blk Source #
Constructors
| OpenedDB | The ChainDB was opened. |
| ClosedDB | The ChainDB was closed. |
| OpenedImmutableDB | The ImmutableDB was opened. |
| OpenedVolatileDB | The VolatileDB was opened. |
| OpenedLgrDB | The LedgerDB was opened. |
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
type TraceLedgerReplayEvent blk = TraceReplayEvent blk (Point blk) Source #
TraceReplayEvent instantiated with additional information.
The replayTo parameter is instantiated with the Point of
the tip of the ImmutableDB.
Re-exported for convenience
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
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) |
Constructors
| Internal | |
Fields
| |