Skip to content

Commit

Permalink
protocol: add FromCBOR and ToCBOR for PraosState and TPraosState
Browse files Browse the repository at this point in the history
  • Loading branch information
nfrisby committed May 17, 2022
1 parent ea3ffaa commit 28c387f
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 28c387f

Please sign in to comment.