ouroboros-network-0.1.0.0: A networking layer for the Ouroboros blockchain protocol
Safe HaskellNone
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 #

Constructors

SlotNo 

Fields

Instances

Instances details
Bounded SlotNo 
Instance details

Defined in Cardano.Slotting.Slot

Enum SlotNo 
Instance details

Defined in Cardano.Slotting.Slot

Eq SlotNo 
Instance details

Defined in Cardano.Slotting.Slot

Methods

(==)SlotNoSlotNoBool Source #

(/=)SlotNoSlotNoBool Source #

Num SlotNo 
Instance details

Defined in Cardano.Slotting.Slot

Ord SlotNo 
Instance details

Defined in Cardano.Slotting.Slot

Show SlotNo 
Instance details

Defined in Cardano.Slotting.Slot

Generic SlotNo 
Instance details

Defined in Cardano.Slotting.Slot

Associated Types

type Rep SlotNoTypeType Source #

Methods

fromSlotNoRep SlotNo x Source #

toRep SlotNo x → SlotNo Source #

NFData SlotNo 
Instance details

Defined in Cardano.Slotting.Slot

Methods

rnfSlotNo → () Source #

Serialise SlotNo 
Instance details

Defined in Cardano.Slotting.Slot

Methods

encodeSlotNo → Encoding #

decode ∷ Decoder s SlotNo #

encodeList ∷ [SlotNo] → Encoding #

decodeList ∷ Decoder s [SlotNo] #

NoThunks SlotNo 
Instance details

Defined in Cardano.Slotting.Slot

Methods

noThunks ∷ Context → SlotNoIO (Maybe ThunkInfo)

wNoThunks ∷ Context → SlotNoIO (Maybe ThunkInfo)

showTypeOfProxy SlotNoString

Hashable SlotNo 
Instance details

Defined in Ouroboros.Network.Testing.ConcreteBlock

Methods

hashWithSaltIntSlotNoInt

hashSlotNoInt

FromCBOR SlotNo 
Instance details

Defined in Cardano.Slotting.Slot

Methods

fromCBOR ∷ Decoder s SlotNo

labelProxy SlotNoText

FromJSON SlotNo 
Instance details

Defined in Cardano.Slotting.Slot

Methods

parseJSON ∷ Value → Parser SlotNo

parseJSONList ∷ Value → Parser [SlotNo]

ToCBOR SlotNo 
Instance details

Defined in Cardano.Slotting.Slot

Methods

toCBORSlotNo → Encoding

encodedSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy SlotNo → Size

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

ToJSON SlotNo 
Instance details

Defined in Cardano.Slotting.Slot

Methods

toJSONSlotNo → Value

toEncodingSlotNo → Encoding

toJSONList ∷ [SlotNo] → Value

toEncodingList ∷ [SlotNo] → Encoding

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.1.0.0-0d44f65cb9561765b48fdba2b66a0b633a4e95aca59cab56ad2b70ffb4013db6" 'True) (C1 ('MetaCons "SlotNo" 'PrefixI 'True) (S1 ('MetaSel ('Just "unSlotNo") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Word64)))

newtype BlockNo #

Constructors

BlockNo 

Fields

Instances

Instances details
Bounded BlockNo 
Instance details

Defined in Cardano.Slotting.Block

Enum BlockNo 
Instance details

Defined in Cardano.Slotting.Block

Eq BlockNo 
Instance details

Defined in Cardano.Slotting.Block

Methods

(==)BlockNoBlockNoBool Source #

(/=)BlockNoBlockNoBool Source #

Num BlockNo 
Instance details

Defined in Cardano.Slotting.Block

Ord BlockNo 
Instance details

Defined in Cardano.Slotting.Block

Show BlockNo 
Instance details

Defined in Cardano.Slotting.Block

Generic BlockNo 
Instance details

Defined in Cardano.Slotting.Block

Associated Types

type Rep BlockNoTypeType Source #

Methods

fromBlockNoRep BlockNo x Source #

toRep BlockNo x → BlockNo Source #

NFData BlockNo 
Instance details

Defined in Cardano.Slotting.Block

Methods

rnfBlockNo → () Source #

Serialise BlockNo 
Instance details

Defined in Cardano.Slotting.Block

Methods

encodeBlockNo → Encoding #

decode ∷ Decoder s BlockNo #

encodeList ∷ [BlockNo] → Encoding #

decodeList ∷ Decoder s [BlockNo] #

NoThunks BlockNo 
Instance details

Defined in Cardano.Slotting.Block

Methods

noThunks ∷ Context → BlockNoIO (Maybe ThunkInfo)

wNoThunks ∷ Context → BlockNoIO (Maybe ThunkInfo)

showTypeOfProxy BlockNoString

Hashable BlockNo 
Instance details

Defined in Ouroboros.Network.Testing.ConcreteBlock

Methods

hashWithSaltIntBlockNoInt

hashBlockNoInt

FromCBOR BlockNo 
Instance details

Defined in Cardano.Slotting.Block

Methods

fromCBOR ∷ Decoder s BlockNo

labelProxy BlockNoText

ToCBOR BlockNo 
Instance details

Defined in Cardano.Slotting.Block

Methods

toCBORBlockNo → Encoding

encodedSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy BlockNo → Size

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

type Rep BlockNo 
Instance details

Defined in Cardano.Slotting.Block

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

type family HeaderHash b ∷ Type Source #

Header hash

Instances

Instances details
type HeaderHash BlockHeader Source # 
Instance details

Defined in Ouroboros.Network.Testing.ConcreteBlock

type HeaderHash Block Source # 
Instance details

Defined in Ouroboros.Network.Testing.ConcreteBlock

type HeaderHash (Serialised block) Source # 
Instance details

Defined in Ouroboros.Network.Block

type HeaderHash (Serialised block) = HeaderHash block
type HeaderHash (HeaderFields b) Source # 
Instance details

Defined in Ouroboros.Network.Block

data HeaderFields b 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 ⇒ Eq (HeaderFields b) Source # 
Instance details

Defined in Ouroboros.Network.Block

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

Defined in Ouroboros.Network.Block

StandardHash b ⇒ Show (HeaderFields b) 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 Source #

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

Defined in Ouroboros.Network.Block

Methods

encodeHeaderFields b → Encoding #

decode ∷ Decoder s (HeaderFields b) #

encodeList ∷ [HeaderFields b] → Encoding #

decodeList ∷ Decoder s [HeaderFields b] #

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

Defined in Ouroboros.Network.Block

(StandardHash b, Typeable b) ⇒ HasHeader (HeaderFields b) 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-0.1.0.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)))))
type HeaderHash (HeaderFields b) Source # 
Instance details

Defined in Ouroboros.Network.Block

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

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

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 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/glasgow_exts.html#inferred-context-for-deriving-clauses

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 BlockHeader Source # 
Instance details

Defined in Ouroboros.Network.Testing.ConcreteBlock

StandardHash Block Source # 
Instance details

Defined in Ouroboros.Network.Testing.ConcreteBlock

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

Defined in Ouroboros.Network.Block

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

Defined in Ouroboros.Network.Block

data ChainHash b Source #

Constructors

GenesisHash 
BlockHash !(HeaderHash b) 

Instances

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

Defined in Ouroboros.Network.Block

Methods

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

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

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

Defined in Ouroboros.Network.Block

Methods

compareChainHash block → ChainHash block → Ordering Source #

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

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

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

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

maxChainHash block → ChainHash block → ChainHash block Source #

minChainHash block → ChainHash block → ChainHash block Source #

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

Defined in Ouroboros.Network.Block

Methods

showsPrecIntChainHash block → ShowS Source #

showChainHash block → String Source #

showList ∷ [ChainHash block] → ShowS Source #

Generic (ChainHash b) Source # 
Instance details

Defined in Ouroboros.Network.Block

Associated Types

type Rep (ChainHash b) ∷ TypeType Source #

Methods

fromChainHash b → Rep (ChainHash b) x Source #

toRep (ChainHash b) x → ChainHash b Source #

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

Defined in Ouroboros.Network.Block

Methods

encodeChainHash b → Encoding #

decode ∷ Decoder s (ChainHash b) #

encodeList ∷ [ChainHash b] → Encoding #

decodeList ∷ Decoder s [ChainHash b] #

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

Defined in Ouroboros.Network.Block

Methods

noThunks ∷ Context → ChainHash block → IO (Maybe ThunkInfo)

wNoThunks ∷ Context → ChainHash block → IO (Maybe ThunkInfo)

showTypeOfProxy (ChainHash block) → String

Hashable (HeaderHash b) ⇒ Hashable (ChainHash b)

Hashable instance for Hash

We don't insist that Hashable in StandardHash because Hashable is only used in the network layer tests.

This requires UndecidableInstances because Hashable (HeaderHash b) is no smaller than Hashable (ChainHash b).

Instance details

Defined in Ouroboros.Network.Testing.ConcreteBlock

Methods

hashWithSaltIntChainHash b → Int

hashChainHash b → Int

type Rep (ChainHash b) Source # 
Instance details

Defined in Ouroboros.Network.Block

type Rep (ChainHash b) = D1 ('MetaData "ChainHash" "Ouroboros.Network.Block" "ouroboros-network-0.1.0.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
StandardHash block ⇒ Eq (Point block) Source # 
Instance details

Defined in Ouroboros.Network.Block

Methods

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

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

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

Defined in Ouroboros.Network.Block

Methods

comparePoint block → Point block → Ordering Source #

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

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

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

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

maxPoint block → Point block → Point block Source #

minPoint block → Point block → Point block Source #

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

Defined in Ouroboros.Network.Block

Methods

showsPrecIntPoint block → ShowS Source #

showPoint block → String Source #

showList ∷ [Point block] → ShowS Source #

Generic (Point block) Source # 
Instance details

Defined in Ouroboros.Network.Block

Associated Types

type Rep (Point block) ∷ TypeType Source #

Methods

fromPoint block → Rep (Point block) x Source #

toRep (Point block) x → Point block Source #

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

Defined in Ouroboros.Network.Block

Methods

encodePoint block → Encoding #

decode ∷ Decoder s (Point block) #

encodeList ∷ [Point block] → Encoding #

decodeList ∷ Decoder s [Point block] #

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

Defined in Ouroboros.Network.Block

Methods

noThunks ∷ Context → Point block → IO (Maybe ThunkInfo)

wNoThunks ∷ Context → Point block → IO (Maybe ThunkInfo)

showTypeOfProxy (Point block) → String

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

Defined in Ouroboros.Network.Block

Methods

showProxyProxy (Point block) → String 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-0.1.0.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 #

atSlotPoint block → SlotNo Source #

withHashPoint 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
StandardHash b ⇒ Eq (Tip b) Source # 
Instance details

Defined in Ouroboros.Network.Block

Methods

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

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

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

Defined in Ouroboros.Network.Block

Methods

showsPrecIntTip b → ShowS Source #

showTip b → String Source #

showList ∷ [Tip b] → ShowS Source #

Generic (Tip b) Source # 
Instance details

Defined in Ouroboros.Network.Block

Associated Types

type Rep (Tip b) ∷ TypeType Source #

Methods

fromTip b → Rep (Tip b) x Source #

toRep (Tip b) x → Tip b Source #

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

Defined in Ouroboros.Network.Block

Methods

noThunks ∷ Context → Tip b → IO (Maybe ThunkInfo)

wNoThunks ∷ Context → Tip b → IO (Maybe ThunkInfo)

showTypeOfProxy (Tip b) → String

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

Defined in Ouroboros.Network.Block

Methods

showProxyProxy (Tip b) → String Source #

type Rep (Tip b) Source # 
Instance details

Defined in Ouroboros.Network.Block

type Rep (Tip b) = D1 ('MetaData "Tip" "Ouroboros.Network.Block" "ouroboros-network-0.1.0.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 #

encodedTipSize ∷ (Proxy (HeaderHash blk) → Size) → Proxy (Tip blk) → Size 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
Functor (ChainUpdate block) Source # 
Instance details

Defined in Ouroboros.Network.Block

Methods

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

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

Foldable (ChainUpdate block) Source # 
Instance details

Defined in Ouroboros.Network.Block

Methods

foldMonoid m ⇒ ChainUpdate block m → m Source #

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

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

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

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

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

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

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

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

toListChainUpdate block a → [a] Source #

nullChainUpdate block a → Bool Source #

lengthChainUpdate block a → Int Source #

elemEq a ⇒ a → ChainUpdate block a → Bool Source #

maximumOrd a ⇒ ChainUpdate block a → a Source #

minimumOrd a ⇒ ChainUpdate block a → a Source #

sumNum a ⇒ ChainUpdate block a → a Source #

productNum a ⇒ ChainUpdate block a → a Source #

Traversable (ChainUpdate block) Source # 
Instance details

Defined in Ouroboros.Network.Block

Methods

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

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

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

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

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

Defined in Ouroboros.Network.Block

Methods

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

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

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

Defined in Ouroboros.Network.Block

Methods

showsPrecIntChainUpdate block a → ShowS Source #

showChainUpdate block a → String Source #

showList ∷ [ChainUpdate block a] → ShowS Source #

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
Eq MaxSlotNo Source # 
Instance details

Defined in Ouroboros.Network.Block

Ord MaxSlotNo Source # 
Instance details

Defined in Ouroboros.Network.Block

Show MaxSlotNo Source # 
Instance details

Defined in Ouroboros.Network.Block

Generic MaxSlotNo Source # 
Instance details

Defined in Ouroboros.Network.Block

Associated Types

type Rep MaxSlotNoTypeType Source #

Semigroup MaxSlotNo Source # 
Instance details

Defined in Ouroboros.Network.Block

Monoid MaxSlotNo Source # 
Instance details

Defined in Ouroboros.Network.Block

NoThunks MaxSlotNo Source # 
Instance details

Defined in Ouroboros.Network.Block

Methods

noThunks ∷ Context → MaxSlotNoIO (Maybe ThunkInfo)

wNoThunks ∷ Context → MaxSlotNoIO (Maybe ThunkInfo)

showTypeOfProxy MaxSlotNoString

type Rep MaxSlotNo Source # 
Instance details

Defined in Ouroboros.Network.Block

type Rep MaxSlotNo = D1 ('MetaData "MaxSlotNo" "Ouroboros.Network.Block" "ouroboros-network-0.1.0.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 #

encodedPointSize ∷ (Proxy (HeaderHash block) → Size) → Proxy (Point block) → Size Source #

encodeChainHash ∷ (HeaderHash block → Encoding) → ChainHash 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
Eq (Serialised a) Source # 
Instance details

Defined in Ouroboros.Network.Block

Methods

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

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

Show (Serialised a) Source # 
Instance details

Defined in Ouroboros.Network.Block

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

Methods

encodeSerialised a → Encoding #

decode ∷ Decoder s (Serialised a) #

encodeList ∷ [Serialised a] → Encoding #

decodeList ∷ Decoder s [Serialised a] #

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

Defined in Ouroboros.Network.Block

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

Defined in Ouroboros.Network.Block

type HeaderHash (Serialised block) Source # 
Instance details

Defined in Ouroboros.Network.Block

type HeaderHash (Serialised block) = 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.