Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- data ChunkInfo = UniformChunkSize ! ChunkSize
- chunkInfoSupportsEBBs :: ChunkInfo -> Bool
- simpleChunkInfo :: EpochSize -> ChunkInfo
- singleChunkInfo :: ChunkSize -> ChunkInfo
- newtype ChunkNo = ChunkNo { }
- chunkNoFromInt :: Int -> ChunkNo
- chunkNoToInt :: ChunkNo -> Int
- chunksBetween :: ChunkNo -> ChunkNo -> [ ChunkNo ]
- countChunks :: ChunkNo -> ChunkNo -> Word64
- firstChunkNo :: ChunkNo
- nextChunkNo :: ChunkNo -> ChunkNo
- prevChunkNo :: ChunkNo -> Maybe ChunkNo
- unsafeChunkNoToEpochNo :: ChunkNo -> EpochNo
- unsafeEpochNoToChunkNo :: EpochNo -> ChunkNo
-
data
ChunkSize
=
ChunkSize
{
- chunkCanContainEBB :: ! Bool
- numRegularBlocks :: ! Word64
- getChunkSize :: ChunkInfo -> ChunkNo -> ChunkSize
-
data
RelativeSlot
=
RelativeSlot
{
- relativeSlotChunkNo :: ! ChunkNo
- relativeSlotChunkSize :: ! ChunkSize
- relativeSlotIndex :: ! Word64
- assertRelativeSlotInChunk :: HasCallStack => ChunkNo -> RelativeSlot -> Word64
- compareRelativeSlot :: HasCallStack => RelativeSlot -> RelativeSlot -> Ordering
- maxRelativeIndex :: ChunkSize -> Word64
- mkRelativeSlot :: HasCallStack => ChunkInfo -> ChunkNo -> Word64 -> RelativeSlot
- data ChunkAssertionFailure
- assertChunkCanContainEBB :: HasCallStack => ChunkNo -> ChunkSize -> a -> a
- assertSameChunk :: HasCallStack => ChunkNo -> ChunkNo -> a -> a
- assertWithinBounds :: HasCallStack => Word64 -> ChunkSize -> a -> a
Documentation
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
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
Show ChunkInfo Source # | |
Generic ChunkInfo Source # | |
NoThunks ChunkInfo Source # | |
type Rep ChunkInfo Source # | |
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.1-DT4Cvwf63DZKctsEvaJqCU" '
False
) (
C1
('
MetaCons
"UniformChunkSize" '
PrefixI
'
False
) (
S1
('
MetaSel
('
Nothing
::
Maybe
Symbol
) '
NoSourceUnpackedness
'
SourceStrict
'
DecidedStrict
) (
Rec0
ChunkSize
)))
|
simpleChunkInfo :: EpochSize -> ChunkInfo Source #
singleChunkInfo :: ChunkSize -> ChunkInfo Source #
ChunkInfo
for a single
ChunkSize
See also
simpleChunkInfo
.
Chunk number
Chunk number
Instances
Eq ChunkNo Source # | |
Ord ChunkNo Source # | |
Defined in Ouroboros.Consensus.Storage.ImmutableDB.Chunks.Internal |
|
Show ChunkNo Source # | |
Generic ChunkNo Source # | |
NoThunks ChunkNo Source # | |
type Rep ChunkNo Source # | |
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
)))
|
chunkNoFromInt :: Int -> ChunkNo Source #
See
chunkNoToInt
for motivation.
chunkNoToInt :: ChunkNo -> Int Source #
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
firstChunkNo :: ChunkNo Source #
First chunk
nextChunkNo :: ChunkNo -> ChunkNo Source #
unsafeChunkNoToEpochNo :: ChunkNo -> EpochNo Source #
This should
ONLY
be used for chunks that contain EBBs.
See
unsafeEpochNoToChunkNo
and
ChunkInfo
for details.
Chunk size
Size of a chunk
The total number of slots available in a chunk is equal to
numRegularBlocks
if
not
chunkCanContainEBB
, and
numRegularBlocks
+ 1
otherwise.
ChunkSize | |
|
Instances
Show ChunkSize Source # | |
Generic ChunkSize Source # | |
NoThunks ChunkSize Source # | |
type Rep ChunkSize Source # | |
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.1-DT4Cvwf63DZKctsEvaJqCU" '
False
) (
C1
('
MetaCons
"ChunkSize" '
PrefixI
'
True
) (
S1
('
MetaSel
('
Just
"chunkCanContainEBB") '
NoSourceUnpackedness
'
SourceStrict
'
DecidedStrict
) (
Rec0
Bool
)
:*:
S1
('
MetaSel
('
Just
"numRegularBlocks") '
NoSourceUnpackedness
'
SourceStrict
'
DecidedStrict
) (
Rec0
Word64
)))
|
Layout
data RelativeSlot Source #
A relative slot within a chunk
RelativeSlot | |
|
Instances
assertRelativeSlotInChunk :: HasCallStack => ChunkNo -> RelativeSlot -> Word64 Source #
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
mkRelativeSlot :: HasCallStack => ChunkInfo -> ChunkNo -> Word64 -> RelativeSlot Source #
Smart constructor for
RelativeSlot
Assertions
data ChunkAssertionFailure Source #
assertChunkCanContainEBB :: HasCallStack => ChunkNo -> ChunkSize -> a -> a Source #
assertSameChunk :: HasCallStack => ChunkNo -> ChunkNo -> a -> a Source #
assertWithinBounds :: HasCallStack => Word64 -> ChunkSize -> a -> a Source #