Safe Haskell | None |
---|---|
Language | Haskell2010 |
Ouroboros.Consensus.Node.Serialisation
Description
Serialisation for sending things across the network.
We separate NodeToNode
from NodeToClient
to be very explicit about what
gets sent where.
Unlike in Ouroboros.Consensus.Storage.Serialisation, we don't separate the encoder from the decoder, because the reasons don't apply: we always need both directions and we don't have access to the bytestrings that could be used for the annotations (we use CBOR-in-CBOR in those cases).
Synopsis
- class SerialiseBlockQueryResult blk (query ∷ Type → k → Type → Type) where
- encodeBlockQueryResult ∷ ∀ (fp ∷ k) result. CodecConfig blk → BlockNodeToClientVersion blk → query blk fp result → result → Encoding
- decodeBlockQueryResult ∷ ∀ (fp ∷ k) result. CodecConfig blk → BlockNodeToClientVersion blk → query blk fp result → ∀ s. Decoder s result
- class SerialiseNodeToClient blk a where
- encodeNodeToClient ∷ CodecConfig blk → BlockNodeToClientVersion blk → a → Encoding
- decodeNodeToClient ∷ CodecConfig blk → BlockNodeToClientVersion blk → ∀ s. Decoder s a
- class SerialiseNodeToNode blk a where
- encodeNodeToNode ∷ CodecConfig blk → BlockNodeToNodeVersion blk → a → Encoding
- decodeNodeToNode ∷ CodecConfig blk → BlockNodeToNodeVersion blk → ∀ s. Decoder s a
- class SerialiseResult blk (query ∷ Type → Type → Type) where
- encodeResult ∷ CodecConfig blk → BlockNodeToClientVersion blk → query blk result → result → Encoding
- decodeResult ∷ CodecConfig blk → BlockNodeToClientVersion blk → query blk result → ∀ s. Decoder s result
- defaultDecodeCBORinCBOR ∷ Serialise a ⇒ Decoder s a
- defaultEncodeCBORinCBOR ∷ Serialise a ⇒ a → Encoding
- data Some (f ∷ k → Type) where
Documentation
class SerialiseBlockQueryResult blk (query ∷ Type → k → Type → Type) where Source #
How to serialise the result
of a block query.
The LocalStateQuery
protocol is a node-to-client protocol, hence the
NodeToClientVersion
argument.
Methods
encodeBlockQueryResult ∷ ∀ (fp ∷ k) result. CodecConfig blk → BlockNodeToClientVersion blk → query blk fp result → result → Encoding Source #
decodeBlockQueryResult ∷ ∀ (fp ∷ k) result. CodecConfig blk → BlockNodeToClientVersion blk → query blk fp result → ∀ s. Decoder s result Source #
Instances
SerialiseHFC xs ⇒ SerialiseBlockQueryResult (HardForkBlock xs) BlockQuery Source # | |
Defined in Ouroboros.Consensus.HardFork.Combinator.Serialisation.SerialiseNodeToClient Methods encodeBlockQueryResult ∷ ∀ (fp ∷ QueryFootprint) result. CodecConfig (HardForkBlock xs) → BlockNodeToClientVersion (HardForkBlock xs) → BlockQuery (HardForkBlock xs) fp result → result → Encoding Source # decodeBlockQueryResult ∷ ∀ (fp ∷ QueryFootprint) result. CodecConfig (HardForkBlock xs) → BlockNodeToClientVersion (HardForkBlock xs) → BlockQuery (HardForkBlock xs) fp result → ∀ s. Decoder s result Source # |
class SerialiseNodeToClient blk a where Source #
Serialise a type a
so that it can be sent across the network via
node-to-client protocol.
Minimal complete definition
Nothing
Methods
encodeNodeToClient ∷ CodecConfig blk → BlockNodeToClientVersion blk → a → Encoding Source #
default encodeNodeToClient ∷ Serialise a ⇒ CodecConfig blk → BlockNodeToClientVersion blk → a → Encoding Source #
decodeNodeToClient ∷ CodecConfig blk → BlockNodeToClientVersion blk → ∀ s. Decoder s a Source #
default decodeNodeToClient ∷ Serialise a ⇒ CodecConfig blk → BlockNodeToClientVersion blk → ∀ s. Decoder s a Source #
Instances
class SerialiseNodeToNode blk a where Source #
Serialise a type a
so that it can be sent across network via a
node-to-node protocol.
Minimal complete definition
Nothing
Methods
encodeNodeToNode ∷ CodecConfig blk → BlockNodeToNodeVersion blk → a → Encoding Source #
default encodeNodeToNode ∷ Serialise a ⇒ CodecConfig blk → BlockNodeToNodeVersion blk → a → Encoding Source #
decodeNodeToNode ∷ CodecConfig blk → BlockNodeToNodeVersion blk → ∀ s. Decoder s a Source #
default decodeNodeToNode ∷ Serialise a ⇒ CodecConfig blk → BlockNodeToNodeVersion blk → ∀ s. Decoder s a Source #
Instances
class SerialiseResult blk (query ∷ Type → Type → Type) where Source #
How to serialise the result
of a query.
The LocalStateQuery
protocol is a node-to-client protocol, hence the
NodeToClientVersion
argument.
Methods
encodeResult ∷ CodecConfig blk → BlockNodeToClientVersion blk → query blk result → result → Encoding Source #
decodeResult ∷ CodecConfig blk → BlockNodeToClientVersion blk → query blk result → ∀ s. Decoder s result Source #
Instances
(SerialiseBlockQueryResult blk BlockQuery, Serialise (HeaderHash blk), SerialiseNodeToClient blk (LedgerConfig blk)) ⇒ SerialiseResult blk Query Source # | |
Defined in Ouroboros.Consensus.Ledger.Query Methods encodeResult ∷ CodecConfig blk → BlockNodeToClientVersion blk → Query blk result → result → Encoding Source # decodeResult ∷ CodecConfig blk → BlockNodeToClientVersion blk → Query blk result → ∀ s. Decoder s result Source # |
Defaults
defaultDecodeCBORinCBOR ∷ Serialise a ⇒ Decoder s a Source #
Inverse of defaultEncodeCBORinCBOR
defaultEncodeCBORinCBOR ∷ Serialise a ⇒ a → Encoding Source #
Uses the Serialise
instance, but wraps it in CBOR-in-CBOR.
Use this for the SerialiseNodeToNode
and/or SerialiseNodeToClient
instance of blk
and/or
, which require CBOR-in-CBOR to be
compatible with the corresponding Header
blkSerialised
instance.
Re-exported for convenience
data Some (f ∷ k → Type) where Source #
Instances
Serialise (Some QueryAnytime) Source # | |
Defined in Ouroboros.Consensus.HardFork.Combinator.Ledger.Query Methods encode ∷ Some QueryAnytime → Encoding Source # decode ∷ Decoder s (Some QueryAnytime) Source # encodeList ∷ [Some QueryAnytime] → Encoding Source # decodeList ∷ Decoder s [Some QueryAnytime] Source # |