| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Ouroboros.Consensus.Byron.Ledger.Serialisation
Synopsis
- data family NestedCtxt_ blk :: (Type -> Type) -> Type -> Type
- type RawHeader = AHeader ByteString
- type RawBoundaryHeader = ABoundaryHeader ByteString
- byronBlockEncodingOverhead :: Word32
- encodeByronBlock :: ByronBlock -> Encoding
- decodeByronBlock :: EpochSlots -> Decoder s (ByteString -> ByronBlock)
- decodeByronRegularBlock :: EpochSlots -> Decoder s (ByteString -> ByronBlock)
- decodeByronBoundaryBlock :: EpochSlots -> Decoder s (ByteString -> ByronBlock)
- encodeByronRegularHeader :: RawHeader -> Encoding
- decodeByronRegularHeader :: EpochSlots -> Decoder s (ByteString -> RawHeader)
- encodeByronBoundaryHeader :: RawBoundaryHeader -> Encoding
- decodeByronBoundaryHeader :: Decoder s (ByteString -> RawBoundaryHeader)
- encodeByronHeaderHash :: HeaderHash ByronBlock -> Encoding
- decodeByronHeaderHash :: Decoder s (HeaderHash ByronBlock)
- byronBinaryBlockInfo :: ByronBlock -> BinaryBlockInfo
- addV1Envelope :: (SomeSecond (NestedCtxt Header) ByronBlock, ByteString) -> ByteString
- dropV1Envelope :: ByteString -> Except String (SomeSecond (NestedCtxt Header) ByronBlock, ByteString)
- fakeByronBlockSizeHint :: SizeInBytes
- encodeUnsizedHeader :: UnsizedHeader -> Encoding
- decodeUnsizedHeader :: EpochSlots -> Decoder s (ByteString -> UnsizedHeader)
Data family instances
data family NestedCtxt_ blk :: (Type -> Type) -> Type -> Type Source #
Context identifying what kind of block we have
In almost all places we will use NestedCtxt rather than NestedCtxt_.
Instances
| SameDepIndex (NestedCtxt_ ByronBlock f) Source # | |
Defined in Ouroboros.Consensus.Byron.Ledger.Serialisation Methods sameDepIndex :: NestedCtxt_ ByronBlock f a -> NestedCtxt_ ByronBlock f b -> Maybe (a :~: b) Source # | |
| Show (NestedCtxt_ ByronBlock f a) Source # | |
Defined in Ouroboros.Consensus.Byron.Ledger.Serialisation Methods showsPrec :: Int -> NestedCtxt_ ByronBlock f a -> ShowS # show :: NestedCtxt_ ByronBlock f a -> String # showList :: [NestedCtxt_ ByronBlock f a] -> ShowS # | |
| data NestedCtxt_ ByronBlock f a Source # | Since the Byron header does not contain the size, we include it in the nested type instead. |
type RawHeader = AHeader ByteString Source #
Serialisation
byronBlockEncodingOverhead :: Word32 Source #
The Byron block encoding overhead size in bytes.
This encompasses the overhead in bytes for everything that is encoded within a Byron block, excluding the actual generalized transactions (transactions, delegation certificates, update votes, and update proposals).
encodeByronBlock :: ByronBlock -> Encoding Source #
Encode a block
Should be backwards compatible with legacy (cardano-sl) nodes.
Implementation note: the decoder uses fromCBORABlockOrBoundary, which
has inverse toCBORABlockOrBoundary. This encoder is intended to be
binary compatible with toCBORABlockOrBoundary, but does not use it and
instead takes advantage of the annotations (using encodePreEncoded).
decodeByronBlock :: EpochSlots -> Decoder s (ByteString -> ByronBlock) Source #
Inverse of encodeByronBlock
decodeByronRegularBlock :: EpochSlots -> Decoder s (ByteString -> ByronBlock) Source #
Decoder for a regular (non-EBB) Byron block.
PRECONDITION: the ByteString given as argument to the decoder is the
same as the one that is decoded.
This is a wrapper for fromCBORABlock.
Use decodeByronBlock when you can, this function is provided for use by
the hard-fork combinator.
decodeByronBoundaryBlock :: EpochSlots -> Decoder s (ByteString -> ByronBlock) Source #
Decoder for a boundary Byron block.
PRECONDITION: the ByteString given as argument to the decoder is the
same as the one that is decoded.
This is a wrapper for fromCBORABoundaryBlock.
Use decodeByronBlock when you can, this function is provided for use by
the hard-fork combinator.
encodeByronRegularHeader :: RawHeader -> Encoding Source #
Encodes a raw Byron header without a tag indicating whether it's a regular header or an EBB header.
Uses the annotation, so cheap.
decodeByronRegularHeader :: EpochSlots -> Decoder s (ByteString -> RawHeader) Source #
Inverse of encodeByronRegularHeader
encodeByronBoundaryHeader :: RawBoundaryHeader -> Encoding Source #
Encodes a raw Byron EBB header without a tag indicating whether it's a regular header or an EBB header.
Uses the annotation, so cheap.
decodeByronBoundaryHeader :: Decoder s (ByteString -> RawBoundaryHeader) Source #
Inverse of encodeByronBoundaryHeader
Support for on-disk format
byronBinaryBlockInfo :: ByronBlock -> BinaryBlockInfo Source #
The BinaryBlockInfo of the given ByronBlock.
NOTE: the bytestring obtained by slicing the serialised block using the
header offset and size will correspond to the header annotation, but not
to the serialised header, as we add an envelope (encodeListLen + tag)
around a header in encodeByronHeader. This envelope must thus still be
added to the sliced bytestring before it can be deserialised using
decodeByronHeader.
Unsized header
addV1Envelope :: (SomeSecond (NestedCtxt Header) ByronBlock, ByteString) -> ByteString Source #
dropV1Envelope :: ByteString -> Except String (SomeSecond (NestedCtxt Header) ByronBlock, ByteString) Source #
Drop the V1 EBB-or-regular-header envelope and reconstruct the context.
Since we don't know the block size, use fakeByronBlockSizeHint.
fakeByronBlockSizeHint :: SizeInBytes Source #
Fake size (used in compatibility mode)
encodeUnsizedHeader :: UnsizedHeader -> Encoding Source #
Encode an unsized header
Does not have to backwards compatible with legacy (cardano-sl) nodes
(which never send or store these headers), but should be inverse to
decodeSizedHeader, and moreover uses fromCBORABlockOrBoundaryHdr from
cardano-ledger, and so we don't have too much choice in this encoder.
decodeUnsizedHeader :: EpochSlots -> Decoder s (ByteString -> UnsizedHeader) Source #
Inverse of encodeSizedHeader
Orphan instances
| Serialise ByronHash Source # | |
| HasNestedContent Header ByronBlock Source # | |
Methods unnest :: Header ByronBlock -> DepPair (NestedCtxt Header ByronBlock) Source # nest :: DepPair (NestedCtxt Header ByronBlock) -> Header ByronBlock Source # | |
| SameDepIndex (NestedCtxt_ ByronBlock f) Source # | |
Methods sameDepIndex :: NestedCtxt_ ByronBlock f a -> NestedCtxt_ ByronBlock f b -> Maybe (a :~: b) Source # | |
| Show (NestedCtxt_ ByronBlock f a) Source # | |
Methods showsPrec :: Int -> NestedCtxt_ ByronBlock f a -> ShowS # show :: NestedCtxt_ ByronBlock f a -> String # showList :: [NestedCtxt_ ByronBlock f a] -> ShowS # | |