Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- type Block = ABlock ()
- data ABlock a = ABlock {
- blockHeader ∷ AHeader a
- blockBody ∷ ABody a
- blockAnnotation ∷ a
- mkBlock ∷ ProtocolMagicId → ProtocolVersion → SoftwareVersion → Either GenesisHash Header → EpochSlots → SlotNumber → SigningKey → Certificate → Body → Block
- mkBlockExplicit ∷ ProtocolMagicId → ProtocolVersion → SoftwareVersion → HeaderHash → ChainDifficulty → EpochSlots → SlotNumber → SigningKey → Certificate → Body → Block
- blockHash ∷ EpochSlots → Block → HeaderHash
- blockHashAnnotated ∷ ABlock ByteString → HeaderHash
- blockAProtocolMagicId ∷ ABlock a → Annotated ProtocolMagicId a
- blockProtocolMagicId ∷ ABlock a → ProtocolMagicId
- blockPrevHash ∷ ABlock a → HeaderHash
- blockProof ∷ ABlock a → Proof
- blockSlot ∷ ABlock a → SlotNumber
- blockGenesisKey ∷ ABlock a → VerificationKey
- blockIssuer ∷ ABlock a → VerificationKey
- blockDifficulty ∷ ABlock a → ChainDifficulty
- blockToSign ∷ EpochSlots → ABlock a → ToSign
- blockSignature ∷ ABlock a → ABlockSignature a
- blockProtocolVersion ∷ ABlock a → ProtocolVersion
- blockSoftwareVersion ∷ ABlock a → SoftwareVersion
- blockTxPayload ∷ ABlock a → ATxPayload a
- blockSscPayload ∷ ABlock a → SscPayload
- blockDlgPayload ∷ ABlock a → APayload a
- blockUpdatePayload ∷ ABlock a → APayload a
- blockLength ∷ ABlock ByteString → Natural
- encCBORBlock ∷ EpochSlots → Block → Encoding
- decCBORABlock ∷ EpochSlots → Decoder s (ABlock ByteSpan)
- renderBlock ∷ EpochSlots → Block → Builder
- data ABlockOrBoundary a
- = ABOBBlock (ABlock a)
- | ABOBBoundary (ABoundaryBlock a)
- encCBORABOBBlock ∷ EpochSlots → ABlock a → Encoding
- decCBORABOBBlock ∷ EpochSlots → Decoder s (Maybe Block)
- decCBORABlockOrBoundary ∷ EpochSlots → Decoder s (ABlockOrBoundary ByteSpan)
- encCBORABlockOrBoundary ∷ ProtocolMagicId → EpochSlots → ABlockOrBoundary a → Encoding
- data ABoundaryBlock a = ABoundaryBlock {
- boundaryBlockLength ∷ !Int64
- boundaryHeader ∷ !(ABoundaryHeader a)
- boundaryBody ∷ !(ABoundaryBody a)
- boundaryAnnotation ∷ !a
- boundaryHashAnnotated ∷ ABoundaryBlock ByteString → HeaderHash
- decCBORABoundaryBlock ∷ Decoder s (ABoundaryBlock ByteSpan)
- encCBORABoundaryBlock ∷ ProtocolMagicId → ABoundaryBlock a → Encoding
- encCBORABOBBoundary ∷ ProtocolMagicId → ABoundaryBlock a → Encoding
- boundaryBlockSlot ∷ EpochSlots → Word64 → SlotNumber
- data ABoundaryBody a = ABoundaryBody {}
- data ABlockOrBoundaryHdr a
- = ABOBBlockHdr !(AHeader a)
- | ABOBBoundaryHdr !(ABoundaryHeader a)
- aBlockOrBoundaryHdr ∷ (AHeader a → b) → (ABoundaryHeader a → b) → ABlockOrBoundaryHdr a → b
- decCBORABlockOrBoundaryHdr ∷ EpochSlots → Decoder s (ABlockOrBoundaryHdr ByteSpan)
- encCBORABlockOrBoundaryHdr ∷ ABlockOrBoundaryHdr ByteString → Encoding
- encCBORABlockOrBoundaryHdrSize ∷ Proxy (ABlockOrBoundaryHdr a) → Size
- abobHdrFromBlock ∷ ABlockOrBoundary a → ABlockOrBoundaryHdr a
- abobHdrSlotNo ∷ EpochSlots → ABlockOrBoundaryHdr a → SlotNumber
- abobHdrChainDifficulty ∷ ABlockOrBoundaryHdr a → ChainDifficulty
- abobHdrHash ∷ ABlockOrBoundaryHdr ByteString → HeaderHash
- abobHdrPrevHash ∷ ABlockOrBoundaryHdr a → Maybe HeaderHash
Block
ABlock | |
|
Instances
Functor ABlock Source # | |
ToJSON a ⇒ ToJSON (ABlock a) Source # | |
Generic (ABlock a) Source # | |
Show a ⇒ Show (ABlock a) Source # | |
NFData a ⇒ NFData (ABlock a) Source # | |
Defined in Cardano.Chain.Block.Block | |
Buildable (WithEpochSlots Block) Source # | |
Defined in Cardano.Chain.Block.Block | |
Eq a ⇒ Eq (ABlock a) Source # | |
type Rep (ABlock a) Source # | |
Defined in Cardano.Chain.Block.Block type Rep (ABlock a) = D1 ('MetaData "ABlock" "Cardano.Chain.Block.Block" "cardano-ledger-byron-1.0.1.0-inplace" 'False) (C1 ('MetaCons "ABlock" 'PrefixI 'True) (S1 ('MetaSel ('Just "blockHeader") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (AHeader a)) :*: (S1 ('MetaSel ('Just "blockBody") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (ABody a)) :*: S1 ('MetaSel ('Just "blockAnnotation") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a)))) |
Block Constructors
∷ ProtocolMagicId | |
→ ProtocolVersion | |
→ SoftwareVersion | |
→ Either GenesisHash Header | |
→ EpochSlots | |
→ SlotNumber | |
→ SigningKey | The |
→ Certificate | A certificate of delegation from a genesis key to the |
→ Body | |
→ Block |
Smart constructor for Block
∷ ProtocolMagicId | |
→ ProtocolVersion | |
→ SoftwareVersion | |
→ HeaderHash | |
→ ChainDifficulty | |
→ EpochSlots | |
→ SlotNumber | |
→ SigningKey | The |
→ Certificate | A certificate of delegation from a genesis key to the |
→ Body | |
→ Block |
Block Accessors
blockHash ∷ EpochSlots → Block → HeaderHash Source #
blockPrevHash ∷ ABlock a → HeaderHash Source #
blockProof ∷ ABlock a → Proof Source #
blockSlot ∷ ABlock a → SlotNumber Source #
blockIssuer ∷ ABlock a → VerificationKey Source #
blockToSign ∷ EpochSlots → ABlock a → ToSign Source #
blockSignature ∷ ABlock a → ABlockSignature a Source #
blockTxPayload ∷ ABlock a → ATxPayload a Source #
blockSscPayload ∷ ABlock a → SscPayload Source #
blockDlgPayload ∷ ABlock a → APayload a Source #
blockUpdatePayload ∷ ABlock a → APayload a Source #
Block Binary Serialization
encCBORBlock ∷ EpochSlots → Block → Encoding Source #
Encode a block, given a number of slots-per-epoch.
Unlike encCBORABOBBlock
, this function does not take the deprecated epoch
boundary blocks into account.
decCBORABlock ∷ EpochSlots → Decoder s (ABlock ByteSpan) Source #
Block Formatting
renderBlock ∷ EpochSlots → Block → Builder Source #
ABlockOrBoundary
data ABlockOrBoundary a Source #
ABOBBlock (ABlock a) | |
ABOBBoundary (ABoundaryBlock a) |
Instances
encCBORABOBBlock ∷ EpochSlots → ABlock a → Encoding Source #
Encode a Block
accounting for deprecated epoch boundary blocks
decCBORABOBBlock ∷ EpochSlots → Decoder s (Maybe Block) Source #
Decode a Block
accounting for deprecated epoch boundary blocks
decCBORABlockOrBoundary ∷ EpochSlots → Decoder s (ABlockOrBoundary ByteSpan) Source #
Decode a Block
accounting for deprecated epoch boundary blocks
Previous versions of Cardano had an explicit boundary block between epochs.
A Block
was then represented as 'Either BoundaryBlock MainBlock'. We have
now deprecated these explicit boundary blocks, but we still need to decode
blocks in the old format. In the case that we find a boundary block, we
drop it using dropBoundaryBlock
and return a Nothing
.
ABoundaryBlock
data ABoundaryBlock a Source #
For a boundary block, we keep the header, body, and an annotation for the whole thing (commonly the bytes from which it was decoded).
ABoundaryBlock | |
|
Instances
boundaryHashAnnotated ∷ ABoundaryBlock ByteString → HeaderHash Source #
Extract the hash of a boundary block from its annotation.
encCBORABoundaryBlock ∷ ProtocolMagicId → ABoundaryBlock a → Encoding Source #
See note on encCBORABoundaryHeader
. This as well does not necessarily
invert the decoder decCBORABoundaryBlock
.
encCBORABOBBoundary ∷ ProtocolMagicId → ABoundaryBlock a → Encoding Source #
encCBORABoundaryBlock but with the list length and tag discriminator bytes.
∷ EpochSlots | |
→ Word64 | Epoch number |
→ SlotNumber |
Compute the slot number assigned to a boundary block
data ABoundaryBody a Source #
For boundary body data, we only keep an annotation. It's the body and extra body data.
Instances
ABlockOrBoundaryHdr
data ABlockOrBoundaryHdr a Source #
ABOBBlockHdr !(AHeader a) | |
ABOBBoundaryHdr !(ABoundaryHeader a) |
Instances
aBlockOrBoundaryHdr ∷ (AHeader a → b) → (ABoundaryHeader a → b) → ABlockOrBoundaryHdr a → b Source #
The analogue of either
encCBORABlockOrBoundaryHdr ∷ ABlockOrBoundaryHdr ByteString → Encoding Source #
Encoder for ABlockOrBoundaryHdr
which is using the annotation.
It is right inverse of decCBORAblockOrBoundaryHdr
.
TODO: add a round trip test, e.g.
decCBORABlockOrBoundaryHdr . encCBORABlockOrBoundaryHdr = id
which does not type check, but convey the meaning.
encCBORABlockOrBoundaryHdrSize ∷ Proxy (ABlockOrBoundaryHdr a) → Size Source #
The size computation is compatible with encCBORABlockOrBoundaryHdr
abobHdrSlotNo ∷ EpochSlots → ABlockOrBoundaryHdr a → SlotNumber Source #
Slot number of the header
NOTE: Epoch slot number calculation must match the one in applyBoundary
.