{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE TypeFamilies #-}
{-# OPTIONS_GHC -Wno-orphans #-}
module Ouroboros.Consensus.Shelley.Node.Serialisation () where
import Control.Exception (Exception, throw)
import qualified Data.ByteString.Lazy as Lazy
import Data.Typeable (Typeable)
import Cardano.Binary (fromCBOR, toCBOR)
import Codec.Serialise (decode, encode)
import Ouroboros.Network.Block (Serialised, unwrapCBORinCBOR,
wrapCBORinCBOR)
import Ouroboros.Consensus.Block
import Ouroboros.Consensus.HeaderValidation
import Ouroboros.Consensus.Ledger.SupportsMempool (GenTxId)
import Ouroboros.Consensus.Node.Run
import Ouroboros.Consensus.Node.Serialisation
import Ouroboros.Consensus.Storage.Serialisation
import qualified Cardano.Ledger.Shelley.API as SL
import qualified Cardano.Protocol.TPraos.API as SL
import Ouroboros.Consensus.Protocol.Praos (PraosState)
import qualified Ouroboros.Consensus.Protocol.Praos as Praos
import Ouroboros.Consensus.Protocol.TPraos
import Ouroboros.Consensus.Shelley.Eras
import Ouroboros.Consensus.Shelley.Ledger
import Ouroboros.Consensus.Shelley.Ledger.NetworkProtocolVersion ()
import Ouroboros.Consensus.Shelley.Protocol.Abstract
(pHeaderBlockSize, pHeaderSize)
instance ShelleyCompatible proto era => HasBinaryBlockInfo (ShelleyBlock proto era) where
getBinaryBlockInfo :: ShelleyBlock proto era -> BinaryBlockInfo
getBinaryBlockInfo = ShelleyBlock proto era -> BinaryBlockInfo
forall proto era.
ShelleyCompatible proto era =>
ShelleyBlock proto era -> BinaryBlockInfo
shelleyBinaryBlockInfo
instance ShelleyCompatible proto era => SerialiseDiskConstraints (ShelleyBlock proto era)
instance ShelleyCompatible proto era => EncodeDisk (ShelleyBlock proto era) (ShelleyBlock proto era) where
encodeDisk :: CodecConfig (ShelleyBlock proto era)
-> ShelleyBlock proto era -> Encoding
encodeDisk CodecConfig (ShelleyBlock proto era)
_ = ShelleyBlock proto era -> Encoding
forall proto era.
ShelleyCompatible proto era =>
ShelleyBlock proto era -> Encoding
encodeShelleyBlock
instance ShelleyCompatible proto era => DecodeDisk (ShelleyBlock proto era) (Lazy.ByteString -> ShelleyBlock proto era) where
decodeDisk :: CodecConfig (ShelleyBlock proto era)
-> forall s. Decoder s (ByteString -> ShelleyBlock proto era)
decodeDisk CodecConfig (ShelleyBlock proto era)
_ = Decoder s (ByteString -> ShelleyBlock proto era)
forall proto era s.
ShelleyCompatible proto era =>
Decoder s (ByteString -> ShelleyBlock proto era)
decodeShelleyBlock
instance ShelleyCompatible proto era => EncodeDisk (ShelleyBlock proto era) (Header (ShelleyBlock proto era)) where
encodeDisk :: CodecConfig (ShelleyBlock proto era)
-> Header (ShelleyBlock proto era) -> Encoding
encodeDisk CodecConfig (ShelleyBlock proto era)
_ = Header (ShelleyBlock proto era) -> Encoding
forall proto era.
ShelleyCompatible proto era =>
Header (ShelleyBlock proto era) -> Encoding
encodeShelleyHeader
instance ShelleyCompatible proto era => DecodeDisk (ShelleyBlock proto era) (Lazy.ByteString -> Header (ShelleyBlock proto era)) where
decodeDisk :: CodecConfig (ShelleyBlock proto era)
-> forall s.
Decoder s (ByteString -> Header (ShelleyBlock proto era))
decodeDisk CodecConfig (ShelleyBlock proto era)
_ = Decoder s (ByteString -> Header (ShelleyBlock proto era))
forall proto era s.
ShelleyCompatible proto era =>
Decoder s (ByteString -> Header (ShelleyBlock proto era))
decodeShelleyHeader
instance ShelleyCompatible proto era => EncodeDisk (ShelleyBlock proto era) (LedgerState (ShelleyBlock proto era)) where
encodeDisk :: CodecConfig (ShelleyBlock proto era)
-> LedgerState (ShelleyBlock proto era) -> Encoding
encodeDisk CodecConfig (ShelleyBlock proto era)
_ = LedgerState (ShelleyBlock proto era) -> Encoding
forall proto era.
ShelleyCompatible proto era =>
LedgerState (ShelleyBlock proto era) -> Encoding
encodeShelleyLedgerState
instance ShelleyCompatible proto era => DecodeDisk (ShelleyBlock proto era) (LedgerState (ShelleyBlock proto era)) where
decodeDisk :: CodecConfig (ShelleyBlock proto era)
-> forall s. Decoder s (LedgerState (ShelleyBlock proto era))
decodeDisk CodecConfig (ShelleyBlock proto era)
_ = Decoder s (LedgerState (ShelleyBlock proto era))
forall era proto s.
ShelleyCompatible proto era =>
Decoder s (LedgerState (ShelleyBlock proto era))
decodeShelleyLedgerState
instance (ShelleyCompatible proto era, EraCrypto era ~ c, SL.PraosCrypto c) => EncodeDisk (ShelleyBlock proto era) (TPraosState c) where
encodeDisk :: CodecConfig (ShelleyBlock proto era) -> TPraosState c -> Encoding
encodeDisk CodecConfig (ShelleyBlock proto era)
_ = TPraosState c -> Encoding
forall a. Serialise a => a -> Encoding
encode
instance (ShelleyCompatible proto era, EraCrypto era ~ c, SL.PraosCrypto c) => DecodeDisk (ShelleyBlock proto era) (TPraosState c) where
decodeDisk :: CodecConfig (ShelleyBlock proto era)
-> forall s. Decoder s (TPraosState c)
decodeDisk CodecConfig (ShelleyBlock proto era)
_ = Decoder s (TPraosState c)
forall a s. Serialise a => Decoder s a
decode
instance (ShelleyCompatible proto era, EraCrypto era ~ c, Praos.PraosCrypto c) => EncodeDisk (ShelleyBlock proto era) (PraosState c) where
encodeDisk :: CodecConfig (ShelleyBlock proto era) -> PraosState c -> Encoding
encodeDisk CodecConfig (ShelleyBlock proto era)
_ = PraosState c -> Encoding
forall a. Serialise a => a -> Encoding
encode
instance (ShelleyCompatible proto era, EraCrypto era ~ c, Praos.PraosCrypto c) => DecodeDisk (ShelleyBlock proto era) (PraosState c) where
decodeDisk :: CodecConfig (ShelleyBlock proto era)
-> forall s. Decoder s (PraosState c)
decodeDisk CodecConfig (ShelleyBlock proto era)
_ = Decoder s (PraosState c)
forall a s. Serialise a => Decoder s a
decode
instance ShelleyCompatible proto era
=> EncodeDisk (ShelleyBlock proto era) (AnnTip (ShelleyBlock proto era)) where
encodeDisk :: CodecConfig (ShelleyBlock proto era)
-> AnnTip (ShelleyBlock proto era) -> Encoding
encodeDisk CodecConfig (ShelleyBlock proto era)
_ = AnnTip (ShelleyBlock proto era) -> Encoding
forall proto era.
ShelleyCompatible proto era =>
AnnTip (ShelleyBlock proto era) -> Encoding
encodeShelleyAnnTip
instance ShelleyCompatible proto era
=> DecodeDisk (ShelleyBlock proto era) (AnnTip (ShelleyBlock proto era)) where
decodeDisk :: CodecConfig (ShelleyBlock proto era)
-> forall s. Decoder s (AnnTip (ShelleyBlock proto era))
decodeDisk CodecConfig (ShelleyBlock proto era)
_ = Decoder s (AnnTip (ShelleyBlock proto era))
forall proto era s.
ShelleyCompatible proto era =>
Decoder s (AnnTip (ShelleyBlock proto era))
decodeShelleyAnnTip
instance ShelleyCompatible proto era
=> SerialiseNodeToNodeConstraints (ShelleyBlock proto era) where
estimateBlockSize :: Header (ShelleyBlock proto era) -> SizeInBytes
estimateBlockSize Header (ShelleyBlock proto era)
hdr = SizeInBytes
overhead SizeInBytes -> SizeInBytes -> SizeInBytes
forall a. Num a => a -> a -> a
+ SizeInBytes
hdrSize SizeInBytes -> SizeInBytes -> SizeInBytes
forall a. Num a => a -> a -> a
+ SizeInBytes
bodySize
where
overhead :: SizeInBytes
overhead = SizeInBytes
7 SizeInBytes -> SizeInBytes -> SizeInBytes
forall a. Num a => a -> a -> a
+ SizeInBytes
1
bodySize :: SizeInBytes
bodySize = Natural -> SizeInBytes
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Natural -> SizeInBytes)
-> (Header (ShelleyBlock proto era) -> Natural)
-> Header (ShelleyBlock proto era)
-> SizeInBytes
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ShelleyProtocolHeader proto -> Natural
forall proto.
ProtocolHeaderSupportsEnvelope proto =>
ShelleyProtocolHeader proto -> Natural
pHeaderBlockSize (ShelleyProtocolHeader proto -> Natural)
-> (Header (ShelleyBlock proto era) -> ShelleyProtocolHeader proto)
-> Header (ShelleyBlock proto era)
-> Natural
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Header (ShelleyBlock proto era) -> ShelleyProtocolHeader proto
forall proto era.
Header (ShelleyBlock proto era) -> ShelleyProtocolHeader proto
shelleyHeaderRaw (Header (ShelleyBlock proto era) -> SizeInBytes)
-> Header (ShelleyBlock proto era) -> SizeInBytes
forall a b. (a -> b) -> a -> b
$ Header (ShelleyBlock proto era)
hdr
hdrSize :: SizeInBytes
hdrSize = Natural -> SizeInBytes
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Natural -> SizeInBytes)
-> (Header (ShelleyBlock proto era) -> Natural)
-> Header (ShelleyBlock proto era)
-> SizeInBytes
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ShelleyProtocolHeader proto -> Natural
forall proto.
ProtocolHeaderSupportsEnvelope proto =>
ShelleyProtocolHeader proto -> Natural
pHeaderSize (ShelleyProtocolHeader proto -> Natural)
-> (Header (ShelleyBlock proto era) -> ShelleyProtocolHeader proto)
-> Header (ShelleyBlock proto era)
-> Natural
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Header (ShelleyBlock proto era) -> ShelleyProtocolHeader proto
forall proto era.
Header (ShelleyBlock proto era) -> ShelleyProtocolHeader proto
shelleyHeaderRaw (Header (ShelleyBlock proto era) -> SizeInBytes)
-> Header (ShelleyBlock proto era) -> SizeInBytes
forall a b. (a -> b) -> a -> b
$ Header (ShelleyBlock proto era)
hdr
instance ShelleyCompatible proto era
=> SerialiseNodeToNode (ShelleyBlock proto era) (ShelleyBlock proto era) where
encodeNodeToNode :: CodecConfig (ShelleyBlock proto era)
-> BlockNodeToNodeVersion (ShelleyBlock proto era)
-> ShelleyBlock proto era
-> Encoding
encodeNodeToNode CodecConfig (ShelleyBlock proto era)
_ BlockNodeToNodeVersion (ShelleyBlock proto era)
_ = (ShelleyBlock proto era -> Encoding)
-> ShelleyBlock proto era -> Encoding
forall a. (a -> Encoding) -> a -> Encoding
wrapCBORinCBOR ShelleyBlock proto era -> Encoding
forall proto era.
ShelleyCompatible proto era =>
ShelleyBlock proto era -> Encoding
encodeShelleyBlock
decodeNodeToNode :: CodecConfig (ShelleyBlock proto era)
-> BlockNodeToNodeVersion (ShelleyBlock proto era)
-> forall s. Decoder s (ShelleyBlock proto era)
decodeNodeToNode CodecConfig (ShelleyBlock proto era)
_ BlockNodeToNodeVersion (ShelleyBlock proto era)
_ = (forall s. Decoder s (ByteString -> ShelleyBlock proto era))
-> forall s. Decoder s (ShelleyBlock proto era)
forall a.
(forall s. Decoder s (ByteString -> a)) -> forall s. Decoder s a
unwrapCBORinCBOR forall s. Decoder s (ByteString -> ShelleyBlock proto era)
forall proto era s.
ShelleyCompatible proto era =>
Decoder s (ByteString -> ShelleyBlock proto era)
decodeShelleyBlock
instance SerialiseNodeToNode (ShelleyBlock proto era) (Serialised (ShelleyBlock proto era))
instance ShelleyCompatible proto era
=> SerialiseNodeToNode (ShelleyBlock proto era) (Header (ShelleyBlock proto era)) where
encodeNodeToNode :: CodecConfig (ShelleyBlock proto era)
-> BlockNodeToNodeVersion (ShelleyBlock proto era)
-> Header (ShelleyBlock proto era)
-> Encoding
encodeNodeToNode CodecConfig (ShelleyBlock proto era)
_ BlockNodeToNodeVersion (ShelleyBlock proto era)
_ = (Header (ShelleyBlock proto era) -> Encoding)
-> Header (ShelleyBlock proto era) -> Encoding
forall a. (a -> Encoding) -> a -> Encoding
wrapCBORinCBOR Header (ShelleyBlock proto era) -> Encoding
forall proto era.
ShelleyCompatible proto era =>
Header (ShelleyBlock proto era) -> Encoding
encodeShelleyHeader
decodeNodeToNode :: CodecConfig (ShelleyBlock proto era)
-> BlockNodeToNodeVersion (ShelleyBlock proto era)
-> forall s. Decoder s (Header (ShelleyBlock proto era))
decodeNodeToNode CodecConfig (ShelleyBlock proto era)
_ BlockNodeToNodeVersion (ShelleyBlock proto era)
_ = (forall s.
Decoder s (ByteString -> Header (ShelleyBlock proto era)))
-> forall s. Decoder s (Header (ShelleyBlock proto era))
forall a.
(forall s. Decoder s (ByteString -> a)) -> forall s. Decoder s a
unwrapCBORinCBOR forall s. Decoder s (ByteString -> Header (ShelleyBlock proto era))
forall proto era s.
ShelleyCompatible proto era =>
Decoder s (ByteString -> Header (ShelleyBlock proto era))
decodeShelleyHeader
instance SerialiseNodeToNode (ShelleyBlock proto era) (SerialisedHeader (ShelleyBlock proto era)) where
encodeNodeToNode :: CodecConfig (ShelleyBlock proto era)
-> BlockNodeToNodeVersion (ShelleyBlock proto era)
-> SerialisedHeader (ShelleyBlock proto era)
-> Encoding
encodeNodeToNode CodecConfig (ShelleyBlock proto era)
_ BlockNodeToNodeVersion (ShelleyBlock proto era)
_ = SerialisedHeader (ShelleyBlock proto era) -> Encoding
forall blk.
TrivialDependency (NestedCtxt_ blk Header) =>
SerialisedHeader blk -> Encoding
encodeTrivialSerialisedHeader
decodeNodeToNode :: CodecConfig (ShelleyBlock proto era)
-> BlockNodeToNodeVersion (ShelleyBlock proto era)
-> forall s. Decoder s (SerialisedHeader (ShelleyBlock proto era))
decodeNodeToNode CodecConfig (ShelleyBlock proto era)
_ BlockNodeToNodeVersion (ShelleyBlock proto era)
_ = Decoder s (SerialisedHeader (ShelleyBlock proto era))
forall blk s.
TrivialDependency (NestedCtxt_ blk Header) =>
Decoder s (SerialisedHeader blk)
decodeTrivialSerialisedHeader
instance ShelleyCompatible proto era
=> SerialiseNodeToNode (ShelleyBlock proto era) (GenTx (ShelleyBlock proto era)) where
encodeNodeToNode :: CodecConfig (ShelleyBlock proto era)
-> BlockNodeToNodeVersion (ShelleyBlock proto era)
-> GenTx (ShelleyBlock proto era)
-> Encoding
encodeNodeToNode CodecConfig (ShelleyBlock proto era)
_ BlockNodeToNodeVersion (ShelleyBlock proto era)
_ = GenTx (ShelleyBlock proto era) -> Encoding
forall a. ToCBOR a => a -> Encoding
toCBOR
decodeNodeToNode :: CodecConfig (ShelleyBlock proto era)
-> BlockNodeToNodeVersion (ShelleyBlock proto era)
-> forall s. Decoder s (GenTx (ShelleyBlock proto era))
decodeNodeToNode CodecConfig (ShelleyBlock proto era)
_ BlockNodeToNodeVersion (ShelleyBlock proto era)
_ = Decoder s (GenTx (ShelleyBlock proto era))
forall a s. FromCBOR a => Decoder s a
fromCBOR
instance ShelleyCompatible proto era
=> SerialiseNodeToNode (ShelleyBlock proto era) (GenTxId (ShelleyBlock proto era)) where
encodeNodeToNode :: CodecConfig (ShelleyBlock proto era)
-> BlockNodeToNodeVersion (ShelleyBlock proto era)
-> GenTxId (ShelleyBlock proto era)
-> Encoding
encodeNodeToNode CodecConfig (ShelleyBlock proto era)
_ BlockNodeToNodeVersion (ShelleyBlock proto era)
_ = GenTxId (ShelleyBlock proto era) -> Encoding
forall a. ToCBOR a => a -> Encoding
toCBOR
decodeNodeToNode :: CodecConfig (ShelleyBlock proto era)
-> BlockNodeToNodeVersion (ShelleyBlock proto era)
-> forall s. Decoder s (GenTxId (ShelleyBlock proto era))
decodeNodeToNode CodecConfig (ShelleyBlock proto era)
_ BlockNodeToNodeVersion (ShelleyBlock proto era)
_ = Decoder s (GenTxId (ShelleyBlock proto era))
forall a s. FromCBOR a => Decoder s a
fromCBOR
data ShelleyEncoderException era proto =
ShelleyEncoderUnsupportedQuery
(SomeSecond BlockQuery (ShelleyBlock proto era))
ShelleyNodeToClientVersion
deriving (Int -> ShelleyEncoderException era proto -> ShowS
[ShelleyEncoderException era proto] -> ShowS
ShelleyEncoderException era proto -> String
(Int -> ShelleyEncoderException era proto -> ShowS)
-> (ShelleyEncoderException era proto -> String)
-> ([ShelleyEncoderException era proto] -> ShowS)
-> Show (ShelleyEncoderException era proto)
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
forall era proto. Int -> ShelleyEncoderException era proto -> ShowS
forall era proto. [ShelleyEncoderException era proto] -> ShowS
forall era proto. ShelleyEncoderException era proto -> String
showList :: [ShelleyEncoderException era proto] -> ShowS
$cshowList :: forall era proto. [ShelleyEncoderException era proto] -> ShowS
show :: ShelleyEncoderException era proto -> String
$cshow :: forall era proto. ShelleyEncoderException era proto -> String
showsPrec :: Int -> ShelleyEncoderException era proto -> ShowS
$cshowsPrec :: forall era proto. Int -> ShelleyEncoderException era proto -> ShowS
Show)
instance (Typeable era, Typeable proto)
=> Exception (ShelleyEncoderException era proto)
instance ShelleyCompatible proto era
=> SerialiseNodeToClientConstraints (ShelleyBlock proto era)
instance ShelleyCompatible proto era
=> SerialiseNodeToClient (ShelleyBlock proto era) (ShelleyBlock proto era) where
encodeNodeToClient :: CodecConfig (ShelleyBlock proto era)
-> BlockNodeToClientVersion (ShelleyBlock proto era)
-> ShelleyBlock proto era
-> Encoding
encodeNodeToClient CodecConfig (ShelleyBlock proto era)
_ BlockNodeToClientVersion (ShelleyBlock proto era)
_ = (ShelleyBlock proto era -> Encoding)
-> ShelleyBlock proto era -> Encoding
forall a. (a -> Encoding) -> a -> Encoding
wrapCBORinCBOR ShelleyBlock proto era -> Encoding
forall proto era.
ShelleyCompatible proto era =>
ShelleyBlock proto era -> Encoding
encodeShelleyBlock
decodeNodeToClient :: CodecConfig (ShelleyBlock proto era)
-> BlockNodeToClientVersion (ShelleyBlock proto era)
-> forall s. Decoder s (ShelleyBlock proto era)
decodeNodeToClient CodecConfig (ShelleyBlock proto era)
_ BlockNodeToClientVersion (ShelleyBlock proto era)
_ = (forall s. Decoder s (ByteString -> ShelleyBlock proto era))
-> forall s. Decoder s (ShelleyBlock proto era)
forall a.
(forall s. Decoder s (ByteString -> a)) -> forall s. Decoder s a
unwrapCBORinCBOR forall s. Decoder s (ByteString -> ShelleyBlock proto era)
forall proto era s.
ShelleyCompatible proto era =>
Decoder s (ByteString -> ShelleyBlock proto era)
decodeShelleyBlock
instance SerialiseNodeToClient (ShelleyBlock proto era) (Serialised (ShelleyBlock proto era))
instance ShelleyCompatible proto era
=> SerialiseNodeToClient (ShelleyBlock proto era) (GenTx (ShelleyBlock proto era)) where
encodeNodeToClient :: CodecConfig (ShelleyBlock proto era)
-> BlockNodeToClientVersion (ShelleyBlock proto era)
-> GenTx (ShelleyBlock proto era)
-> Encoding
encodeNodeToClient CodecConfig (ShelleyBlock proto era)
_ BlockNodeToClientVersion (ShelleyBlock proto era)
_ = GenTx (ShelleyBlock proto era) -> Encoding
forall a. ToCBOR a => a -> Encoding
toCBOR
decodeNodeToClient :: CodecConfig (ShelleyBlock proto era)
-> BlockNodeToClientVersion (ShelleyBlock proto era)
-> forall s. Decoder s (GenTx (ShelleyBlock proto era))
decodeNodeToClient CodecConfig (ShelleyBlock proto era)
_ BlockNodeToClientVersion (ShelleyBlock proto era)
_ = Decoder s (GenTx (ShelleyBlock proto era))
forall a s. FromCBOR a => Decoder s a
fromCBOR
instance ShelleyCompatible proto era
=> SerialiseNodeToClient (ShelleyBlock proto era) (GenTxId (ShelleyBlock proto era)) where
encodeNodeToClient :: CodecConfig (ShelleyBlock proto era)
-> BlockNodeToClientVersion (ShelleyBlock proto era)
-> GenTxId (ShelleyBlock proto era)
-> Encoding
encodeNodeToClient CodecConfig (ShelleyBlock proto era)
_ BlockNodeToClientVersion (ShelleyBlock proto era)
_ = GenTxId (ShelleyBlock proto era) -> Encoding
forall a. ToCBOR a => a -> Encoding
toCBOR
decodeNodeToClient :: CodecConfig (ShelleyBlock proto era)
-> BlockNodeToClientVersion (ShelleyBlock proto era)
-> forall s. Decoder s (GenTxId (ShelleyBlock proto era))
decodeNodeToClient CodecConfig (ShelleyBlock proto era)
_ BlockNodeToClientVersion (ShelleyBlock proto era)
_ = Decoder s (GenTxId (ShelleyBlock proto era))
forall a s. FromCBOR a => Decoder s a
fromCBOR
instance ShelleyBasedEra era => SerialiseNodeToClient (ShelleyBlock proto era) (SL.ApplyTxError era) where
encodeNodeToClient :: CodecConfig (ShelleyBlock proto era)
-> BlockNodeToClientVersion (ShelleyBlock proto era)
-> ApplyTxError era
-> Encoding
encodeNodeToClient CodecConfig (ShelleyBlock proto era)
_ BlockNodeToClientVersion (ShelleyBlock proto era)
_ = ApplyTxError era -> Encoding
forall a. ToCBOR a => a -> Encoding
toCBOR
decodeNodeToClient :: CodecConfig (ShelleyBlock proto era)
-> BlockNodeToClientVersion (ShelleyBlock proto era)
-> forall s. Decoder s (ApplyTxError era)
decodeNodeToClient CodecConfig (ShelleyBlock proto era)
_ BlockNodeToClientVersion (ShelleyBlock proto era)
_ = Decoder s (ApplyTxError era)
forall a s. FromCBOR a => Decoder s a
fromCBOR
instance ShelleyCompatible proto era
=> SerialiseNodeToClient (ShelleyBlock proto era) (SomeSecond BlockQuery (ShelleyBlock proto era)) where
encodeNodeToClient :: CodecConfig (ShelleyBlock proto era)
-> BlockNodeToClientVersion (ShelleyBlock proto era)
-> SomeSecond BlockQuery (ShelleyBlock proto era)
-> Encoding
encodeNodeToClient CodecConfig (ShelleyBlock proto era)
_ BlockNodeToClientVersion (ShelleyBlock proto era)
version (SomeSecond BlockQuery (ShelleyBlock proto era) b
q)
| BlockQuery (ShelleyBlock proto era) b
-> ShelleyNodeToClientVersion -> Bool
forall proto era result.
BlockQuery (ShelleyBlock proto era) result
-> ShelleyNodeToClientVersion -> Bool
querySupportedVersion BlockQuery (ShelleyBlock proto era) b
q BlockNodeToClientVersion (ShelleyBlock proto era)
ShelleyNodeToClientVersion
version
= BlockQuery (ShelleyBlock proto era) b -> Encoding
forall era proto result.
ShelleyBasedEra era =>
BlockQuery (ShelleyBlock proto era) result -> Encoding
encodeShelleyQuery BlockQuery (ShelleyBlock proto era) b
q
| Bool
otherwise
= ShelleyEncoderException era proto -> Encoding
forall a e. Exception e => e -> a
throw (ShelleyEncoderException era proto -> Encoding)
-> ShelleyEncoderException era proto -> Encoding
forall a b. (a -> b) -> a -> b
$ SomeSecond BlockQuery (ShelleyBlock proto era)
-> ShelleyNodeToClientVersion -> ShelleyEncoderException era proto
forall era proto.
SomeSecond BlockQuery (ShelleyBlock proto era)
-> ShelleyNodeToClientVersion -> ShelleyEncoderException era proto
ShelleyEncoderUnsupportedQuery (BlockQuery (ShelleyBlock proto era) b
-> SomeSecond BlockQuery (ShelleyBlock proto era)
forall (f :: * -> * -> *) a b. f a b -> SomeSecond f a
SomeSecond BlockQuery (ShelleyBlock proto era) b
q) BlockNodeToClientVersion (ShelleyBlock proto era)
ShelleyNodeToClientVersion
version
decodeNodeToClient :: CodecConfig (ShelleyBlock proto era)
-> BlockNodeToClientVersion (ShelleyBlock proto era)
-> forall s.
Decoder s (SomeSecond BlockQuery (ShelleyBlock proto era))
decodeNodeToClient CodecConfig (ShelleyBlock proto era)
_ BlockNodeToClientVersion (ShelleyBlock proto era)
_ = Decoder s (SomeSecond BlockQuery (ShelleyBlock proto era))
forall era s proto.
ShelleyBasedEra era =>
Decoder s (SomeSecond BlockQuery (ShelleyBlock proto era))
decodeShelleyQuery
instance ShelleyCompatible proto era => SerialiseResult (ShelleyBlock proto era) (BlockQuery (ShelleyBlock proto era)) where
encodeResult :: CodecConfig (ShelleyBlock proto era)
-> BlockNodeToClientVersion (ShelleyBlock proto era)
-> BlockQuery (ShelleyBlock proto era) result
-> result
-> Encoding
encodeResult CodecConfig (ShelleyBlock proto era)
_ BlockNodeToClientVersion (ShelleyBlock proto era)
_ = BlockQuery (ShelleyBlock proto era) result -> result -> Encoding
forall proto era result.
ShelleyCompatible proto era =>
BlockQuery (ShelleyBlock proto era) result -> result -> Encoding
encodeShelleyResult
decodeResult :: CodecConfig (ShelleyBlock proto era)
-> BlockNodeToClientVersion (ShelleyBlock proto era)
-> BlockQuery (ShelleyBlock proto era) result
-> forall s. Decoder s result
decodeResult CodecConfig (ShelleyBlock proto era)
_ BlockNodeToClientVersion (ShelleyBlock proto era)
_ = BlockQuery (ShelleyBlock proto era) result -> Decoder s result
forall proto era result.
ShelleyCompatible proto era =>
BlockQuery (ShelleyBlock proto era) result
-> forall s. Decoder s result
decodeShelleyResult
instance ShelleyCompatible proto era => SerialiseNodeToClient (ShelleyBlock proto era) SlotNo where
encodeNodeToClient :: CodecConfig (ShelleyBlock proto era)
-> BlockNodeToClientVersion (ShelleyBlock proto era)
-> SlotNo
-> Encoding
encodeNodeToClient CodecConfig (ShelleyBlock proto era)
_ BlockNodeToClientVersion (ShelleyBlock proto era)
_ = SlotNo -> Encoding
forall a. ToCBOR a => a -> Encoding
toCBOR
decodeNodeToClient :: CodecConfig (ShelleyBlock proto era)
-> BlockNodeToClientVersion (ShelleyBlock proto era)
-> forall s. Decoder s SlotNo
decodeNodeToClient CodecConfig (ShelleyBlock proto era)
_ BlockNodeToClientVersion (ShelleyBlock proto era)
_ = Decoder s SlotNo
forall a s. FromCBOR a => Decoder s a
fromCBOR
instance ShelleyBasedEra era => ReconstructNestedCtxt Header (ShelleyBlock proto era)
instance ShelleyBasedEra era => EncodeDiskDepIx (NestedCtxt Header) (ShelleyBlock proto era)
instance ShelleyCompatible proto era => EncodeDiskDep (NestedCtxt Header) (ShelleyBlock proto era)
instance ShelleyBasedEra era => DecodeDiskDepIx (NestedCtxt Header) (ShelleyBlock proto era)
instance ShelleyCompatible proto era => DecodeDiskDep (NestedCtxt Header) (ShelleyBlock proto era)