ouroboros-consensus-0.1.0.1: Consensus layer for the Ouroboros blockchain protocol
Safe Haskell None
Language Haskell2010

Ouroboros.Consensus.Storage.ImmutableDB.Chunks.Internal

Synopsis

Documentation

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

chunkInfoSupportsEBBs :: ChunkInfo -> Bool 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 .

simpleChunkInfo :: EpochSize -> ChunkInfo 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.

Chunk number

newtype ChunkNo Source #

Chunk number

Constructors

ChunkNo

Instances

Instances details
Eq ChunkNo Source #
Instance details

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

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

NoThunks ChunkNo Source #
Instance details

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

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.1-DT4Cvwf63DZKctsEvaJqCU" ' True ) ( C1 (' MetaCons "ChunkNo" ' PrefixI ' True ) ( S1 (' MetaSel (' Just "unChunkNo") ' NoSourceUnpackedness ' NoSourceStrictness ' DecidedLazy ) ( Rec0 Word64 )))

chunkNoToInt :: ChunkNo -> Int Source #

Convert ChunkNo to Int

This is primarily useful for the immutable DB, which uses an IntPSQ .

chunksBetween :: ChunkNo -> ChunkNo -> [ ChunkNo ] Source #

Enumerate all chunks

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

countChunks :: ChunkNo -> ChunkNo -> Word64 Source #

Count number of chunks between two indices

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

unsafeChunkNoToEpochNo :: ChunkNo -> EpochNo Source #

Translate ChunkNo to EpochNo

This should ONLY be used for chunks that contain EBBs. See unsafeEpochNoToChunkNo and ChunkInfo for details.

unsafeEpochNoToChunkNo :: EpochNo -> ChunkNo Source #

Translate EpochNo to ChunkNo

This should ONLY be used to translate the EpochNo of an EBB, since the invariant says EBBs can only exist in the first period of the DB, where the chunk size must equal the epoch size. See ChunkInfo for details.

Chunk size

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

Layout

data RelativeSlot Source #

A relative slot within a chunk

Constructors

RelativeSlot

Fields

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

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.1.0.1-DT4Cvwf63DZKctsEvaJqCU" ' 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 ))))

compareRelativeSlot :: HasCallStack => RelativeSlot -> RelativeSlot -> Ordering 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.

maxRelativeIndex :: ChunkSize -> Word64 Source #

Maximum relative index within a chunk

Assertions