ouroboros-consensus-0.18.0.0: Consensus layer for the Ouroboros blockchain protocol
Safe HaskellSafe-Inferred
LanguageHaskell2010

Ouroboros.Consensus.Storage.ImmutableDB.Chunks.Layout

Description

Layout of individual chunks on disk

This module is not re-exported from the public Chunks API, since it's only relevant internally in the immutable DB. This module makes the layout decisions.

Synopsis

Relative slots

data NextRelativeSlot Source #

Constructors

NextRelativeSlot RelativeSlot

There is a next negative slot

NoMoreRelativeSlots

We reached the end of the chunk

firstBlockOrEBBChunkInfoChunkNoRelativeSlot Source #

The first relative slot

NOTE: This refers to an EBB only if the ChunkSize supports it.

maxRelativeSlotChunkInfoChunkNoRelativeSlot Source #

The last relative slot within a chunk of the given size

nthBlockOrEBB ∷ (HasCallStack, Integral a) ⇒ ChunkInfoChunkNo → a → RelativeSlot Source #

The n'th relative slot for an arbitrary block

NOTE: Offset 0 refers to an EBB only if the ChunkSize supports it.

relativeSlotIsEBBRelativeSlotIsEBB Source #

Is this relative slot reserved for an EBB?

unsafeNextRelativeSlotHasCallStackRelativeSlotRelativeSlot Source #

Variation on nextRelativeSlot where the caller knows that there must be a next slot

Throws an assertion failure (if assertions are enabled) if there is no next slot.

Opaque

data RelativeSlot Source #

A relative slot within a chunk

Instances

Instances details
Generic RelativeSlot Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.ImmutableDB.Chunks.Internal

Associated Types

type Rep RelativeSlotTypeType #

Show RelativeSlot Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.ImmutableDB.Chunks.Internal

Eq RelativeSlot Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.ImmutableDB.Chunks.Internal

NoThunks RelativeSlot Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.ImmutableDB.Chunks.Internal

type Rep RelativeSlot Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.ImmutableDB.Chunks.Internal

type Rep RelativeSlot = D1 ('MetaData "RelativeSlot" "Ouroboros.Consensus.Storage.ImmutableDB.Chunks.Internal" "ouroboros-consensus-0.18.0.0-inplace" 'False) (C1 ('MetaCons "RelativeSlot" 'PrefixI 'True) (S1 ('MetaSel ('Just "relativeSlotChunkNo") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 ChunkNo) :*: (S1 ('MetaSel ('Just "relativeSlotChunkSize") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 ChunkSize) :*: S1 ('MetaSel ('Just "relativeSlotIndex") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Word64))))

Chunks

Slots within a chunk

data ChunkSlot Source #

Uniquely identify a block within the immutable DB

Constructor marked as Unsafe; construction should normally happen inside this module only (though see the ChunkSlot pattern synonym).

Instances

Instances details
Generic ChunkSlot Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.ImmutableDB.Chunks.Layout

Associated Types

type Rep ChunkSlotTypeType #

Methods

fromChunkSlotRep ChunkSlot x #

toRep ChunkSlot x → ChunkSlot #

Show ChunkSlot Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.ImmutableDB.Chunks.Layout

Methods

showsPrecIntChunkSlotShowS #

showChunkSlotString #

showList ∷ [ChunkSlot] → ShowS #

Eq ChunkSlot Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.ImmutableDB.Chunks.Layout

Methods

(==)ChunkSlotChunkSlotBool #

(/=)ChunkSlotChunkSlotBool #

Ord ChunkSlot Source #

We provide a manual Ord instance because RelativeSlot does not (and cannot) define one. By comparing the chunkIndex before the index here, we establish the precondition to compareRelativeSlot.

Instance details

Defined in Ouroboros.Consensus.Storage.ImmutableDB.Chunks.Layout

NoThunks ChunkSlot Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.ImmutableDB.Chunks.Layout

type Rep ChunkSlot Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.ImmutableDB.Chunks.Layout

type Rep ChunkSlot = D1 ('MetaData "ChunkSlot" "Ouroboros.Consensus.Storage.ImmutableDB.Chunks.Layout" "ouroboros-consensus-0.18.0.0-inplace" 'False) (C1 ('MetaCons "UnsafeChunkSlot" 'PrefixI 'True) (S1 ('MetaSel ('Just "chunkIndex") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 ChunkNo) :*: S1 ('MetaSel ('Just "chunkRelative") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 RelativeSlot)))

Translation to ChunkSlot

chunkSlotForRegularBlockChunkInfoSlotNoChunkSlot Source #

Chunk slot for a regular block (i.e., not an EBB)

chunkSlotForTipChunkInfoTip blk → ChunkSlot Source #

Chunk slot for Tip

chunkSlotForUnknownBlockHasCallStackChunkInfoSlotNo → (ChunkNo, Maybe ChunkSlot, ChunkSlot) Source #

Chunk slot for an unknown block

This returns two ChunkSlots: one in case the block could be an EBB, and one in case the block is a regular block. In addition, it also returns the ChunkNo that both of these ChunkSlots must necessarily share.

Translation from ChunkSlot

chunkSlotToSlotChunkInfoChunkSlotSlotNo Source #

From relative to absolute slot

This can be used for EBBs and regular blocks, since they don't share a relative slot.

Support for EBBs