ouroboros-consensus-cardano-0.12.1.0: The instantation of the Ouroboros consensus layer used by Cardano
Safe HaskellSafe-Inferred
LanguageHaskell2010

Ouroboros.Consensus.Byron.Ledger.Serialisation

Synopsis

Data family instances

data family NestedCtxt_ blk :: (Type -> Type) -> Type -> Type #

Instances

Instances details
SameDepIndex (NestedCtxt_ ByronBlock f) 
Instance details

Defined in Ouroboros.Consensus.Byron.Ledger.Serialisation

SameDepIndex (NestedCtxt_ (ShelleyBlock proto era) f) 
Instance details

Defined in Ouroboros.Consensus.Shelley.Ledger.Block

Methods

sameDepIndex :: NestedCtxt_ (ShelleyBlock proto era) f a -> NestedCtxt_ (ShelleyBlock proto era) f b -> Maybe (a :~: b)

TrivialDependency (NestedCtxt_ (ShelleyBlock proto era) f) 
Instance details

Defined in Ouroboros.Consensus.Shelley.Ledger.Block

Associated Types

type TrivialIndex (NestedCtxt_ (ShelleyBlock proto era) f)

Methods

hasSingleIndex :: NestedCtxt_ (ShelleyBlock proto era) f a -> NestedCtxt_ (ShelleyBlock proto era) f b -> a :~: b

indexIsTrivial :: NestedCtxt_ (ShelleyBlock proto era) f (TrivialIndex (NestedCtxt_ (ShelleyBlock proto era) f))

Show (NestedCtxt_ ByronBlock f a) Source # 
Instance details

Defined in Ouroboros.Consensus.Byron.Ledger.Serialisation

Show (NestedCtxt_ (ShelleyBlock proto era) f a) Source # 
Instance details

Defined in Ouroboros.Consensus.Shelley.Ledger.Block

Methods

showsPrec :: Int -> NestedCtxt_ (ShelleyBlock proto era) f a -> ShowS Source #

show :: NestedCtxt_ (ShelleyBlock proto era) f a -> String Source #

showList :: [NestedCtxt_ (ShelleyBlock proto era) f a] -> ShowS Source #

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

Defined in Ouroboros.Consensus.Byron.Ledger.Serialisation

data NestedCtxt_ (HardForkBlock xs) a b 
Instance details

Defined in Ouroboros.Consensus.HardFork.Combinator.Block

data NestedCtxt_ (HardForkBlock xs) a b where
data NestedCtxt_ (ShelleyBlock proto era) f a Source # 
Instance details

Defined in Ouroboros.Consensus.Shelley.Ledger.Block

data NestedCtxt_ (ShelleyBlock proto era) f a where
type TrivialIndex (NestedCtxt_ (ShelleyBlock proto era) f) 
Instance details

Defined in Ouroboros.Consensus.Shelley.Ledger.Block

type TrivialIndex (NestedCtxt_ (ShelleyBlock proto era) f) = f (ShelleyBlock proto era)

type RawBoundaryHeader = ABoundaryHeader ByteString Source #

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

decodeByronBlock :: EpochSlots -> Decoder s (ByteString -> ByronBlock) Source #

Inverse of encodeByronBlock

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

Use decodeByronBlock when you can, this function is provided for use by the hard-fork combinator.

decodeByronHeaderHash :: Decoder s (HeaderHash ByronBlock) Source #

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

Use decodeByronBlock when you can, this function is provided for use by the hard-fork combinator.

decodeByronRegularHeader :: EpochSlots -> Decoder s (ByteString -> RawHeader) Source #

encodeByronBlock :: ByronBlock -> Encoding Source #

Encode a block

Should be backwards compatible with legacy (cardano-sl) nodes.

Implementation note: the decoder uses decCBORABlockOrBoundary, which has inverse encCBORABlockOrBoundary. This encoder is intended to be binary compatible with encCBORABlockOrBoundary, but does not use it and instead takes advantage of the annotations (using encodePreEncoded).

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.

encodeByronHeaderHash :: HeaderHash ByronBlock -> Encoding Source #

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.

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 #

decodeUnsizedHeader :: EpochSlots -> Decoder s (ByteString -> UnsizedHeader) Source #

Inverse of encodeSizedHeader

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.

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

fakeByronBlockSizeHint :: SizeInBytes Source #

Fake size (used in compatibility mode)

Orphan instances

Serialise ByronHash Source # 
Instance details

Methods

encode :: ByronHash -> Encoding

decode :: Decoder s ByronHash

encodeList :: [ByronHash] -> Encoding

decodeList :: Decoder s [ByronHash]

HasNestedContent Header ByronBlock Source # 
Instance details

Methods

unnest :: Header ByronBlock -> DepPair (NestedCtxt Header ByronBlock)

nest :: DepPair (NestedCtxt Header ByronBlock) -> Header ByronBlock

SameDepIndex (NestedCtxt_ ByronBlock f) Source # 
Instance details

Show (NestedCtxt_ ByronBlock f a) Source # 
Instance details