{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DerivingVia #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE UndecidableSuperClasses #-}
{-# LANGUAGE ViewPatterns #-}
module Cardano.Protocol.Leios.BlockHeader (
Header (HeaderConstr),
HeaderRaw (..),
HeaderBody (
HeaderBodyConstr,
HeaderBody,
hbBlockNo,
hbSlotNo,
hbPrev,
hbVk,
hbVrfVk,
hbVrfRes,
hbBodySize,
hbBodyHash,
hbOCert,
hbVersionInfo,
hbBlockBodyContainsLeiosCert,
hbEbReferencesAnnouncement
),
HeaderBodyRaw (..),
mkHeader,
mkHeaderBody,
headerBody,
headerSig,
headerHash,
headerSize,
) where
import qualified Cardano.Crypto.Hash as Hash
import qualified Cardano.Crypto.KES as KES
import Cardano.Crypto.Util (
SignableRepresentation (getSignableRepresentation),
)
import qualified Cardano.Crypto.VRF as VRF
import Cardano.Ledger.Binary (
Annotator (..),
DecCBOR (decCBOR),
EncCBOR (..),
decodeFixedSized,
decodeNullStrictMaybe,
decodeRecordNamed,
encodeFixedSized,
encodeListLen,
encodeNullStrictMaybe,
unCBORGroup,
)
import qualified Cardano.Ledger.Binary.Plain as Plain
import Cardano.Ledger.Block (
BlockHeaderVersionInfo,
EbReferencesAnnouncement,
EraBlockHeader (..),
LeiosEraBlockHeader (..),
blockHeaderL,
)
import Cardano.Ledger.Core (Era)
import Cardano.Ledger.Hashes (
EraIndependentBlockBody,
EraIndependentBlockHeader,
EraIndependentBlockHeaderBody,
HASH,
HashAnnotated (..),
SafeToHash (..),
extractHash,
)
import Cardano.Ledger.Keys (KeyRole (BlockIssuer), VKey, hashKey)
import Cardano.Ledger.MemoBytes (
Mem,
MemoBytes,
MemoHashIndex,
Memoized (..),
getMemoRawType,
getMemoSafeHash,
memoRawTypeL,
mkMemoizedEra,
)
import Cardano.Protocol.Crypto (Crypto, KES, VRF)
import Cardano.Protocol.Praos.VRF (InputVRF)
import Cardano.Protocol.TPraos.BlockHeader (PrevHash)
import Cardano.Protocol.TPraos.OCert (OCert)
import Cardano.Slotting.Block (BlockNo)
import Cardano.Slotting.Slot (SlotNo)
import Data.Maybe.Strict (StrictMaybe (..))
import Data.Proxy (Proxy (..))
import Data.Word (Word32)
import GHC.Generics (Generic)
import Lens.Micro (Lens', lens, to)
import NoThunks.Class (NoThunks (..))
data HeaderBodyRaw crypto = HeaderBodyRaw
{ forall crypto. HeaderBodyRaw crypto -> BlockNo
hbrBlockNo :: !BlockNo
, forall crypto. HeaderBodyRaw crypto -> SlotNo
hbrSlotNo :: !SlotNo
, forall crypto. HeaderBodyRaw crypto -> PrevHash
hbrPrev :: !PrevHash
, forall crypto. HeaderBodyRaw crypto -> VKey BlockIssuer
hbrVk :: !(VKey BlockIssuer)
, forall crypto. HeaderBodyRaw crypto -> VerKeyVRF (VRF crypto)
hbrVrfVk :: !(VRF.VerKeyVRF (VRF crypto))
, forall crypto.
HeaderBodyRaw crypto -> CertifiedVRF (VRF crypto) InputVRF
hbrVrfRes :: !(VRF.CertifiedVRF (VRF crypto) InputVRF)
, forall crypto. HeaderBodyRaw crypto -> Word32
hbrBodySize :: !Word32
, forall crypto.
HeaderBodyRaw crypto -> Hash HASH EraIndependentBlockBody
hbrBodyHash :: !(Hash.Hash HASH EraIndependentBlockBody)
, forall crypto. HeaderBodyRaw crypto -> OCert crypto
hbrOCert :: !(OCert crypto)
, forall crypto. HeaderBodyRaw crypto -> BlockHeaderVersionInfo
hbrVersionInfo :: !BlockHeaderVersionInfo
, forall crypto. HeaderBodyRaw crypto -> Bool
hbrBlockBodyContainsLeiosCert :: !Bool
, forall crypto.
HeaderBodyRaw crypto -> StrictMaybe EbReferencesAnnouncement
hbrEbReferencesAnnouncement :: !(StrictMaybe EbReferencesAnnouncement)
}
deriving ((forall x. HeaderBodyRaw crypto -> Rep (HeaderBodyRaw crypto) x)
-> (forall x. Rep (HeaderBodyRaw crypto) x -> HeaderBodyRaw crypto)
-> Generic (HeaderBodyRaw crypto)
forall x. Rep (HeaderBodyRaw crypto) x -> HeaderBodyRaw crypto
forall x. HeaderBodyRaw crypto -> Rep (HeaderBodyRaw crypto) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall crypto x.
Rep (HeaderBodyRaw crypto) x -> HeaderBodyRaw crypto
forall crypto x.
HeaderBodyRaw crypto -> Rep (HeaderBodyRaw crypto) x
$cfrom :: forall crypto x.
HeaderBodyRaw crypto -> Rep (HeaderBodyRaw crypto) x
from :: forall x. HeaderBodyRaw crypto -> Rep (HeaderBodyRaw crypto) x
$cto :: forall crypto x.
Rep (HeaderBodyRaw crypto) x -> HeaderBodyRaw crypto
to :: forall x. Rep (HeaderBodyRaw crypto) x -> HeaderBodyRaw crypto
Generic)
hbrVersionInfoL :: Lens' (HeaderBodyRaw crypto) BlockHeaderVersionInfo
hbrVersionInfoL :: forall crypto (f :: * -> *).
Functor f =>
(BlockHeaderVersionInfo -> f BlockHeaderVersionInfo)
-> HeaderBodyRaw crypto -> f (HeaderBodyRaw crypto)
hbrVersionInfoL = (HeaderBodyRaw crypto -> BlockHeaderVersionInfo)
-> (HeaderBodyRaw crypto
-> BlockHeaderVersionInfo -> HeaderBodyRaw crypto)
-> Lens
(HeaderBodyRaw crypto)
(HeaderBodyRaw crypto)
BlockHeaderVersionInfo
BlockHeaderVersionInfo
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens HeaderBodyRaw crypto -> BlockHeaderVersionInfo
forall crypto. HeaderBodyRaw crypto -> BlockHeaderVersionInfo
hbrVersionInfo (\HeaderBodyRaw crypto
hbr BlockHeaderVersionInfo
vi -> HeaderBodyRaw crypto
hbr {hbrVersionInfo = vi})
hbrEbReferencesAnnouncementL :: Lens' (HeaderBodyRaw crypto) (StrictMaybe EbReferencesAnnouncement)
hbrEbReferencesAnnouncementL :: forall crypto (f :: * -> *).
Functor f =>
(StrictMaybe EbReferencesAnnouncement
-> f (StrictMaybe EbReferencesAnnouncement))
-> HeaderBodyRaw crypto -> f (HeaderBodyRaw crypto)
hbrEbReferencesAnnouncementL =
(HeaderBodyRaw crypto -> StrictMaybe EbReferencesAnnouncement)
-> (HeaderBodyRaw crypto
-> StrictMaybe EbReferencesAnnouncement -> HeaderBodyRaw crypto)
-> Lens
(HeaderBodyRaw crypto)
(HeaderBodyRaw crypto)
(StrictMaybe EbReferencesAnnouncement)
(StrictMaybe EbReferencesAnnouncement)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens HeaderBodyRaw crypto -> StrictMaybe EbReferencesAnnouncement
forall crypto.
HeaderBodyRaw crypto -> StrictMaybe EbReferencesAnnouncement
hbrEbReferencesAnnouncement (\HeaderBodyRaw crypto
hbr StrictMaybe EbReferencesAnnouncement
ma -> HeaderBodyRaw crypto
hbr {hbrEbReferencesAnnouncement = ma})
deriving instance Crypto crypto => Show (HeaderBodyRaw crypto)
deriving instance Crypto crypto => Eq (HeaderBodyRaw crypto)
instance
Crypto crypto =>
NoThunks (HeaderBodyRaw crypto)
newtype HeaderBody crypto = HeaderBodyConstr (MemoBytes (HeaderBodyRaw crypto))
deriving ((forall x. HeaderBody crypto -> Rep (HeaderBody crypto) x)
-> (forall x. Rep (HeaderBody crypto) x -> HeaderBody crypto)
-> Generic (HeaderBody crypto)
forall x. Rep (HeaderBody crypto) x -> HeaderBody crypto
forall x. HeaderBody crypto -> Rep (HeaderBody crypto) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall crypto x. Rep (HeaderBody crypto) x -> HeaderBody crypto
forall crypto x. HeaderBody crypto -> Rep (HeaderBody crypto) x
$cfrom :: forall crypto x. HeaderBody crypto -> Rep (HeaderBody crypto) x
from :: forall x. HeaderBody crypto -> Rep (HeaderBody crypto) x
$cto :: forall crypto x. Rep (HeaderBody crypto) x -> HeaderBody crypto
to :: forall x. Rep (HeaderBody crypto) x -> HeaderBody crypto
Generic)
deriving newtype (HeaderBody crypto -> HeaderBody crypto -> Bool
(HeaderBody crypto -> HeaderBody crypto -> Bool)
-> (HeaderBody crypto -> HeaderBody crypto -> Bool)
-> Eq (HeaderBody crypto)
forall crypto.
Crypto crypto =>
HeaderBody crypto -> HeaderBody crypto -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall crypto.
Crypto crypto =>
HeaderBody crypto -> HeaderBody crypto -> Bool
== :: HeaderBody crypto -> HeaderBody crypto -> Bool
$c/= :: forall crypto.
Crypto crypto =>
HeaderBody crypto -> HeaderBody crypto -> Bool
/= :: HeaderBody crypto -> HeaderBody crypto -> Bool
Eq, Int -> HeaderBody crypto -> ShowS
[HeaderBody crypto] -> ShowS
HeaderBody crypto -> String
(Int -> HeaderBody crypto -> ShowS)
-> (HeaderBody crypto -> String)
-> ([HeaderBody crypto] -> ShowS)
-> Show (HeaderBody crypto)
forall crypto. Crypto crypto => Int -> HeaderBody crypto -> ShowS
forall crypto. Crypto crypto => [HeaderBody crypto] -> ShowS
forall crypto. Crypto crypto => HeaderBody crypto -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall crypto. Crypto crypto => Int -> HeaderBody crypto -> ShowS
showsPrec :: Int -> HeaderBody crypto -> ShowS
$cshow :: forall crypto. Crypto crypto => HeaderBody crypto -> String
show :: HeaderBody crypto -> String
$cshowList :: forall crypto. Crypto crypto => [HeaderBody crypto] -> ShowS
showList :: [HeaderBody crypto] -> ShowS
Show, Context -> HeaderBody crypto -> IO (Maybe ThunkInfo)
Proxy (HeaderBody crypto) -> String
(Context -> HeaderBody crypto -> IO (Maybe ThunkInfo))
-> (Context -> HeaderBody crypto -> IO (Maybe ThunkInfo))
-> (Proxy (HeaderBody crypto) -> String)
-> NoThunks (HeaderBody crypto)
forall crypto.
Crypto crypto =>
Context -> HeaderBody crypto -> IO (Maybe ThunkInfo)
forall crypto. Crypto crypto => Proxy (HeaderBody crypto) -> String
forall a.
(Context -> a -> IO (Maybe ThunkInfo))
-> (Context -> a -> IO (Maybe ThunkInfo))
-> (Proxy a -> String)
-> NoThunks a
$cnoThunks :: forall crypto.
Crypto crypto =>
Context -> HeaderBody crypto -> IO (Maybe ThunkInfo)
noThunks :: Context -> HeaderBody crypto -> IO (Maybe ThunkInfo)
$cwNoThunks :: forall crypto.
Crypto crypto =>
Context -> HeaderBody crypto -> IO (Maybe ThunkInfo)
wNoThunks :: Context -> HeaderBody crypto -> IO (Maybe ThunkInfo)
$cshowTypeOf :: forall crypto. Crypto crypto => Proxy (HeaderBody crypto) -> String
showTypeOf :: Proxy (HeaderBody crypto) -> String
NoThunks, Typeable (HeaderBody crypto)
Typeable (HeaderBody crypto) =>
(HeaderBody crypto -> Encoding)
-> ((forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (HeaderBody crypto) -> Size)
-> ((forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [HeaderBody crypto] -> Size)
-> ToCBOR (HeaderBody crypto)
HeaderBody crypto -> Encoding
(forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [HeaderBody crypto] -> Size
(forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (HeaderBody crypto) -> Size
forall crypto. Typeable crypto => Typeable (HeaderBody crypto)
forall crypto. Typeable crypto => HeaderBody crypto -> Encoding
forall a.
Typeable a =>
(a -> Encoding)
-> ((forall t. ToCBOR t => Proxy t -> Size) -> Proxy a -> Size)
-> ((forall t. ToCBOR t => Proxy t -> Size) -> Proxy [a] -> Size)
-> ToCBOR a
forall crypto.
Typeable crypto =>
(forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [HeaderBody crypto] -> Size
forall crypto.
Typeable crypto =>
(forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (HeaderBody crypto) -> Size
$ctoCBOR :: forall crypto. Typeable crypto => HeaderBody crypto -> Encoding
toCBOR :: HeaderBody crypto -> Encoding
$cencodedSizeExpr :: forall crypto.
Typeable crypto =>
(forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (HeaderBody crypto) -> Size
encodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (HeaderBody crypto) -> Size
$cencodedListSizeExpr :: forall crypto.
Typeable crypto =>
(forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [HeaderBody crypto] -> Size
encodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [HeaderBody crypto] -> Size
Plain.ToCBOR, HeaderBody crypto -> Int
HeaderBody crypto -> ByteString
(HeaderBody crypto -> ByteString)
-> (HeaderBody crypto -> Int)
-> (forall i. Proxy i -> HeaderBody crypto -> SafeHash i)
-> SafeToHash (HeaderBody crypto)
forall i. Proxy i -> HeaderBody crypto -> SafeHash i
forall crypto. HeaderBody crypto -> Int
forall crypto. HeaderBody crypto -> ByteString
forall t.
(t -> ByteString)
-> (t -> Int)
-> (forall i. Proxy i -> t -> SafeHash i)
-> SafeToHash t
forall crypto i. Proxy i -> HeaderBody crypto -> SafeHash i
$coriginalBytes :: forall crypto. HeaderBody crypto -> ByteString
originalBytes :: HeaderBody crypto -> ByteString
$coriginalBytesSize :: forall crypto. HeaderBody crypto -> Int
originalBytesSize :: HeaderBody crypto -> Int
$cmakeHashWithExplicitProxys :: forall crypto i. Proxy i -> HeaderBody crypto -> SafeHash i
makeHashWithExplicitProxys :: forall i. Proxy i -> HeaderBody crypto -> SafeHash i
SafeToHash)
instance Memoized (HeaderBody crypto) where
type RawType (HeaderBody crypto) = HeaderBodyRaw crypto
type instance MemoHashIndex (HeaderBodyRaw crypto) = EraIndependentBlockHeaderBody
instance SignableRepresentation (HeaderBody crypto) where
getSignableRepresentation :: HeaderBody crypto -> ByteString
getSignableRepresentation = HeaderBody crypto -> ByteString
forall t. SafeToHash t => t -> ByteString
originalBytes
pattern HeaderBody ::
BlockNo ->
SlotNo ->
PrevHash ->
VKey BlockIssuer ->
VRF.VerKeyVRF (VRF crypto) ->
VRF.CertifiedVRF (VRF crypto) InputVRF ->
Word32 ->
Hash.Hash HASH EraIndependentBlockBody ->
OCert crypto ->
BlockHeaderVersionInfo ->
Bool ->
StrictMaybe EbReferencesAnnouncement ->
HeaderBody crypto
pattern $mHeaderBody :: forall {r} {crypto}.
HeaderBody crypto
-> (BlockNo
-> SlotNo
-> PrevHash
-> VKey BlockIssuer
-> VerKeyVRF (VRF crypto)
-> CertifiedVRF (VRF crypto) InputVRF
-> Word32
-> Hash HASH EraIndependentBlockBody
-> OCert crypto
-> BlockHeaderVersionInfo
-> Bool
-> StrictMaybe EbReferencesAnnouncement
-> r)
-> ((# #) -> r)
-> r
HeaderBody
{ forall crypto. HeaderBody crypto -> BlockNo
hbBlockNo
, forall crypto. HeaderBody crypto -> SlotNo
hbSlotNo
, forall crypto. HeaderBody crypto -> PrevHash
hbPrev
, forall crypto. HeaderBody crypto -> VKey BlockIssuer
hbVk
, forall crypto. HeaderBody crypto -> VerKeyVRF (VRF crypto)
hbVrfVk
, forall crypto.
HeaderBody crypto -> CertifiedVRF (VRF crypto) InputVRF
hbVrfRes
, forall crypto. HeaderBody crypto -> Word32
hbBodySize
, forall crypto.
HeaderBody crypto -> Hash HASH EraIndependentBlockBody
hbBodyHash
, forall crypto. HeaderBody crypto -> OCert crypto
hbOCert
, forall crypto. HeaderBody crypto -> BlockHeaderVersionInfo
hbVersionInfo
, forall crypto. HeaderBody crypto -> Bool
hbBlockBodyContainsLeiosCert
, forall crypto.
HeaderBody crypto -> StrictMaybe EbReferencesAnnouncement
hbEbReferencesAnnouncement
} <-
( getMemoRawType ->
HeaderBodyRaw
{ hbrBlockNo = hbBlockNo
, hbrSlotNo = hbSlotNo
, hbrPrev = hbPrev
, hbrVk = hbVk
, hbrVrfVk = hbVrfVk
, hbrVrfRes = hbVrfRes
, hbrBodySize = hbBodySize
, hbrBodyHash = hbBodyHash
, hbrOCert = hbOCert
, hbrVersionInfo = hbVersionInfo
, hbrBlockBodyContainsLeiosCert = hbBlockBodyContainsLeiosCert
, hbrEbReferencesAnnouncement = hbEbReferencesAnnouncement
}
)
{-# COMPLETE HeaderBody #-}
mkHeaderBody ::
forall era crypto proxy.
(Era era, Crypto crypto) =>
proxy era ->
HeaderBodyRaw crypto ->
HeaderBody crypto
mkHeaderBody :: forall era crypto (proxy :: * -> *).
(Era era, Crypto crypto) =>
proxy era -> HeaderBodyRaw crypto -> HeaderBody crypto
mkHeaderBody proxy era
_ = forall era t.
(Era era, EncCBOR (RawType t), Memoized t) =>
RawType t -> t
mkMemoizedEra @era
data crypto =
{ forall crypto. HeaderRaw crypto -> HeaderBody crypto
headerRawBody :: !(HeaderBody crypto)
, :: !(KES.SignedKES (KES crypto) (HeaderBody crypto))
}
deriving ((forall x. HeaderRaw crypto -> Rep (HeaderRaw crypto) x)
-> (forall x. Rep (HeaderRaw crypto) x -> HeaderRaw crypto)
-> Generic (HeaderRaw crypto)
forall x. Rep (HeaderRaw crypto) x -> HeaderRaw crypto
forall x. HeaderRaw crypto -> Rep (HeaderRaw crypto) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall crypto x. Rep (HeaderRaw crypto) x -> HeaderRaw crypto
forall crypto x. HeaderRaw crypto -> Rep (HeaderRaw crypto) x
$cfrom :: forall crypto x. HeaderRaw crypto -> Rep (HeaderRaw crypto) x
from :: forall x. HeaderRaw crypto -> Rep (HeaderRaw crypto) x
$cto :: forall crypto x. Rep (HeaderRaw crypto) x -> HeaderRaw crypto
to :: forall x. Rep (HeaderRaw crypto) x -> HeaderRaw crypto
Generic)
deriving instance Crypto crypto => Show (HeaderRaw crypto)
instance Crypto c => Eq (HeaderRaw c) where
HeaderRaw c
h1 == :: HeaderRaw c -> HeaderRaw c -> Bool
== HeaderRaw c
h2 =
HeaderRaw c -> SignedKES (KES c) (HeaderBody c)
forall crypto.
HeaderRaw crypto -> SignedKES (KES crypto) (HeaderBody crypto)
headerRawSig HeaderRaw c
h1 SignedKES (KES c) (HeaderBody c)
-> SignedKES (KES c) (HeaderBody c) -> Bool
forall a. Eq a => a -> a -> Bool
== HeaderRaw c -> SignedKES (KES c) (HeaderBody c)
forall crypto.
HeaderRaw crypto -> SignedKES (KES crypto) (HeaderBody crypto)
headerRawSig HeaderRaw c
h2
Bool -> Bool -> Bool
&& HeaderRaw c -> HeaderBody c
forall crypto. HeaderRaw crypto -> HeaderBody crypto
headerRawBody HeaderRaw c
h1 HeaderBody c -> HeaderBody c -> Bool
forall a. Eq a => a -> a -> Bool
== HeaderRaw c -> HeaderBody c
forall crypto. HeaderRaw crypto -> HeaderBody crypto
headerRawBody HeaderRaw c
h2
instance
Crypto crypto =>
NoThunks (HeaderRaw crypto)
newtype crypto = (MemoBytes (HeaderRaw crypto))
deriving ((forall x. Header crypto -> Rep (Header crypto) x)
-> (forall x. Rep (Header crypto) x -> Header crypto)
-> Generic (Header crypto)
forall x. Rep (Header crypto) x -> Header crypto
forall x. Header crypto -> Rep (Header crypto) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall crypto x. Rep (Header crypto) x -> Header crypto
forall crypto x. Header crypto -> Rep (Header crypto) x
$cfrom :: forall crypto x. Header crypto -> Rep (Header crypto) x
from :: forall x. Header crypto -> Rep (Header crypto) x
$cto :: forall crypto x. Rep (Header crypto) x -> Header crypto
to :: forall x. Rep (Header crypto) x -> Header crypto
Generic)
deriving newtype (Header crypto -> Header crypto -> Bool
(Header crypto -> Header crypto -> Bool)
-> (Header crypto -> Header crypto -> Bool) -> Eq (Header crypto)
forall crypto.
Crypto crypto =>
Header crypto -> Header crypto -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall crypto.
Crypto crypto =>
Header crypto -> Header crypto -> Bool
== :: Header crypto -> Header crypto -> Bool
$c/= :: forall crypto.
Crypto crypto =>
Header crypto -> Header crypto -> Bool
/= :: Header crypto -> Header crypto -> Bool
Eq, Int -> Header crypto -> ShowS
[Header crypto] -> ShowS
Header crypto -> String
(Int -> Header crypto -> ShowS)
-> (Header crypto -> String)
-> ([Header crypto] -> ShowS)
-> Show (Header crypto)
forall crypto. Crypto crypto => Int -> Header crypto -> ShowS
forall crypto. Crypto crypto => [Header crypto] -> ShowS
forall crypto. Crypto crypto => Header crypto -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall crypto. Crypto crypto => Int -> Header crypto -> ShowS
showsPrec :: Int -> Header crypto -> ShowS
$cshow :: forall crypto. Crypto crypto => Header crypto -> String
show :: Header crypto -> String
$cshowList :: forall crypto. Crypto crypto => [Header crypto] -> ShowS
showList :: [Header crypto] -> ShowS
Show, Context -> Header crypto -> IO (Maybe ThunkInfo)
Proxy (Header crypto) -> String
(Context -> Header crypto -> IO (Maybe ThunkInfo))
-> (Context -> Header crypto -> IO (Maybe ThunkInfo))
-> (Proxy (Header crypto) -> String)
-> NoThunks (Header crypto)
forall crypto.
Crypto crypto =>
Context -> Header crypto -> IO (Maybe ThunkInfo)
forall crypto. Crypto crypto => Proxy (Header crypto) -> String
forall a.
(Context -> a -> IO (Maybe ThunkInfo))
-> (Context -> a -> IO (Maybe ThunkInfo))
-> (Proxy a -> String)
-> NoThunks a
$cnoThunks :: forall crypto.
Crypto crypto =>
Context -> Header crypto -> IO (Maybe ThunkInfo)
noThunks :: Context -> Header crypto -> IO (Maybe ThunkInfo)
$cwNoThunks :: forall crypto.
Crypto crypto =>
Context -> Header crypto -> IO (Maybe ThunkInfo)
wNoThunks :: Context -> Header crypto -> IO (Maybe ThunkInfo)
$cshowTypeOf :: forall crypto. Crypto crypto => Proxy (Header crypto) -> String
showTypeOf :: Proxy (Header crypto) -> String
NoThunks, Typeable (Header crypto)
Typeable (Header crypto) =>
(Header crypto -> Encoding)
-> ((forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (Header crypto) -> Size)
-> ((forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [Header crypto] -> Size)
-> ToCBOR (Header crypto)
Header crypto -> Encoding
(forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [Header crypto] -> Size
(forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (Header crypto) -> Size
forall crypto. Typeable crypto => Typeable (Header crypto)
forall crypto. Typeable crypto => Header crypto -> Encoding
forall a.
Typeable a =>
(a -> Encoding)
-> ((forall t. ToCBOR t => Proxy t -> Size) -> Proxy a -> Size)
-> ((forall t. ToCBOR t => Proxy t -> Size) -> Proxy [a] -> Size)
-> ToCBOR a
forall crypto.
Typeable crypto =>
(forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [Header crypto] -> Size
forall crypto.
Typeable crypto =>
(forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (Header crypto) -> Size
$ctoCBOR :: forall crypto. Typeable crypto => Header crypto -> Encoding
toCBOR :: Header crypto -> Encoding
$cencodedSizeExpr :: forall crypto.
Typeable crypto =>
(forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (Header crypto) -> Size
encodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (Header crypto) -> Size
$cencodedListSizeExpr :: forall crypto.
Typeable crypto =>
(forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [Header crypto] -> Size
encodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [Header crypto] -> Size
Plain.ToCBOR, Header crypto -> Int
Header crypto -> ByteString
(Header crypto -> ByteString)
-> (Header crypto -> Int)
-> (forall i. Proxy i -> Header crypto -> SafeHash i)
-> SafeToHash (Header crypto)
forall i. Proxy i -> Header crypto -> SafeHash i
forall crypto. Header crypto -> Int
forall crypto. Header crypto -> ByteString
forall t.
(t -> ByteString)
-> (t -> Int)
-> (forall i. Proxy i -> t -> SafeHash i)
-> SafeToHash t
forall crypto i. Proxy i -> Header crypto -> SafeHash i
$coriginalBytes :: forall crypto. Header crypto -> ByteString
originalBytes :: Header crypto -> ByteString
$coriginalBytesSize :: forall crypto. Header crypto -> Int
originalBytesSize :: Header crypto -> Int
$cmakeHashWithExplicitProxys :: forall crypto i. Proxy i -> Header crypto -> SafeHash i
makeHashWithExplicitProxys :: forall i. Proxy i -> Header crypto -> SafeHash i
SafeToHash)
instance Memoized (Header crypto) where
type RawType (Header crypto) = HeaderRaw crypto
type instance MemoHashIndex (HeaderRaw crypto) = EraIndependentBlockHeader
instance HashAnnotated (Header crypto) EraIndependentBlockHeader where
hashAnnotated :: Header crypto -> SafeHash EraIndependentBlockHeader
hashAnnotated = Header crypto -> SafeHash EraIndependentBlockHeader
Header crypto -> SafeHash (MemoHashIndex (RawType (Header crypto)))
forall t. Memoized t => t -> SafeHash (MemoHashIndex (RawType t))
getMemoSafeHash
mkHeader ::
forall era crypto proxy.
(Era era, Crypto crypto) =>
proxy era ->
HeaderBody crypto ->
KES.SignedKES (KES crypto) (HeaderBody crypto) ->
Header crypto
proxy era
_ HeaderBody crypto
body SignedKES (KES crypto) (HeaderBody crypto)
sig = forall era t.
(Era era, EncCBOR (RawType t), Memoized t) =>
RawType t -> t
mkMemoizedEra @era (RawType (Header crypto) -> Header crypto)
-> RawType (Header crypto) -> Header crypto
forall a b. (a -> b) -> a -> b
$ HeaderBody crypto
-> SignedKES (KES crypto) (HeaderBody crypto) -> HeaderRaw crypto
forall crypto.
HeaderBody crypto
-> SignedKES (KES crypto) (HeaderBody crypto) -> HeaderRaw crypto
HeaderRaw HeaderBody crypto
body SignedKES (KES crypto) (HeaderBody crypto)
sig
headerBody :: Header crypto -> HeaderBody crypto
headerBody :: forall crypto. Header crypto -> HeaderBody crypto
headerBody = HeaderRaw crypto -> HeaderBody crypto
forall crypto. HeaderRaw crypto -> HeaderBody crypto
headerRawBody (HeaderRaw crypto -> HeaderBody crypto)
-> (Header crypto -> HeaderRaw crypto)
-> Header crypto
-> HeaderBody crypto
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Header crypto -> RawType (Header crypto)
Header crypto -> HeaderRaw crypto
forall t. Memoized t => t -> RawType t
getMemoRawType
headerSig :: Header crypto -> KES.SignedKES (KES crypto) (HeaderBody crypto)
= HeaderRaw crypto -> SignedKES (KES crypto) (HeaderBody crypto)
forall crypto.
HeaderRaw crypto -> SignedKES (KES crypto) (HeaderBody crypto)
headerRawSig (HeaderRaw crypto -> SignedKES (KES crypto) (HeaderBody crypto))
-> (Header crypto -> HeaderRaw crypto)
-> Header crypto
-> SignedKES (KES crypto) (HeaderBody crypto)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Header crypto -> RawType (Header crypto)
Header crypto -> HeaderRaw crypto
forall t. Memoized t => t -> RawType t
getMemoRawType
headerSize :: Header crypto -> Int
= Header crypto -> Int
forall t. SafeToHash t => t -> Int
originalBytesSize
headerHash ::
Header crypto ->
Hash.Hash HASH EraIndependentBlockHeader
= SafeHash EraIndependentBlockHeader
-> Hash HASH EraIndependentBlockHeader
forall i. SafeHash i -> Hash HASH i
extractHash (SafeHash EraIndependentBlockHeader
-> Hash HASH EraIndependentBlockHeader)
-> (Header crypto -> SafeHash EraIndependentBlockHeader)
-> Header crypto
-> Hash HASH EraIndependentBlockHeader
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Header crypto -> SafeHash EraIndependentBlockHeader
forall x i. HashAnnotated x i => x -> SafeHash i
hashAnnotated
instance Crypto crypto => EncCBOR (HeaderBodyRaw crypto) where
encCBOR :: HeaderBodyRaw crypto -> Encoding
encCBOR
HeaderBodyRaw
{ BlockNo
hbrBlockNo :: forall crypto. HeaderBodyRaw crypto -> BlockNo
hbrBlockNo :: BlockNo
hbrBlockNo
, SlotNo
hbrSlotNo :: forall crypto. HeaderBodyRaw crypto -> SlotNo
hbrSlotNo :: SlotNo
hbrSlotNo
, PrevHash
hbrPrev :: forall crypto. HeaderBodyRaw crypto -> PrevHash
hbrPrev :: PrevHash
hbrPrev
, VKey BlockIssuer
hbrVk :: forall crypto. HeaderBodyRaw crypto -> VKey BlockIssuer
hbrVk :: VKey BlockIssuer
hbrVk
, VerKeyVRF (VRF crypto)
hbrVrfVk :: forall crypto. HeaderBodyRaw crypto -> VerKeyVRF (VRF crypto)
hbrVrfVk :: VerKeyVRF (VRF crypto)
hbrVrfVk
, CertifiedVRF (VRF crypto) InputVRF
hbrVrfRes :: forall crypto.
HeaderBodyRaw crypto -> CertifiedVRF (VRF crypto) InputVRF
hbrVrfRes :: CertifiedVRF (VRF crypto) InputVRF
hbrVrfRes
, Word32
hbrBodySize :: forall crypto. HeaderBodyRaw crypto -> Word32
hbrBodySize :: Word32
hbrBodySize
, Hash HASH EraIndependentBlockBody
hbrBodyHash :: forall crypto.
HeaderBodyRaw crypto -> Hash HASH EraIndependentBlockBody
hbrBodyHash :: Hash HASH EraIndependentBlockBody
hbrBodyHash
, OCert crypto
hbrOCert :: forall crypto. HeaderBodyRaw crypto -> OCert crypto
hbrOCert :: OCert crypto
hbrOCert
, BlockHeaderVersionInfo
hbrVersionInfo :: forall crypto. HeaderBodyRaw crypto -> BlockHeaderVersionInfo
hbrVersionInfo :: BlockHeaderVersionInfo
hbrVersionInfo
, Bool
hbrBlockBodyContainsLeiosCert :: forall crypto. HeaderBodyRaw crypto -> Bool
hbrBlockBodyContainsLeiosCert :: Bool
hbrBlockBodyContainsLeiosCert
, StrictMaybe EbReferencesAnnouncement
hbrEbReferencesAnnouncement :: forall crypto.
HeaderBodyRaw crypto -> StrictMaybe EbReferencesAnnouncement
hbrEbReferencesAnnouncement :: StrictMaybe EbReferencesAnnouncement
hbrEbReferencesAnnouncement
} =
Word -> Encoding
encodeListLen Word
12
Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> BlockNo -> Encoding
forall a. EncCBOR a => a -> Encoding
encCBOR BlockNo
hbrBlockNo
Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> SlotNo -> Encoding
forall a. EncCBOR a => a -> Encoding
encCBOR SlotNo
hbrSlotNo
Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> PrevHash -> Encoding
forall a. EncCBOR a => a -> Encoding
encCBOR PrevHash
hbrPrev
Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> VKey BlockIssuer -> Encoding
forall a. EncCBOR a => a -> Encoding
encCBOR VKey BlockIssuer
hbrVk
Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> VerKeyVRF (VRF crypto) -> Encoding
forall a. FixedSizeCodec a => a -> Encoding
encodeFixedSized VerKeyVRF (VRF crypto)
hbrVrfVk
Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> CertifiedVRF (VRF crypto) InputVRF -> Encoding
forall a. EncCBOR a => a -> Encoding
encCBOR CertifiedVRF (VRF crypto) InputVRF
hbrVrfRes
Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> Word32 -> Encoding
forall a. EncCBOR a => a -> Encoding
encCBOR Word32
hbrBodySize
Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> Hash HASH EraIndependentBlockBody -> Encoding
forall a. EncCBOR a => a -> Encoding
encCBOR Hash HASH EraIndependentBlockBody
hbrBodyHash
Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> OCert crypto -> Encoding
forall a. EncCBOR a => a -> Encoding
encCBOR OCert crypto
hbrOCert
Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> BlockHeaderVersionInfo -> Encoding
forall a. EncCBOR a => a -> Encoding
encCBOR BlockHeaderVersionInfo
hbrVersionInfo
Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> Bool -> Encoding
forall a. EncCBOR a => a -> Encoding
encCBOR Bool
hbrBlockBodyContainsLeiosCert
Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> (EbReferencesAnnouncement -> Encoding)
-> StrictMaybe EbReferencesAnnouncement -> Encoding
forall a. (a -> Encoding) -> StrictMaybe a -> Encoding
encodeNullStrictMaybe EbReferencesAnnouncement -> Encoding
forall a. EncCBOR a => a -> Encoding
encCBOR StrictMaybe EbReferencesAnnouncement
hbrEbReferencesAnnouncement
instance Crypto crypto => DecCBOR (HeaderBodyRaw crypto) where
decCBOR :: forall s. Decoder s (HeaderBodyRaw crypto)
decCBOR =
Text
-> (HeaderBodyRaw crypto -> Int)
-> Decoder s (HeaderBodyRaw crypto)
-> Decoder s (HeaderBodyRaw crypto)
forall a s. Text -> (a -> Int) -> Decoder s a -> Decoder s a
decodeRecordNamed Text
"HeaderBody" (Int -> HeaderBodyRaw crypto -> Int
forall a b. a -> b -> a
const Int
12) (Decoder s (HeaderBodyRaw crypto)
-> Decoder s (HeaderBodyRaw crypto))
-> Decoder s (HeaderBodyRaw crypto)
-> Decoder s (HeaderBodyRaw crypto)
forall a b. (a -> b) -> a -> b
$
BlockNo
-> SlotNo
-> PrevHash
-> VKey BlockIssuer
-> VerKeyVRF (VRF crypto)
-> CertifiedVRF (VRF crypto) InputVRF
-> Word32
-> Hash HASH EraIndependentBlockBody
-> OCert crypto
-> BlockHeaderVersionInfo
-> Bool
-> StrictMaybe EbReferencesAnnouncement
-> HeaderBodyRaw crypto
forall crypto.
BlockNo
-> SlotNo
-> PrevHash
-> VKey BlockIssuer
-> VerKeyVRF (VRF crypto)
-> CertifiedVRF (VRF crypto) InputVRF
-> Word32
-> Hash HASH EraIndependentBlockBody
-> OCert crypto
-> BlockHeaderVersionInfo
-> Bool
-> StrictMaybe EbReferencesAnnouncement
-> HeaderBodyRaw crypto
HeaderBodyRaw
(BlockNo
-> SlotNo
-> PrevHash
-> VKey BlockIssuer
-> VerKeyVRF (VRF crypto)
-> CertifiedVRF (VRF crypto) InputVRF
-> Word32
-> Hash HASH EraIndependentBlockBody
-> OCert crypto
-> BlockHeaderVersionInfo
-> Bool
-> StrictMaybe EbReferencesAnnouncement
-> HeaderBodyRaw crypto)
-> Decoder s BlockNo
-> Decoder
s
(SlotNo
-> PrevHash
-> VKey BlockIssuer
-> VerKeyVRF (VRF crypto)
-> CertifiedVRF (VRF crypto) InputVRF
-> Word32
-> Hash HASH EraIndependentBlockBody
-> OCert crypto
-> BlockHeaderVersionInfo
-> Bool
-> StrictMaybe EbReferencesAnnouncement
-> HeaderBodyRaw crypto)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Decoder s BlockNo
forall s. Decoder s BlockNo
forall a s. DecCBOR a => Decoder s a
decCBOR
Decoder
s
(SlotNo
-> PrevHash
-> VKey BlockIssuer
-> VerKeyVRF (VRF crypto)
-> CertifiedVRF (VRF crypto) InputVRF
-> Word32
-> Hash HASH EraIndependentBlockBody
-> OCert crypto
-> BlockHeaderVersionInfo
-> Bool
-> StrictMaybe EbReferencesAnnouncement
-> HeaderBodyRaw crypto)
-> Decoder s SlotNo
-> Decoder
s
(PrevHash
-> VKey BlockIssuer
-> VerKeyVRF (VRF crypto)
-> CertifiedVRF (VRF crypto) InputVRF
-> Word32
-> Hash HASH EraIndependentBlockBody
-> OCert crypto
-> BlockHeaderVersionInfo
-> Bool
-> StrictMaybe EbReferencesAnnouncement
-> HeaderBodyRaw crypto)
forall a b. Decoder s (a -> b) -> Decoder s a -> Decoder s b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Decoder s SlotNo
forall s. Decoder s SlotNo
forall a s. DecCBOR a => Decoder s a
decCBOR
Decoder
s
(PrevHash
-> VKey BlockIssuer
-> VerKeyVRF (VRF crypto)
-> CertifiedVRF (VRF crypto) InputVRF
-> Word32
-> Hash HASH EraIndependentBlockBody
-> OCert crypto
-> BlockHeaderVersionInfo
-> Bool
-> StrictMaybe EbReferencesAnnouncement
-> HeaderBodyRaw crypto)
-> Decoder s PrevHash
-> Decoder
s
(VKey BlockIssuer
-> VerKeyVRF (VRF crypto)
-> CertifiedVRF (VRF crypto) InputVRF
-> Word32
-> Hash HASH EraIndependentBlockBody
-> OCert crypto
-> BlockHeaderVersionInfo
-> Bool
-> StrictMaybe EbReferencesAnnouncement
-> HeaderBodyRaw crypto)
forall a b. Decoder s (a -> b) -> Decoder s a -> Decoder s b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Decoder s PrevHash
forall s. Decoder s PrevHash
forall a s. DecCBOR a => Decoder s a
decCBOR
Decoder
s
(VKey BlockIssuer
-> VerKeyVRF (VRF crypto)
-> CertifiedVRF (VRF crypto) InputVRF
-> Word32
-> Hash HASH EraIndependentBlockBody
-> OCert crypto
-> BlockHeaderVersionInfo
-> Bool
-> StrictMaybe EbReferencesAnnouncement
-> HeaderBodyRaw crypto)
-> Decoder s (VKey BlockIssuer)
-> Decoder
s
(VerKeyVRF (VRF crypto)
-> CertifiedVRF (VRF crypto) InputVRF
-> Word32
-> Hash HASH EraIndependentBlockBody
-> OCert crypto
-> BlockHeaderVersionInfo
-> Bool
-> StrictMaybe EbReferencesAnnouncement
-> HeaderBodyRaw crypto)
forall a b. Decoder s (a -> b) -> Decoder s a -> Decoder s b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Decoder s (VKey BlockIssuer)
forall s. Decoder s (VKey BlockIssuer)
forall a s. DecCBOR a => Decoder s a
decCBOR
Decoder
s
(VerKeyVRF (VRF crypto)
-> CertifiedVRF (VRF crypto) InputVRF
-> Word32
-> Hash HASH EraIndependentBlockBody
-> OCert crypto
-> BlockHeaderVersionInfo
-> Bool
-> StrictMaybe EbReferencesAnnouncement
-> HeaderBodyRaw crypto)
-> Decoder s (VerKeyVRF (VRF crypto))
-> Decoder
s
(CertifiedVRF (VRF crypto) InputVRF
-> Word32
-> Hash HASH EraIndependentBlockBody
-> OCert crypto
-> BlockHeaderVersionInfo
-> Bool
-> StrictMaybe EbReferencesAnnouncement
-> HeaderBodyRaw crypto)
forall a b. Decoder s (a -> b) -> Decoder s a -> Decoder s b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Decoder s (VerKeyVRF (VRF crypto))
forall a s. FixedSizeCodec a => Decoder s a
decodeFixedSized
Decoder
s
(CertifiedVRF (VRF crypto) InputVRF
-> Word32
-> Hash HASH EraIndependentBlockBody
-> OCert crypto
-> BlockHeaderVersionInfo
-> Bool
-> StrictMaybe EbReferencesAnnouncement
-> HeaderBodyRaw crypto)
-> Decoder s (CertifiedVRF (VRF crypto) InputVRF)
-> Decoder
s
(Word32
-> Hash HASH EraIndependentBlockBody
-> OCert crypto
-> BlockHeaderVersionInfo
-> Bool
-> StrictMaybe EbReferencesAnnouncement
-> HeaderBodyRaw crypto)
forall a b. Decoder s (a -> b) -> Decoder s a -> Decoder s b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Decoder s (CertifiedVRF (VRF crypto) InputVRF)
forall s. Decoder s (CertifiedVRF (VRF crypto) InputVRF)
forall a s. DecCBOR a => Decoder s a
decCBOR
Decoder
s
(Word32
-> Hash HASH EraIndependentBlockBody
-> OCert crypto
-> BlockHeaderVersionInfo
-> Bool
-> StrictMaybe EbReferencesAnnouncement
-> HeaderBodyRaw crypto)
-> Decoder s Word32
-> Decoder
s
(Hash HASH EraIndependentBlockBody
-> OCert crypto
-> BlockHeaderVersionInfo
-> Bool
-> StrictMaybe EbReferencesAnnouncement
-> HeaderBodyRaw crypto)
forall a b. Decoder s (a -> b) -> Decoder s a -> Decoder s b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Decoder s Word32
forall s. Decoder s Word32
forall a s. DecCBOR a => Decoder s a
decCBOR
Decoder
s
(Hash HASH EraIndependentBlockBody
-> OCert crypto
-> BlockHeaderVersionInfo
-> Bool
-> StrictMaybe EbReferencesAnnouncement
-> HeaderBodyRaw crypto)
-> Decoder s (Hash HASH EraIndependentBlockBody)
-> Decoder
s
(OCert crypto
-> BlockHeaderVersionInfo
-> Bool
-> StrictMaybe EbReferencesAnnouncement
-> HeaderBodyRaw crypto)
forall a b. Decoder s (a -> b) -> Decoder s a -> Decoder s b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Decoder s (Hash HASH EraIndependentBlockBody)
forall s. Decoder s (Hash HASH EraIndependentBlockBody)
forall a s. DecCBOR a => Decoder s a
decCBOR
Decoder
s
(OCert crypto
-> BlockHeaderVersionInfo
-> Bool
-> StrictMaybe EbReferencesAnnouncement
-> HeaderBodyRaw crypto)
-> Decoder s (OCert crypto)
-> Decoder
s
(BlockHeaderVersionInfo
-> Bool
-> StrictMaybe EbReferencesAnnouncement
-> HeaderBodyRaw crypto)
forall a b. Decoder s (a -> b) -> Decoder s a -> Decoder s b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (CBORGroup (OCert crypto) -> OCert crypto
forall a. CBORGroup a -> a
unCBORGroup (CBORGroup (OCert crypto) -> OCert crypto)
-> Decoder s (CBORGroup (OCert crypto)) -> Decoder s (OCert crypto)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Decoder s (CBORGroup (OCert crypto))
forall s. Decoder s (CBORGroup (OCert crypto))
forall a s. DecCBOR a => Decoder s a
decCBOR)
Decoder
s
(BlockHeaderVersionInfo
-> Bool
-> StrictMaybe EbReferencesAnnouncement
-> HeaderBodyRaw crypto)
-> Decoder s BlockHeaderVersionInfo
-> Decoder
s
(Bool
-> StrictMaybe EbReferencesAnnouncement -> HeaderBodyRaw crypto)
forall a b. Decoder s (a -> b) -> Decoder s a -> Decoder s b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Decoder s BlockHeaderVersionInfo
forall s. Decoder s BlockHeaderVersionInfo
forall a s. DecCBOR a => Decoder s a
decCBOR
Decoder
s
(Bool
-> StrictMaybe EbReferencesAnnouncement -> HeaderBodyRaw crypto)
-> Decoder s Bool
-> Decoder
s (StrictMaybe EbReferencesAnnouncement -> HeaderBodyRaw crypto)
forall a b. Decoder s (a -> b) -> Decoder s a -> Decoder s b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Decoder s Bool
forall s. Decoder s Bool
forall a s. DecCBOR a => Decoder s a
decCBOR
Decoder
s (StrictMaybe EbReferencesAnnouncement -> HeaderBodyRaw crypto)
-> Decoder s (StrictMaybe EbReferencesAnnouncement)
-> Decoder s (HeaderBodyRaw crypto)
forall a b. Decoder s (a -> b) -> Decoder s a -> Decoder s b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Decoder s EbReferencesAnnouncement
-> Decoder s (StrictMaybe EbReferencesAnnouncement)
forall s a. Decoder s a -> Decoder s (StrictMaybe a)
decodeNullStrictMaybe Decoder s EbReferencesAnnouncement
forall s. Decoder s EbReferencesAnnouncement
forall a s. DecCBOR a => Decoder s a
decCBOR
instance Crypto crypto => DecCBOR (Annotator (HeaderBodyRaw crypto)) where
decCBOR :: forall s. Decoder s (Annotator (HeaderBodyRaw crypto))
decCBOR = HeaderBodyRaw crypto -> Annotator (HeaderBodyRaw crypto)
forall a. a -> Annotator a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (HeaderBodyRaw crypto -> Annotator (HeaderBodyRaw crypto))
-> Decoder s (HeaderBodyRaw crypto)
-> Decoder s (Annotator (HeaderBodyRaw crypto))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Decoder s (HeaderBodyRaw crypto)
forall s. Decoder s (HeaderBodyRaw crypto)
forall a s. DecCBOR a => Decoder s a
decCBOR
instance Crypto crypto => EncCBOR (HeaderBody crypto)
deriving via
Mem (HeaderBodyRaw crypto)
instance
Crypto crypto => DecCBOR (Annotator (HeaderBody crypto))
instance Crypto crypto => EncCBOR (HeaderRaw crypto) where
encCBOR :: HeaderRaw crypto -> Encoding
encCBOR (HeaderRaw HeaderBody crypto
body SignedKES (KES crypto) (HeaderBody crypto)
sig) =
Word -> Encoding
encodeListLen Word
2 Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> HeaderBody crypto -> Encoding
forall a. EncCBOR a => a -> Encoding
encCBOR HeaderBody crypto
body Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> SignedKES (KES crypto) (HeaderBody crypto) -> Encoding
forall a. FixedSizeCodec a => a -> Encoding
encodeFixedSized SignedKES (KES crypto) (HeaderBody crypto)
sig
instance Crypto crypto => DecCBOR (Annotator (HeaderRaw crypto)) where
decCBOR :: forall s. Decoder s (Annotator (HeaderRaw crypto))
decCBOR =
Text
-> (Annotator (HeaderRaw crypto) -> Int)
-> Decoder s (Annotator (HeaderRaw crypto))
-> Decoder s (Annotator (HeaderRaw crypto))
forall a s. Text -> (a -> Int) -> Decoder s a -> Decoder s a
decodeRecordNamed Text
"HeaderRaw" (Int -> Annotator (HeaderRaw crypto) -> Int
forall a b. a -> b -> a
const Int
2) (Decoder s (Annotator (HeaderRaw crypto))
-> Decoder s (Annotator (HeaderRaw crypto)))
-> Decoder s (Annotator (HeaderRaw crypto))
-> Decoder s (Annotator (HeaderRaw crypto))
forall a b. (a -> b) -> a -> b
$ do
body <- Decoder s (Annotator (HeaderBody crypto))
forall s. Decoder s (Annotator (HeaderBody crypto))
forall a s. DecCBOR a => Decoder s a
decCBOR
sig <- decodeFixedSized
pure $ HeaderRaw <$> body <*> pure sig
instance Crypto c => EncCBOR (Header c)
deriving via
Mem (HeaderRaw c)
instance
Crypto c => DecCBOR (Annotator (Header c))
headerBodyL :: (Era era, Crypto c) => proxy era -> Lens' (Header c) (HeaderBody c)
headerBodyL :: forall era c (proxy :: * -> *).
(Era era, Crypto c) =>
proxy era -> Lens' (Header c) (HeaderBody c)
headerBodyL proxy era
p = (Header c -> HeaderBody c)
-> (Header c -> HeaderBody c -> Header c)
-> Lens (Header c) (Header c) (HeaderBody c) (HeaderBody c)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens Header c -> HeaderBody c
forall crypto. Header crypto -> HeaderBody crypto
headerBody (\Header c
h HeaderBody c
b -> proxy era
-> HeaderBody c -> SignedKES (KES c) (HeaderBody c) -> Header c
forall era crypto (proxy :: * -> *).
(Era era, Crypto crypto) =>
proxy era
-> HeaderBody crypto
-> SignedKES (KES crypto) (HeaderBody crypto)
-> Header crypto
mkHeader proxy era
p HeaderBody c
b (Header c -> SignedKES (KES c) (HeaderBody c)
forall crypto.
Header crypto -> SignedKES (KES crypto) (HeaderBody crypto)
headerSig Header c
h))
headerBodyRawL ::
forall era c proxy.
(Era era, Crypto c) =>
proxy era ->
Lens' (Header c) (HeaderBodyRaw c)
headerBodyRawL :: forall era c (proxy :: * -> *).
(Era era, Crypto c) =>
proxy era -> Lens' (Header c) (HeaderBodyRaw c)
headerBodyRawL proxy era
p = proxy era -> Lens' (Header c) (HeaderBody c)
forall era c (proxy :: * -> *).
(Era era, Crypto c) =>
proxy era -> Lens' (Header c) (HeaderBody c)
headerBodyL proxy era
p ((HeaderBody c -> f (HeaderBody c)) -> Header c -> f (Header c))
-> ((HeaderBodyRaw c -> f (HeaderBodyRaw c))
-> HeaderBody c -> f (HeaderBody c))
-> (HeaderBodyRaw c -> f (HeaderBodyRaw c))
-> Header c
-> f (Header c)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall era t.
(Era era, EncCBOR (RawType t), Memoized t) =>
Lens' t (RawType t)
memoRawTypeL @era
instance (Crypto c, Era era) => EraBlockHeader (Header c) era where
blockHeaderSizeBlockHeaderG :: SimpleGetter (Block (Header c) era) Int
blockHeaderSizeBlockHeaderG =
(Header c -> Const r (Header c))
-> Block (Header c) era -> Const r (Block (Header c) era)
forall h era (f :: * -> *).
Functor f =>
(h -> f h) -> Block h era -> f (Block h era)
blockHeaderL ((Header c -> Const r (Header c))
-> Block (Header c) era -> Const r (Block (Header c) era))
-> ((Int -> Const r Int) -> Header c -> Const r (Header c))
-> (Int -> Const r Int)
-> Block (Header c) era
-> Const r (Block (Header c) era)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Header c -> Int) -> SimpleGetter (Header c) Int
forall s a. (s -> a) -> SimpleGetter s a
to Header c -> Int
forall t. SafeToHash t => t -> Int
originalBytesSize
blockIssuerBlockHeaderG :: SimpleGetter (Block (Header c) era) (KeyHash BlockIssuer)
blockIssuerBlockHeaderG =
(Header c -> Const r (Header c))
-> Block (Header c) era -> Const r (Block (Header c) era)
forall h era (f :: * -> *).
Functor f =>
(h -> f h) -> Block h era -> f (Block h era)
blockHeaderL ((Header c -> Const r (Header c))
-> Block (Header c) era -> Const r (Block (Header c) era))
-> ((KeyHash BlockIssuer -> Const r (KeyHash BlockIssuer))
-> Header c -> Const r (Header c))
-> (KeyHash BlockIssuer -> Const r (KeyHash BlockIssuer))
-> Block (Header c) era
-> Const r (Block (Header c) era)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Proxy era -> Lens' (Header c) (HeaderBody c)
forall era c (proxy :: * -> *).
(Era era, Crypto c) =>
proxy era -> Lens' (Header c) (HeaderBody c)
headerBodyL (forall t. Proxy t
forall {k} (t :: k). Proxy t
Proxy @era) ((HeaderBody c -> Const r (HeaderBody c))
-> Header c -> Const r (Header c))
-> ((KeyHash BlockIssuer -> Const r (KeyHash BlockIssuer))
-> HeaderBody c -> Const r (HeaderBody c))
-> (KeyHash BlockIssuer -> Const r (KeyHash BlockIssuer))
-> Header c
-> Const r (Header c)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (HeaderBody c -> KeyHash BlockIssuer)
-> SimpleGetter (HeaderBody c) (KeyHash BlockIssuer)
forall s a. (s -> a) -> SimpleGetter s a
to (VKey BlockIssuer -> KeyHash BlockIssuer
forall (kd :: KeyRole). VKey kd -> KeyHash kd
hashKey (VKey BlockIssuer -> KeyHash BlockIssuer)
-> (HeaderBody c -> VKey BlockIssuer)
-> HeaderBody c
-> KeyHash BlockIssuer
forall b c a. (b -> c) -> (a -> b) -> a -> c
. HeaderBody c -> VKey BlockIssuer
forall crypto. HeaderBody crypto -> VKey BlockIssuer
hbVk)
blockBodySizeBlockHeaderL :: Lens' (Block (Header c) era) Word32
blockBodySizeBlockHeaderL =
(Header c -> f (Header c))
-> Block (Header c) era -> f (Block (Header c) era)
forall h era (f :: * -> *).
Functor f =>
(h -> f h) -> Block h era -> f (Block h era)
blockHeaderL ((Header c -> f (Header c))
-> Block (Header c) era -> f (Block (Header c) era))
-> ((Word32 -> f Word32) -> Header c -> f (Header c))
-> (Word32 -> f Word32)
-> Block (Header c) era
-> f (Block (Header c) era)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Proxy era -> Lens' (Header c) (HeaderBodyRaw c)
forall era c (proxy :: * -> *).
(Era era, Crypto c) =>
proxy era -> Lens' (Header c) (HeaderBodyRaw c)
headerBodyRawL (forall t. Proxy t
forall {k} (t :: k). Proxy t
Proxy @era) ((HeaderBodyRaw c -> f (HeaderBodyRaw c))
-> Header c -> f (Header c))
-> ((Word32 -> f Word32) -> HeaderBodyRaw c -> f (HeaderBodyRaw c))
-> (Word32 -> f Word32)
-> Header c
-> f (Header c)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (HeaderBodyRaw c -> Word32)
-> (HeaderBodyRaw c -> Word32 -> HeaderBodyRaw c)
-> Lens (HeaderBodyRaw c) (HeaderBodyRaw c) Word32 Word32
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens HeaderBodyRaw c -> Word32
forall crypto. HeaderBodyRaw crypto -> Word32
hbrBodySize (\HeaderBodyRaw c
hbr Word32
sz -> HeaderBodyRaw c
hbr {hbrBodySize = sz})
blockBodyHashBlockHeaderL :: Lens' (Block (Header c) era) (Hash HASH EraIndependentBlockBody)
blockBodyHashBlockHeaderL =
(Header c -> f (Header c))
-> Block (Header c) era -> f (Block (Header c) era)
forall h era (f :: * -> *).
Functor f =>
(h -> f h) -> Block h era -> f (Block h era)
blockHeaderL ((Header c -> f (Header c))
-> Block (Header c) era -> f (Block (Header c) era))
-> ((Hash HASH EraIndependentBlockBody
-> f (Hash HASH EraIndependentBlockBody))
-> Header c -> f (Header c))
-> (Hash HASH EraIndependentBlockBody
-> f (Hash HASH EraIndependentBlockBody))
-> Block (Header c) era
-> f (Block (Header c) era)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Proxy era -> Lens' (Header c) (HeaderBodyRaw c)
forall era c (proxy :: * -> *).
(Era era, Crypto c) =>
proxy era -> Lens' (Header c) (HeaderBodyRaw c)
headerBodyRawL (forall t. Proxy t
forall {k} (t :: k). Proxy t
Proxy @era) ((HeaderBodyRaw c -> f (HeaderBodyRaw c))
-> Header c -> f (Header c))
-> ((Hash HASH EraIndependentBlockBody
-> f (Hash HASH EraIndependentBlockBody))
-> HeaderBodyRaw c -> f (HeaderBodyRaw c))
-> (Hash HASH EraIndependentBlockBody
-> f (Hash HASH EraIndependentBlockBody))
-> Header c
-> f (Header c)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (HeaderBodyRaw c -> Hash HASH EraIndependentBlockBody)
-> (HeaderBodyRaw c
-> Hash HASH EraIndependentBlockBody -> HeaderBodyRaw c)
-> Lens
(HeaderBodyRaw c)
(HeaderBodyRaw c)
(Hash HASH EraIndependentBlockBody)
(Hash HASH EraIndependentBlockBody)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens HeaderBodyRaw c -> Hash HASH EraIndependentBlockBody
forall crypto.
HeaderBodyRaw crypto -> Hash HASH EraIndependentBlockBody
hbrBodyHash (\HeaderBodyRaw c
hbr Hash HASH EraIndependentBlockBody
h -> HeaderBodyRaw c
hbr {hbrBodyHash = h})
slotNoBlockHeaderL :: Lens' (Block (Header c) era) SlotNo
slotNoBlockHeaderL =
(Header c -> f (Header c))
-> Block (Header c) era -> f (Block (Header c) era)
forall h era (f :: * -> *).
Functor f =>
(h -> f h) -> Block h era -> f (Block h era)
blockHeaderL ((Header c -> f (Header c))
-> Block (Header c) era -> f (Block (Header c) era))
-> ((SlotNo -> f SlotNo) -> Header c -> f (Header c))
-> (SlotNo -> f SlotNo)
-> Block (Header c) era
-> f (Block (Header c) era)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Proxy era -> Lens' (Header c) (HeaderBodyRaw c)
forall era c (proxy :: * -> *).
(Era era, Crypto c) =>
proxy era -> Lens' (Header c) (HeaderBodyRaw c)
headerBodyRawL (forall t. Proxy t
forall {k} (t :: k). Proxy t
Proxy @era) ((HeaderBodyRaw c -> f (HeaderBodyRaw c))
-> Header c -> f (Header c))
-> ((SlotNo -> f SlotNo) -> HeaderBodyRaw c -> f (HeaderBodyRaw c))
-> (SlotNo -> f SlotNo)
-> Header c
-> f (Header c)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (HeaderBodyRaw c -> SlotNo)
-> (HeaderBodyRaw c -> SlotNo -> HeaderBodyRaw c)
-> Lens (HeaderBodyRaw c) (HeaderBodyRaw c) SlotNo SlotNo
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens HeaderBodyRaw c -> SlotNo
forall crypto. HeaderBodyRaw crypto -> SlotNo
hbrSlotNo (\HeaderBodyRaw c
hbr SlotNo
sn -> HeaderBodyRaw c
hbr {hbrSlotNo = sn})
instance (Crypto c, Era era) => LeiosEraBlockHeader (Header c) era where
versionInfoBlockHeaderL :: Lens' (Block (Header c) era) BlockHeaderVersionInfo
versionInfoBlockHeaderL =
(Header c -> f (Header c))
-> Block (Header c) era -> f (Block (Header c) era)
forall h era (f :: * -> *).
Functor f =>
(h -> f h) -> Block h era -> f (Block h era)
blockHeaderL ((Header c -> f (Header c))
-> Block (Header c) era -> f (Block (Header c) era))
-> ((BlockHeaderVersionInfo -> f BlockHeaderVersionInfo)
-> Header c -> f (Header c))
-> (BlockHeaderVersionInfo -> f BlockHeaderVersionInfo)
-> Block (Header c) era
-> f (Block (Header c) era)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Proxy era -> Lens' (Header c) (HeaderBodyRaw c)
forall era c (proxy :: * -> *).
(Era era, Crypto c) =>
proxy era -> Lens' (Header c) (HeaderBodyRaw c)
headerBodyRawL (forall t. Proxy t
forall {k} (t :: k). Proxy t
Proxy @era) ((HeaderBodyRaw c -> f (HeaderBodyRaw c))
-> Header c -> f (Header c))
-> ((BlockHeaderVersionInfo -> f BlockHeaderVersionInfo)
-> HeaderBodyRaw c -> f (HeaderBodyRaw c))
-> (BlockHeaderVersionInfo -> f BlockHeaderVersionInfo)
-> Header c
-> f (Header c)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (BlockHeaderVersionInfo -> f BlockHeaderVersionInfo)
-> HeaderBodyRaw c -> f (HeaderBodyRaw c)
forall crypto (f :: * -> *).
Functor f =>
(BlockHeaderVersionInfo -> f BlockHeaderVersionInfo)
-> HeaderBodyRaw crypto -> f (HeaderBodyRaw crypto)
hbrVersionInfoL
ebReferencesAnnouncementBlockHeaderL :: Lens' (Block (Header c) era) (StrictMaybe EbReferencesAnnouncement)
ebReferencesAnnouncementBlockHeaderL =
(Header c -> f (Header c))
-> Block (Header c) era -> f (Block (Header c) era)
forall h era (f :: * -> *).
Functor f =>
(h -> f h) -> Block h era -> f (Block h era)
blockHeaderL ((Header c -> f (Header c))
-> Block (Header c) era -> f (Block (Header c) era))
-> ((StrictMaybe EbReferencesAnnouncement
-> f (StrictMaybe EbReferencesAnnouncement))
-> Header c -> f (Header c))
-> (StrictMaybe EbReferencesAnnouncement
-> f (StrictMaybe EbReferencesAnnouncement))
-> Block (Header c) era
-> f (Block (Header c) era)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Proxy era -> Lens' (Header c) (HeaderBodyRaw c)
forall era c (proxy :: * -> *).
(Era era, Crypto c) =>
proxy era -> Lens' (Header c) (HeaderBodyRaw c)
headerBodyRawL (forall t. Proxy t
forall {k} (t :: k). Proxy t
Proxy @era) ((HeaderBodyRaw c -> f (HeaderBodyRaw c))
-> Header c -> f (Header c))
-> ((StrictMaybe EbReferencesAnnouncement
-> f (StrictMaybe EbReferencesAnnouncement))
-> HeaderBodyRaw c -> f (HeaderBodyRaw c))
-> (StrictMaybe EbReferencesAnnouncement
-> f (StrictMaybe EbReferencesAnnouncement))
-> Header c
-> f (Header c)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (StrictMaybe EbReferencesAnnouncement
-> f (StrictMaybe EbReferencesAnnouncement))
-> HeaderBodyRaw c -> f (HeaderBodyRaw c)
forall crypto (f :: * -> *).
Functor f =>
(StrictMaybe EbReferencesAnnouncement
-> f (StrictMaybe EbReferencesAnnouncement))
-> HeaderBodyRaw crypto -> f (HeaderBodyRaw crypto)
hbrEbReferencesAnnouncementL