Skip to content

Commit

Permalink
Merge #3745
Browse files Browse the repository at this point in the history
3745: protocol: add FromCBOR and ToCBOR for PraosState and TPraosState r=nfrisby a=nfrisby

Instantiate `FromCBOR` and `ToCBOR` for `PraosState` and `TPraosState`. This is just reusing the existing `Serialise` instance.

Co-authored-by: Nicolas Frisby <nick.frisby@iohk.io>
  • Loading branch information
iohk-bors[bot] and nfrisby committed May 17, 2022
2 parents 163408c + 07015e6 commit fd5fac6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ module Ouroboros.Consensus.Protocol.Praos (
, praosCheckCanForge
) where

import Cardano.Binary (enforceSize, fromCBOR, toCBOR)
import Cardano.Binary (enforceSize, FromCBOR (..), ToCBOR (..))
import qualified Cardano.Crypto.DSIGN as DSIGN
import qualified Cardano.Crypto.KES as KES
import Cardano.Crypto.VRF (hashVerKeyVRF)
Expand Down Expand Up @@ -265,6 +265,12 @@ data PraosState c = PraosState

instance PraosCrypto c => NoThunks (PraosState c)

instance PraosCrypto c => ToCBOR (PraosState c) where
toCBOR = encode

instance PraosCrypto c => FromCBOR (PraosState c) where
fromCBOR = decode

instance PraosCrypto c => Serialise (PraosState c) where
encode
PraosState
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ import GHC.Generics (Generic)
import NoThunks.Class (NoThunks (..))
import Numeric.Natural (Natural)

import Cardano.Binary (enforceSize, fromCBOR, toCBOR)
import Cardano.Binary (enforceSize, FromCBOR (..), ToCBOR (..))
import qualified Cardano.Crypto.VRF as VRF
import Cardano.Slotting.EpochInfo
import Cardano.Slotting.Time (SystemStart (..))
Expand Down Expand Up @@ -266,6 +266,12 @@ instance SL.PraosCrypto c => NoThunks (TPraosState c)
serialisationFormatVersion1 :: VersionNumber
serialisationFormatVersion1 = 1

instance SL.PraosCrypto c => ToCBOR (TPraosState c) where
toCBOR = encode

instance SL.PraosCrypto c => FromCBOR (TPraosState c) where
fromCBOR = decode

instance SL.PraosCrypto c => Serialise (TPraosState c) where
encode (TPraosState slot chainDepState) =
encodeVersion serialisationFormatVersion1 $ mconcat [
Expand Down

0 comments on commit fd5fac6

Please sign in to comment.