ouroboros-consensus-byron-0.1.0.0: Byron ledger integration in the Ouroboros consensus layer

Ouroboros.Consensus.Byron.Ledger.Serialisation

Synopsis

# Data family instances

data family NestedCtxt_ blk ∷ (TypeType) → TypeType Source #

Context identifying what kind of block we have

In almost all places we will use NestedCtxt rather than NestedCtxt_.

#### Instances

Instances details
 Source # Instance details Methods Source # Instance details Methods data NestedCtxt_ ByronBlock f a Source # Since the Byron header does not contain the size, we include it in the nested type instead. Instance details

# Serialisation

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

decodeByronBlock ∷ EpochSlots → Decoder s (ByteStringByronBlock) Source #

Inverse of encodeByronBlock

decodeByronBoundaryBlock ∷ EpochSlots → Decoder s (ByteStringByronBlock) 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.

Inverse of encodeByronBoundaryHeader

decodeByronRegularBlock ∷ EpochSlots → Decoder s (ByteStringByronBlock) 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.

Inverse of encodeByronRegularHeader

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

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.

Encodes a raw Byron header without a tag indicating whether it's a regular header or an EBB header.

Uses the annotation, so cheap.

# Support for on-disk format

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.

Inverse of encodeSizedHeader

Drop the V1 EBB-or-regular-header envelope and reconstruct the context. Since we don't know the block size, use fakeByronBlockSizeHint.

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-byron, and so we don't have too much choice in this encoder.