ouroboros-consensus-0.1.0.0: Consensus layer for the Ouroboros blockchain protocol
Safe HaskellNone
LanguageHaskell2010

Ouroboros.Consensus.Storage.ImmutableDB.Chunks

Synopsis

Documentation

data RelativeSlot Source #

A relative slot within a chunk

Instances

Instances details
Eq RelativeSlot Source # 
Instance details

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

Show RelativeSlot Source # 
Instance details

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

Generic RelativeSlot Source # 
Instance details

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

Associated Types

type Rep RelativeSlotTypeType Source #

NoThunks RelativeSlot Source # 
Instance details

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

Methods

noThunks ∷ Context → RelativeSlotIO (Maybe ThunkInfo) #

wNoThunks ∷ Context → RelativeSlotIO (Maybe ThunkInfo) #

showTypeOfProxy RelativeSlotString #

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.1.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))))

data ChunkNo Source #

Chunk number

Instances

Instances details
Eq ChunkNo Source # 
Instance details

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

Methods

(==)ChunkNoChunkNoBool Source #

(/=)ChunkNoChunkNoBool Source #

Ord ChunkNo Source # 
Instance details

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

Show ChunkNo Source # 
Instance details

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

Generic ChunkNo Source # 
Instance details

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

Associated Types

type Rep ChunkNoTypeType Source #

Methods

fromChunkNoRep ChunkNo x Source #

toRep ChunkNo x → ChunkNo Source #

NoThunks ChunkNo Source # 
Instance details

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

Methods

noThunks ∷ Context → ChunkNoIO (Maybe ThunkInfo) #

wNoThunks ∷ Context → ChunkNoIO (Maybe ThunkInfo) #

showTypeOfProxy ChunkNoString #

type Rep ChunkNo Source # 
Instance details

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

type Rep ChunkNo = D1 ('MetaData "ChunkNo" "Ouroboros.Consensus.Storage.ImmutableDB.Chunks.Internal" "ouroboros-consensus-0.1.0.0-inplace" 'True) (C1 ('MetaCons "ChunkNo" 'PrefixI 'True) (S1 ('MetaSel ('Just "unChunkNo") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Word64)))

data ChunkSize Source #

Size of a chunk

The total number of slots available in a chunk is equal to numRegularBlocks if not chunkCanContainEBB, and numRegularBlocks + 1 otherwise.

Constructors

ChunkSize 

Fields

Instances

Instances details
Show ChunkSize Source # 
Instance details

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

Generic ChunkSize Source # 
Instance details

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

Associated Types

type Rep ChunkSizeTypeType Source #

NoThunks ChunkSize Source # 
Instance details

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

Methods

noThunks ∷ Context → ChunkSizeIO (Maybe ThunkInfo) #

wNoThunks ∷ Context → ChunkSizeIO (Maybe ThunkInfo) #

showTypeOfProxy ChunkSizeString #

type Rep ChunkSize Source # 
Instance details

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

type Rep ChunkSize = D1 ('MetaData "ChunkSize" "Ouroboros.Consensus.Storage.ImmutableDB.Chunks.Internal" "ouroboros-consensus-0.1.0.0-inplace" 'False) (C1 ('MetaCons "ChunkSize" 'PrefixI 'True) (S1 ('MetaSel ('Just "chunkCanContainEBB") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Bool) :*: S1 ('MetaSel ('Just "numRegularBlocks") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Word64)))

data ChunkInfo Source #

Size of the chunks of the immutable DB

This is the key data structure that drives all layout functions.

TODO: Add support for non-uniform ChunkInfo https://github.com/input-output-hk/ouroboros-network/issues/1754

Constructors

UniformChunkSize !ChunkSize

A single, uniform, chunk size

If EBBs are present, the chunk size must line up precisely with the epoch size (that is, the number of regular blocks in the chunk must equal the number of regular blocks in an epoch).

Instances

Instances details
Show ChunkInfo Source # 
Instance details

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

Generic ChunkInfo Source # 
Instance details

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

Associated Types

type Rep ChunkInfoTypeType Source #

NoThunks ChunkInfo Source # 
Instance details

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

Methods

noThunks ∷ Context → ChunkInfoIO (Maybe ThunkInfo) #

wNoThunks ∷ Context → ChunkInfoIO (Maybe ThunkInfo) #

showTypeOfProxy ChunkInfoString #

type Rep ChunkInfo Source # 
Instance details

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

type Rep ChunkInfo = D1 ('MetaData "ChunkInfo" "Ouroboros.Consensus.Storage.ImmutableDB.Chunks.Internal" "ouroboros-consensus-0.1.0.0-inplace" 'False) (C1 ('MetaCons "UniformChunkSize" 'PrefixI 'False) (S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 ChunkSize)))

simpleChunkInfoEpochSizeChunkInfo Source #

Simple chunk config with a single chunk size

This intentionally takes EpochSize (number of slots) rather than ChunkSize: the translation from EpochSize to ChunkSize (number of available entries in a chunk) should not be done by client code.

chunkInfoSupportsEBBsChunkInfoBool Source #

Can we store EBBs in the chunks described by this ChunkInfo?

This is only used for tests. This API will need to change (and the tests will become more complicated) once we support non-uniform ChunkInfo.

firstChunkNoChunkNo Source #

First chunk

countChunksChunkNoChunkNoWord64 Source #

Count number of chunks between two indices

countChunks x              x  == 0
countChunks x (nextChunkNo x) == 1

chunksBetweenChunkNoChunkNo → [ChunkNo] Source #

Enumerate all chunks

chunksBetween x              x  == [x]
chunksBetween x (nextChunkNo x) == [x, nextChunkNo x]

compareRelativeSlotHasCallStackRelativeSlotRelativeSlotOrdering Source #

RelativeSlot is partially ordered, not totally ordered

It makes no sense to compare RelativeSlots from different chunks. Doing so will result in an assertion failure.

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
Eq ChunkSlot Source # 
Instance details

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

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

Show ChunkSlot Source # 
Instance details

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

Generic ChunkSlot Source # 
Instance details

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

Associated Types

type Rep ChunkSlotTypeType Source #

NoThunks ChunkSlot Source # 
Instance details

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

Methods

noThunks ∷ Context → ChunkSlotIO (Maybe ThunkInfo) #

wNoThunks ∷ Context → ChunkSlotIO (Maybe ThunkInfo) #

showTypeOfProxy ChunkSlotString #

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.1.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)))

data NextRelativeSlot Source #

Constructors

NextRelativeSlot RelativeSlot

There is a next negative slot

NoMoreRelativeSlots

We reached the end of the chunk

maxRelativeSlotChunkInfoChunkNoRelativeSlot Source #

The last relative slot within a chunk of the given size

relativeSlotIsEBBRelativeSlotIsEBB Source #

Is this relative slot reserved for an EBB?

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.

firstBlockOrEBBChunkInfoChunkNoRelativeSlot Source #

The first relative slot

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

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.

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.

chunkSlotForRegularBlockChunkInfoSlotNoChunkSlot Source #

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

chunkSlotForTipChunkInfoTip blk → ChunkSlot Source #

Chunk slot for Tip

chunkSlotToSlotChunkInfoChunkSlotSlotNo Source #

From relative to absolute slot

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