{-# LANGUAGE DataKinds #-}

module Ouroboros.Consensus.Protocol.Praos.Views (
    HeaderView (..)
  , LedgerView (..)
  ) where

import           Cardano.Crypto.KES (SignedKES)
import           Cardano.Crypto.VRF (CertifiedVRF, VRFAlgorithm (VerKeyVRF))
import           Cardano.Ledger.BaseTypes (ProtVer)
import           Cardano.Ledger.Keys (KeyRole (BlockIssuer), VKey)
import qualified Cardano.Ledger.Shelley.API as SL
import           Cardano.Protocol.Crypto (KES, VRF)
import           Cardano.Protocol.TPraos.BHeader (PrevHash)
import           Cardano.Protocol.TPraos.OCert (OCert)
import           Cardano.Slotting.Slot (SlotNo)
import           Data.Word (Word16, Word32)
import           Ouroboros.Consensus.Protocol.Praos.Header (HeaderBody)
import           Ouroboros.Consensus.Protocol.Praos.VRF (InputVRF)

-- | View of the block header required by the Praos protocol.
data HeaderView crypto = HeaderView
  { -- | Hash of the previous block
    forall crypto. HeaderView crypto -> PrevHash
hvPrevHash  :: !PrevHash,
    -- | verification key of block issuer
    forall crypto. HeaderView crypto -> VKey 'BlockIssuer
hvVK        :: !(VKey 'BlockIssuer),
    -- | VRF verification key for block issuer
    forall crypto. HeaderView crypto -> VerKeyVRF (VRF crypto)
hvVrfVK     :: !(VerKeyVRF (VRF crypto)),
    -- | VRF result
    forall crypto.
HeaderView crypto -> CertifiedVRF (VRF crypto) InputVRF
hvVrfRes    :: !(CertifiedVRF (VRF crypto) InputVRF),
    -- | operational certificate
    forall crypto. HeaderView crypto -> OCert crypto
hvOCert     :: !(OCert crypto),
    -- | Slot
    forall crypto. HeaderView crypto -> SlotNo
hvSlotNo    :: !SlotNo,
    -- | Header which must be signed
    forall crypto. HeaderView crypto -> HeaderBody crypto
hvSigned    :: !(HeaderBody crypto),
    -- | KES Signature of the header
    forall crypto.
HeaderView crypto -> SignedKES (KES crypto) (HeaderBody crypto)
hvSignature :: !(SignedKES (KES crypto) (HeaderBody crypto))
  }

data LedgerView = LedgerView
  { -- | Stake distribution
    LedgerView -> PoolDistr
lvPoolDistr       :: SL.PoolDistr,
    -- | Maximum header size
    LedgerView -> Word16
lvMaxHeaderSize   :: !Word16,
    -- | Maximum block body size
    LedgerView -> Word32
lvMaxBodySize     :: !Word32,
    -- | Current protocol version
    LedgerView -> ProtVer
lvProtocolVersion :: !ProtVer
  }
  deriving (Int -> LedgerView -> ShowS
[LedgerView] -> ShowS
LedgerView -> String
(Int -> LedgerView -> ShowS)
-> (LedgerView -> String)
-> ([LedgerView] -> ShowS)
-> Show LedgerView
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> LedgerView -> ShowS
showsPrec :: Int -> LedgerView -> ShowS
$cshow :: LedgerView -> String
show :: LedgerView -> String
$cshowList :: [LedgerView] -> ShowS
showList :: [LedgerView] -> ShowS
Show)