ouroboros-network-api-0.7.2.0: A networking api shared with ouroboros-consensus
Safe HaskellSafe-Inferred
LanguageHaskell2010

Ouroboros.Network.Block

Description

Abstract view over blocks

The network layer does not make any concrete assumptions about what blocks look like.

Synopsis

Documentation

newtype SlotNo Source #

The 0-based index for the Ourboros time slot.

Constructors

SlotNo 

Fields

Instances

Instances details
FromJSON SlotNo 
Instance details

Defined in Cardano.Slotting.Slot

ToJSON SlotNo 
Instance details

Defined in Cardano.Slotting.Slot

Bounded SlotNo 
Instance details

Defined in Cardano.Slotting.Slot

Enum SlotNo 
Instance details

Defined in Cardano.Slotting.Slot

Generic SlotNo 
Instance details

Defined in Cardano.Slotting.Slot

Associated Types

type Rep SlotNoTypeType #

Methods

fromSlotNoRep SlotNo x #

toRep SlotNo x → SlotNo #

Num SlotNo 
Instance details

Defined in Cardano.Slotting.Slot

Methods

(+)SlotNoSlotNoSlotNo #

(-)SlotNoSlotNoSlotNo #

(*)SlotNoSlotNoSlotNo #

negateSlotNoSlotNo #

absSlotNoSlotNo #

signumSlotNoSlotNo #

fromIntegerIntegerSlotNo #

Show SlotNo 
Instance details

Defined in Cardano.Slotting.Slot

Methods

showsPrecIntSlotNoShowS #

showSlotNoString #

showList ∷ [SlotNo] → ShowS #

FromCBOR SlotNo 
Instance details

Defined in Cardano.Slotting.Slot

ToCBOR SlotNo 
Instance details

Defined in Cardano.Slotting.Slot

Methods

toCBORSlotNoEncoding Source #

encodedSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy SlotNoSize Source #

encodedListSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy [SlotNo] → Size Source #

NFData SlotNo 
Instance details

Defined in Cardano.Slotting.Slot

Methods

rnfSlotNo → () #

Eq SlotNo 
Instance details

Defined in Cardano.Slotting.Slot

Methods

(==)SlotNoSlotNoBool #

(/=)SlotNoSlotNoBool #

Ord SlotNo 
Instance details

Defined in Cardano.Slotting.Slot

Methods

compareSlotNoSlotNoOrdering #

(<)SlotNoSlotNoBool #

(<=)SlotNoSlotNoBool #

(>)SlotNoSlotNoBool #

(>=)SlotNoSlotNoBool #

maxSlotNoSlotNoSlotNo #

minSlotNoSlotNoSlotNo #

NoThunks SlotNo 
Instance details

Defined in Cardano.Slotting.Slot

Serialise SlotNo 
Instance details

Defined in Cardano.Slotting.Slot

ShowProxy SlotNo Source # 
Instance details

Defined in Ouroboros.Network.Util.ShowProxy

HasHeader block ⇒ Anchorable (WithOrigin SlotNo) (Anchor block) block Source # 
Instance details

Defined in Ouroboros.Network.AnchoredFragment

Methods

asAnchor ∷ block → Anchor block Source #

getAnchorMeasureProxy block → Anchor block → WithOrigin SlotNo Source #

type Rep SlotNo 
Instance details

Defined in Cardano.Slotting.Slot

type Rep SlotNo = D1 ('MetaData "SlotNo" "Cardano.Slotting.Slot" "cardano-slotting-0.2.0.0-b80c39407d1aae29adb9ad4f2d33d3fc06cf7bab5162a7ec4f22b16819d616e6" 'True) (C1 ('MetaCons "SlotNo" 'PrefixI 'True) (S1 ('MetaSel ('Just "unSlotNo") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Word64)))

newtype BlockNo Source #

The 0-based index of the block in the blockchain. BlockNo is <= SlotNo and is only equal at slot N if there is a block for every slot where N <= SlotNo.

Constructors

BlockNo 

Fields

Instances

Instances details
FromJSON BlockNo 
Instance details

Defined in Cardano.Slotting.Block

ToJSON BlockNo 
Instance details

Defined in Cardano.Slotting.Block

Bounded BlockNo 
Instance details

Defined in Cardano.Slotting.Block

Enum BlockNo 
Instance details

Defined in Cardano.Slotting.Block

Generic BlockNo 
Instance details

Defined in Cardano.Slotting.Block

Associated Types

type Rep BlockNoTypeType #

Methods

fromBlockNoRep BlockNo x #

toRep BlockNo x → BlockNo #

Num BlockNo 
Instance details

Defined in Cardano.Slotting.Block

Show BlockNo 
Instance details

Defined in Cardano.Slotting.Block

Methods

showsPrecIntBlockNoShowS #

showBlockNoString #

showList ∷ [BlockNo] → ShowS #

FromCBOR BlockNo 
Instance details

Defined in Cardano.Slotting.Block

ToCBOR BlockNo 
Instance details

Defined in Cardano.Slotting.Block

Methods

toCBORBlockNoEncoding Source #

encodedSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy BlockNoSize Source #

encodedListSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy [BlockNo] → Size Source #

NFData BlockNo 
Instance details

Defined in Cardano.Slotting.Block

Methods

rnfBlockNo → () #

Eq BlockNo 
Instance details

Defined in Cardano.Slotting.Block

Methods

(==)BlockNoBlockNoBool #

(/=)BlockNoBlockNoBool #

Ord BlockNo 
Instance details

Defined in Cardano.Slotting.Block

Methods

compareBlockNoBlockNoOrdering #

(<)BlockNoBlockNoBool #

(<=)BlockNoBlockNoBool #

(>)BlockNoBlockNoBool #

(>=)BlockNoBlockNoBool #

maxBlockNoBlockNoBlockNo #

minBlockNoBlockNoBlockNo #

NoThunks BlockNo 
Instance details

Defined in Cardano.Slotting.Block

Serialise BlockNo 
Instance details

Defined in Cardano.Slotting.Block

type Rep BlockNo 
Instance details

Defined in Cardano.Slotting.Block

type Rep BlockNo = D1 ('MetaData "BlockNo" "Cardano.Slotting.Block" "cardano-slotting-0.2.0.0-b80c39407d1aae29adb9ad4f2d33d3fc06cf7bab5162a7ec4f22b16819d616e6" 'True) (C1 ('MetaCons "BlockNo" 'PrefixI 'True) (S1 ('MetaSel ('Just "unBlockNo") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Word64)))

type family HeaderHash (b ∷ k) ∷ Type Source #

Header hash

Instances

Instances details
type HeaderHash (HeaderFields b ∷ Type) Source # 
Instance details

Defined in Ouroboros.Network.Block

type HeaderHash (Serialised block ∷ Type) Source # 
Instance details

Defined in Ouroboros.Network.Block

type HeaderHash (Serialised block ∷ Type) = HeaderHash block

data HeaderFields (b ∷ k) Source #

Header fields we expect to be present in a block

These fields are lazy because they are extracted from a block or block header; this type is not intended for storage.

Constructors

HeaderFields 

Fields

Instances

Instances details
StandardHash b ⇒ StandardHash (HeaderFields b ∷ Type) Source # 
Instance details

Defined in Ouroboros.Network.Block

Generic (HeaderFields b) Source # 
Instance details

Defined in Ouroboros.Network.Block

Associated Types

type Rep (HeaderFields b) ∷ TypeType #

Methods

fromHeaderFields b → Rep (HeaderFields b) x #

toRep (HeaderFields b) x → HeaderFields b #

StandardHash b ⇒ Show (HeaderFields b) Source # 
Instance details

Defined in Ouroboros.Network.Block

Methods

showsPrecIntHeaderFields b → ShowS #

showHeaderFields b → String #

showList ∷ [HeaderFields b] → ShowS #

StandardHash b ⇒ Eq (HeaderFields b) Source # 
Instance details

Defined in Ouroboros.Network.Block

Methods

(==)HeaderFields b → HeaderFields b → Bool #

(/=)HeaderFields b → HeaderFields b → Bool #

StandardHash b ⇒ Ord (HeaderFields b) Source # 
Instance details

Defined in Ouroboros.Network.Block

(StandardHash b, Typeable b, Typeable k) ⇒ HasHeader (HeaderFields b) Source # 
Instance details

Defined in Ouroboros.Network.Block

Serialise (HeaderHash b) ⇒ Serialise (HeaderFields b) Source # 
Instance details

Defined in Ouroboros.Network.Block

type HeaderHash (HeaderFields b ∷ Type) Source # 
Instance details

Defined in Ouroboros.Network.Block

type Rep (HeaderFields b) Source # 
Instance details

Defined in Ouroboros.Network.Block

type Rep (HeaderFields b) = D1 ('MetaData "HeaderFields" "Ouroboros.Network.Block" "ouroboros-network-api-0.7.2.0-inplace" 'False) (C1 ('MetaCons "HeaderFields" 'PrefixI 'True) (S1 ('MetaSel ('Just "headerFieldSlot") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 SlotNo) :*: (S1 ('MetaSel ('Just "headerFieldBlockNo") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 BlockNo) :*: S1 ('MetaSel ('Just "headerFieldHash") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (HeaderHash b)))))

class (StandardHash b, Typeable b) ⇒ HasHeader b where Source #

Abstract over the shape of blocks (or indeed just block headers)

Instances

Instances details
(StandardHash b, Typeable b, Typeable k) ⇒ HasHeader (HeaderFields b) Source # 
Instance details

Defined in Ouroboros.Network.Block

blockNoHasHeader b ⇒ b → BlockNo Source #

class HasHeader b ⇒ HasFullHeader b where Source #

Extension of HasHeader with some additional information

Used in tests and assertions only.

class (Eq (HeaderHash b), Ord (HeaderHash b), Show (HeaderHash b), Typeable (HeaderHash b), NoThunks (HeaderHash b)) ⇒ StandardHash (b ∷ k) Source #

StandardHash summarises the constraints we want header hashes to have

Without this class we would need to write

deriving instance Eq (HeaderHash block) => Eq (ChainHash block)

That requires UndecidableInstances; not a problem by itself, but it also means that we can then not use deriving Eq anywhere else for datatypes that reference Hash, which is very frustrating; see

https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/exts/deriving_inferred.html

Introducing the StandardHash class avoids this problem.

Having these constraints directly as part of the HasHeader class is possible but libraries that use the networking layer may wish to be able to talk about StandardHash independently of HasHeader since the latter may impose yet further constraints.

Instances

Instances details
StandardHash b ⇒ StandardHash (HeaderFields b ∷ Type) Source # 
Instance details

Defined in Ouroboros.Network.Block

StandardHash block ⇒ StandardHash (Serialised block ∷ Type) Source # 
Instance details

Defined in Ouroboros.Network.Block

data ChainHash b Source #

Constructors

GenesisHash 
BlockHash !(HeaderHash b) 

Instances

Instances details
Generic (ChainHash b) Source # 
Instance details

Defined in Ouroboros.Network.Block

Associated Types

type Rep (ChainHash b) ∷ TypeType #

Methods

fromChainHash b → Rep (ChainHash b) x #

toRep (ChainHash b) x → ChainHash b #

StandardHash block ⇒ Show (ChainHash block) Source # 
Instance details

Defined in Ouroboros.Network.Block

Methods

showsPrecIntChainHash block → ShowS #

showChainHash block → String #

showList ∷ [ChainHash block] → ShowS #

StandardHash block ⇒ Eq (ChainHash block) Source # 
Instance details

Defined in Ouroboros.Network.Block

Methods

(==)ChainHash block → ChainHash block → Bool #

(/=)ChainHash block → ChainHash block → Bool #

StandardHash block ⇒ Ord (ChainHash block) Source # 
Instance details

Defined in Ouroboros.Network.Block

Methods

compareChainHash block → ChainHash block → Ordering #

(<)ChainHash block → ChainHash block → Bool #

(<=)ChainHash block → ChainHash block → Bool #

(>)ChainHash block → ChainHash block → Bool #

(>=)ChainHash block → ChainHash block → Bool #

maxChainHash block → ChainHash block → ChainHash block #

minChainHash block → ChainHash block → ChainHash block #

(StandardHash block, Typeable block) ⇒ NoThunks (ChainHash block) Source # 
Instance details

Defined in Ouroboros.Network.Block

Serialise (HeaderHash b) ⇒ Serialise (ChainHash b) Source # 
Instance details

Defined in Ouroboros.Network.Block

type Rep (ChainHash b) Source # 
Instance details

Defined in Ouroboros.Network.Block

type Rep (ChainHash b) = D1 ('MetaData "ChainHash" "Ouroboros.Network.Block" "ouroboros-network-api-0.7.2.0-inplace" 'False) (C1 ('MetaCons "GenesisHash" 'PrefixI 'False) (U1TypeType) :+: C1 ('MetaCons "BlockHash" 'PrefixI 'False) (S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (HeaderHash b))))

newtype Point block Source #

A point on the chain is identified by its Slot and HeaderHash.

The Slot tells us where to look and the HeaderHash either simply serves as a check, or in some contexts it disambiguates blocks from different forks that were in the same slot.

It's a newtype rather than a type synonym, because using a type synonym would lead to ambiguity, since HeaderHash is a non-injective type family.

Constructors

Point 

Fields

Instances

Instances details
ShowProxy block ⇒ ShowProxy (Point block ∷ Type) Source # 
Instance details

Defined in Ouroboros.Network.Block

Methods

showProxyProxy (Point block) → String Source #

Generic (Point block) Source # 
Instance details

Defined in Ouroboros.Network.Block

Associated Types

type Rep (Point block) ∷ TypeType #

Methods

fromPoint block → Rep (Point block) x #

toRep (Point block) x → Point block #

StandardHash block ⇒ Show (Point block) Source # 
Instance details

Defined in Ouroboros.Network.Block

Methods

showsPrecIntPoint block → ShowS #

showPoint block → String #

showList ∷ [Point block] → ShowS #

StandardHash block ⇒ Eq (Point block) Source # 
Instance details

Defined in Ouroboros.Network.Block

Methods

(==)Point block → Point block → Bool #

(/=)Point block → Point block → Bool #

StandardHash block ⇒ Ord (Point block) Source # 
Instance details

Defined in Ouroboros.Network.Block

Methods

comparePoint block → Point block → Ordering #

(<)Point block → Point block → Bool #

(<=)Point block → Point block → Bool #

(>)Point block → Point block → Bool #

(>=)Point block → Point block → Bool #

maxPoint block → Point block → Point block #

minPoint block → Point block → Point block #

StandardHash block ⇒ NoThunks (Point block) Source # 
Instance details

Defined in Ouroboros.Network.Block

Methods

noThunksContextPoint block → IO (Maybe ThunkInfo) Source #

wNoThunksContextPoint block → IO (Maybe ThunkInfo) Source #

showTypeOfProxy (Point block) → String Source #

Serialise (HeaderHash block) ⇒ Serialise (Point block) Source # 
Instance details

Defined in Ouroboros.Network.Block

Methods

encodePoint block → Encoding Source #

decodeDecoder s (Point block) Source #

encodeList ∷ [Point block] → Encoding Source #

decodeListDecoder s [Point block] Source #

type Rep (Point block) Source # 
Instance details

Defined in Ouroboros.Network.Block

type Rep (Point block) = D1 ('MetaData "Point" "Ouroboros.Network.Block" "ouroboros-network-api-0.7.2.0-inplace" 'True) (C1 ('MetaCons "Point" 'PrefixI 'True) (S1 ('MetaSel ('Just "getPoint") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (WithOrigin (Block SlotNo (HeaderHash block))))))

pointHashPoint block → ChainHash block Source #

blockPointHasHeader block ⇒ block → Point block Source #

pattern GenesisPointPoint block Source #

pattern BlockPointSlotNoHeaderHash block → Point block Source #

atSlot ∷ ∀ {k} (block ∷ k). Point block → SlotNo Source #

withHash ∷ ∀ {k} (block ∷ k). Point block → HeaderHash block Source #

data Tip b Source #

Used in chain-sync protocol to advertise the tip of the server's chain.

Constructors

TipGenesis

The tip is genesis

Tip !SlotNo !(HeaderHash b) !BlockNo

The tip is not genesis

Instances

Instances details
ShowProxy b ⇒ ShowProxy (Tip b ∷ Type) Source # 
Instance details

Defined in Ouroboros.Network.Block

Methods

showProxyProxy (Tip b) → String Source #

Generic (Tip b) Source # 
Instance details

Defined in Ouroboros.Network.Block

Associated Types

type Rep (Tip b) ∷ TypeType #

Methods

fromTip b → Rep (Tip b) x #

toRep (Tip b) x → Tip b #

StandardHash b ⇒ Show (Tip b) Source # 
Instance details

Defined in Ouroboros.Network.Block

Methods

showsPrecIntTip b → ShowS #

showTip b → String #

showList ∷ [Tip b] → ShowS #

StandardHash b ⇒ Eq (Tip b) Source # 
Instance details

Defined in Ouroboros.Network.Block

Methods

(==)Tip b → Tip b → Bool #

(/=)Tip b → Tip b → Bool #

StandardHash b ⇒ NoThunks (Tip b) Source # 
Instance details

Defined in Ouroboros.Network.Block

type Rep (Tip b) Source # 
Instance details

Defined in Ouroboros.Network.Block

type Rep (Tip b) = D1 ('MetaData "Tip" "Ouroboros.Network.Block" "ouroboros-network-api-0.7.2.0-inplace" 'False) (C1 ('MetaCons "TipGenesis" 'PrefixI 'False) (U1TypeType) :+: C1 ('MetaCons "Tip" 'PrefixI 'False) (S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 SlotNo) :*: (S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (HeaderHash b)) :*: S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 BlockNo))))

castTipHeaderHash a ~ HeaderHash b ⇒ Tip a → Tip b Source #

The equivalent of castPoint for Tip

getLegacyTipBlockNoTip b → BlockNo Source #

Deprecated: Use getTipBlockNo

Get the block number associated with a Tip, or genesisBlockNo otherwise

TODO: This is wrong. There is no block number if we are at genesis (genesisBlockNo is the block number of the first block on the chain). Usage of this function should be phased out.

tipFromHeaderHasHeader a ⇒ a → Tip a Source #

legacyTipPoint b → BlockNoTip b Source #

Deprecated: Use tipFromHeader instead

Inverse of toLegacyTip

TODO: This should be phased out, since it makes no sense to have a BlockNo for the genesis point.

toLegacyTipTip b → (Point b, BlockNo) Source #

Deprecated: Use getTipPoint and getTipBlockNo

Translate to the format it was before (to maintain binary compatibility)

encodeTip ∷ (HeaderHash blk → Encoding) → Tip blk → Encoding Source #

decodeTip ∷ ∀ blk. (∀ s. Decoder s (HeaderHash blk)) → ∀ s. Decoder s (Tip blk) Source #

data ChainUpdate block a Source #

A representation of two actions to update a chain: add a block or roll back to a previous point.

The type parameter a is there to allow a Functor instance. Typically, it will be instantiated with block itself.

Constructors

AddBlock a 
RollBack (Point block) 

Instances

Instances details
Foldable (ChainUpdate block) Source # 
Instance details

Defined in Ouroboros.Network.Block

Methods

foldMonoid m ⇒ ChainUpdate block m → m #

foldMapMonoid m ⇒ (a → m) → ChainUpdate block a → m #

foldMap'Monoid m ⇒ (a → m) → ChainUpdate block a → m #

foldr ∷ (a → b → b) → b → ChainUpdate block a → b #

foldr' ∷ (a → b → b) → b → ChainUpdate block a → b #

foldl ∷ (b → a → b) → b → ChainUpdate block a → b #

foldl' ∷ (b → a → b) → b → ChainUpdate block a → b #

foldr1 ∷ (a → a → a) → ChainUpdate block a → a #

foldl1 ∷ (a → a → a) → ChainUpdate block a → a #

toListChainUpdate block a → [a] #

nullChainUpdate block a → Bool #

lengthChainUpdate block a → Int #

elemEq a ⇒ a → ChainUpdate block a → Bool #

maximumOrd a ⇒ ChainUpdate block a → a #

minimumOrd a ⇒ ChainUpdate block a → a #

sumNum a ⇒ ChainUpdate block a → a #

productNum a ⇒ ChainUpdate block a → a #

Traversable (ChainUpdate block) Source # 
Instance details

Defined in Ouroboros.Network.Block

Methods

traverseApplicative f ⇒ (a → f b) → ChainUpdate block a → f (ChainUpdate block b) #

sequenceAApplicative f ⇒ ChainUpdate block (f a) → f (ChainUpdate block a) #

mapMMonad m ⇒ (a → m b) → ChainUpdate block a → m (ChainUpdate block b) #

sequenceMonad m ⇒ ChainUpdate block (m a) → m (ChainUpdate block a) #

Functor (ChainUpdate block) Source # 
Instance details

Defined in Ouroboros.Network.Block

Methods

fmap ∷ (a → b) → ChainUpdate block a → ChainUpdate block b #

(<$) ∷ a → ChainUpdate block b → ChainUpdate block a #

(StandardHash block, Show a) ⇒ Show (ChainUpdate block a) Source # 
Instance details

Defined in Ouroboros.Network.Block

Methods

showsPrecIntChainUpdate block a → ShowS #

showChainUpdate block a → String #

showList ∷ [ChainUpdate block a] → ShowS #

(StandardHash block, Eq a) ⇒ Eq (ChainUpdate block a) Source # 
Instance details

Defined in Ouroboros.Network.Block

Methods

(==)ChainUpdate block a → ChainUpdate block a → Bool #

(/=)ChainUpdate block a → ChainUpdate block a → Bool #

data MaxSlotNo Source #

The highest slot number seen.

Constructors

NoMaxSlotNo

No block/header has been seen yet, so we don't have a highest slot number.

MaxSlotNo !SlotNo

The highest slot number seen.

Instances

Instances details
Monoid MaxSlotNo Source # 
Instance details

Defined in Ouroboros.Network.Block

Semigroup MaxSlotNo Source # 
Instance details

Defined in Ouroboros.Network.Block

Generic MaxSlotNo Source # 
Instance details

Defined in Ouroboros.Network.Block

Associated Types

type Rep MaxSlotNoTypeType #

Methods

fromMaxSlotNoRep MaxSlotNo x #

toRep MaxSlotNo x → MaxSlotNo #

Show MaxSlotNo Source # 
Instance details

Defined in Ouroboros.Network.Block

Methods

showsPrecIntMaxSlotNoShowS #

showMaxSlotNoString #

showList ∷ [MaxSlotNo] → ShowS #

Eq MaxSlotNo Source # 
Instance details

Defined in Ouroboros.Network.Block

Methods

(==)MaxSlotNoMaxSlotNoBool #

(/=)MaxSlotNoMaxSlotNoBool #

Ord MaxSlotNo Source # 
Instance details

Defined in Ouroboros.Network.Block

NoThunks MaxSlotNo Source # 
Instance details

Defined in Ouroboros.Network.Block

type Rep MaxSlotNo Source # 
Instance details

Defined in Ouroboros.Network.Block

type Rep MaxSlotNo = D1 ('MetaData "MaxSlotNo" "Ouroboros.Network.Block" "ouroboros-network-api-0.7.2.0-inplace" 'False) (C1 ('MetaCons "NoMaxSlotNo" 'PrefixI 'False) (U1TypeType) :+: C1 ('MetaCons "MaxSlotNo" 'PrefixI 'False) (S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 SlotNo)))

Serialisation

encodePoint ∷ (HeaderHash block → Encoding) → Point block → Encoding Source #

decodePoint ∷ (∀ s. Decoder s (HeaderHash block)) → ∀ s. Decoder s (Point block) Source #

decodeChainHash ∷ (∀ s. Decoder s (HeaderHash block)) → ∀ s. Decoder s (ChainHash block) Source #

Serialised block/header

newtype Serialised a Source #

An already serialised value

When streaming blocks/header from disk to the network, there is often no need to deserialise them, as we'll just end up serialising them again when putting them on the wire.

Constructors

Serialised 

Instances

Instances details
StandardHash block ⇒ StandardHash (Serialised block ∷ Type) Source # 
Instance details

Defined in Ouroboros.Network.Block

ShowProxy a ⇒ ShowProxy (Serialised a ∷ Type) Source # 
Instance details

Defined in Ouroboros.Network.Block

Show (Serialised a) Source # 
Instance details

Defined in Ouroboros.Network.Block

Methods

showsPrecIntSerialised a → ShowS #

showSerialised a → String #

showList ∷ [Serialised a] → ShowS #

Eq (Serialised a) Source # 
Instance details

Defined in Ouroboros.Network.Block

Methods

(==)Serialised a → Serialised a → Bool #

(/=)Serialised a → Serialised a → Bool #

Serialise (Serialised a) Source #

CBOR-in-CBOR

TODO: replace with encodeEmbeddedCBOR from cborg-0.2.4 once it is available, since that will be faster.

TODO: Avoid converting to a strict ByteString, as that requires copying O(n) in case the lazy ByteString consists of more than one chunks.

Instance details

Defined in Ouroboros.Network.Block

type HeaderHash (Serialised block ∷ Type) Source # 
Instance details

Defined in Ouroboros.Network.Block

type HeaderHash (Serialised block ∷ Type) = HeaderHash block

wrapCBORinCBOR ∷ (a → Encoding) → a → Encoding Source #

Wrap CBOR-in-CBOR

This is primarily useful for the decoder; see unwrapCBORinCBOR

unwrapCBORinCBOR ∷ (∀ s. Decoder s (ByteString → a)) → ∀ s. Decoder s a Source #

Unwrap CBOR-in-CBOR

The CBOR-in-CBOR encoding gives us the ByteString we need in order to to construct annotations.

mkSerialised ∷ (a → Encoding) → a → Serialised a Source #

Construct Serialised value from an unserialised value

fromSerialised ∷ (∀ s. Decoder s (ByteString → a)) → Serialised a → ∀ s. Decoder s a Source #

Decode a Serialised value

Unlike a regular Decoder, which has an implicit input stream, fromSerialised takes the Serialised value as an argument.