Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- data RelativeSlot
- data ChunkNo
-
data
ChunkSize
=
ChunkSize
{
- chunkCanContainEBB :: ! Bool
- numRegularBlocks :: ! Word64
- data ChunkInfo = UniformChunkSize ! ChunkSize
- simpleChunkInfo :: EpochSize -> ChunkInfo
- singleChunkInfo :: ChunkSize -> ChunkInfo
- chunkInfoSupportsEBBs :: ChunkInfo -> Bool
- firstChunkNo :: ChunkNo
- nextChunkNo :: ChunkNo -> ChunkNo
- prevChunkNo :: ChunkNo -> Maybe ChunkNo
- countChunks :: ChunkNo -> ChunkNo -> Word64
- chunksBetween :: ChunkNo -> ChunkNo -> [ ChunkNo ]
- getChunkSize :: ChunkInfo -> ChunkNo -> ChunkSize
- mkRelativeSlot :: HasCallStack => ChunkInfo -> ChunkNo -> Word64 -> RelativeSlot
- compareRelativeSlot :: HasCallStack => RelativeSlot -> RelativeSlot -> Ordering
-
data
ChunkSlot
=
UnsafeChunkSlot
{
- chunkIndex :: ! ChunkNo
- chunkRelative :: ! RelativeSlot
- data NextRelativeSlot
- pattern ChunkSlot :: ChunkNo -> RelativeSlot -> ChunkSlot
- maxRelativeSlot :: ChunkInfo -> ChunkNo -> RelativeSlot
- relativeSlotIsEBB :: RelativeSlot -> IsEBB
- nthBlockOrEBB :: ( HasCallStack , Integral a) => ChunkInfo -> ChunkNo -> a -> RelativeSlot
- firstBlockOrEBB :: ChunkInfo -> ChunkNo -> RelativeSlot
- nextRelativeSlot :: HasCallStack => RelativeSlot -> NextRelativeSlot
- unsafeNextRelativeSlot :: HasCallStack => RelativeSlot -> RelativeSlot
- chunkIndexOfSlot :: ChunkInfo -> SlotNo -> ChunkNo
- chunkSlotForUnknownBlock :: HasCallStack => ChunkInfo -> SlotNo -> ( ChunkNo , Maybe ChunkSlot , ChunkSlot )
- chunkSlotForRegularBlock :: ChunkInfo -> SlotNo -> ChunkSlot
- chunkSlotForBoundaryBlock :: HasCallStack => ChunkInfo -> EpochNo -> ChunkSlot
- chunkSlotForBlockOrEBB :: ChunkInfo -> BlockOrEBB -> ChunkSlot
- chunkSlotForTip :: ChunkInfo -> Tip blk -> ChunkSlot
- chunkSlotForRelativeSlot :: ChunkNo -> RelativeSlot -> ChunkSlot
- chunkSlotToSlot :: ChunkInfo -> ChunkSlot -> SlotNo
- chunkSlotToBlockOrEBB :: ChunkInfo -> ChunkSlot -> BlockOrEBB
- slotNoOfEBB :: HasCallStack => ChunkInfo -> EpochNo -> SlotNo
- slotMightBeEBB :: ChunkInfo -> SlotNo -> Maybe EpochNo
- slotNoOfBlockOrEBB :: ChunkInfo -> BlockOrEBB -> SlotNo
Documentation
data RelativeSlot Source #
A relative slot within a chunk
Instances
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
)))
|
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
)))
|
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
.
firstChunkNo :: ChunkNo Source #
First chunk
nextChunkNo :: ChunkNo -> ChunkNo Source #
countChunks :: ChunkNo -> ChunkNo -> Word64 Source #
Count number of chunks between two indices
countChunks x x == 0 countChunks x (nextChunkNo x) == 1
chunksBetween :: ChunkNo -> ChunkNo -> [ ChunkNo ] Source #
Enumerate all chunks
chunksBetween x x == [x] chunksBetween x (nextChunkNo x) == [x, nextChunkNo x]
mkRelativeSlot :: HasCallStack => ChunkInfo -> ChunkNo -> Word64 -> RelativeSlot Source #
Smart constructor for
RelativeSlot
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.
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
Eq ChunkSlot Source # | |
Ord ChunkSlot Source # |
We provide a manual
|
Defined in Ouroboros.Consensus.Storage.ImmutableDB.Chunks.Layout |
|
Show ChunkSlot Source # | |
Generic ChunkSlot Source # | |
NoThunks ChunkSlot Source # | |
type Rep ChunkSlot Source # | |
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.1-DT4Cvwf63DZKctsEvaJqCU" '
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 #
Result of
nextRelativeSlot
NextRelativeSlot RelativeSlot |
There is a next negative slot |
NoMoreRelativeSlots |
We reached the end of the chunk |
maxRelativeSlot :: ChunkInfo -> ChunkNo -> RelativeSlot Source #
The last relative slot within a chunk of the given size
relativeSlotIsEBB :: RelativeSlot -> IsEBB Source #
Is this relative slot reserved for an EBB?
nthBlockOrEBB :: ( HasCallStack , Integral a) => ChunkInfo -> ChunkNo -> 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.
firstBlockOrEBB :: ChunkInfo -> ChunkNo -> RelativeSlot Source #
The first relative slot
NOTE: This refers to an EBB only if the
ChunkSize
supports it.
nextRelativeSlot :: HasCallStack => RelativeSlot -> NextRelativeSlot Source #
Next relative slot
unsafeNextRelativeSlot :: HasCallStack => RelativeSlot -> RelativeSlot 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.
chunkSlotForUnknownBlock :: HasCallStack => ChunkInfo -> SlotNo -> ( ChunkNo , Maybe ChunkSlot , ChunkSlot ) Source #
chunkSlotForRegularBlock :: ChunkInfo -> SlotNo -> ChunkSlot Source #
Chunk slot for a regular block (i.e., not an EBB)
chunkSlotForBoundaryBlock :: HasCallStack => ChunkInfo -> EpochNo -> ChunkSlot Source #
Chunk slot for EBB
chunkSlotForBlockOrEBB :: ChunkInfo -> BlockOrEBB -> ChunkSlot Source #
Chunk slot for
BlockOrEBB
chunkSlotToSlot :: ChunkInfo -> ChunkSlot -> SlotNo Source #
From relative to absolute slot
This can be used for EBBs and regular blocks, since they don't share a relative slot.
chunkSlotToBlockOrEBB :: ChunkInfo -> ChunkSlot -> BlockOrEBB Source #
slotNoOfEBB :: HasCallStack => ChunkInfo -> EpochNo -> SlotNo Source #
slotNoOfBlockOrEBB :: ChunkInfo -> BlockOrEBB -> SlotNo Source #