/
Abstract.hs
70 lines (59 loc) · 3.26 KB
/
Abstract.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE UndecidableSuperClasses #-}
-- | Infrastructure required to run a node
--
-- The definitions in this module are independent from any specific protocol.
module Ouroboros.Consensus.Node.Run.Abstract
( RunNode (..)
) where
import Codec.CBOR.Decoding (Decoder)
import Codec.CBOR.Encoding (Encoding)
import Crypto.Random (MonadRandom)
import qualified Data.ByteString.Lazy as Lazy
import Data.Proxy (Proxy)
import Ouroboros.Network.Block (BlockNo, ChainHash (..), HeaderHash,
SlotNo)
import Ouroboros.Network.BlockFetch (SizeInBytes)
import Ouroboros.Consensus.Block
import Ouroboros.Consensus.BlockchainTime (SystemStart)
import Ouroboros.Consensus.Ledger.Abstract
import Ouroboros.Consensus.Ledger.Byron
import Ouroboros.Consensus.Mempool
import Ouroboros.Consensus.Protocol.Abstract
import Ouroboros.Storage.Common (EpochNo, EpochSize)
class (ProtocolLedgerView blk, ApplyTx blk) => RunNode blk where
nodeForgeBlock :: (HasNodeState (BlockProtocol blk) m, MonadRandom m)
=> NodeConfig (BlockProtocol blk)
-> SlotNo -- ^ Current slot
-> BlockNo -- ^ Current block number
-> ChainHash blk -- ^ Previous hash
-> [GenTx blk] -- ^ Txs to add in the block
-> IsLeader (BlockProtocol blk)
-> m blk
nodeBlockMatchesHeader :: Header blk -> blk -> Bool
nodeBlockFetchSize :: Header blk -> SizeInBytes
nodeIsEBB :: blk -> Bool
nodeEpochSize :: Monad m
=> Proxy blk -> EpochNo -> m EpochSize
nodeStartTime :: Proxy blk
-> NodeConfig (BlockProtocol blk)
-> SystemStart
-- Encoders
nodeEncodeBlock :: NodeConfig (BlockProtocol blk) -> blk -> Encoding
nodeEncodeHeader :: NodeConfig (BlockProtocol blk) -> Header blk -> Encoding
nodeEncodeGenTx :: GenTx blk -> Encoding
nodeEncodeGenTxId :: GenTxId blk -> Encoding
nodeEncodeHeaderHash :: Proxy blk -> HeaderHash blk -> Encoding
nodeEncodeLedgerState :: NodeConfig (BlockProtocol blk) -> LedgerState blk -> Encoding
nodeEncodeChainState :: Proxy blk -> ChainState (BlockProtocol blk) -> Encoding
nodeEncodeApplyTxError :: Proxy blk -> ApplyTxErr blk -> Encoding
-- Decoders
nodeDecodeHeader :: forall s. NodeConfig (BlockProtocol blk) -> Decoder s (Lazy.ByteString -> Header blk)
nodeDecodeBlock :: forall s. NodeConfig (BlockProtocol blk) -> Decoder s (Lazy.ByteString -> blk)
nodeDecodeGenTx :: forall s. Decoder s (GenTx blk)
nodeDecodeGenTxId :: forall s. Decoder s (GenTxId blk)
nodeDecodeHeaderHash :: forall s. Proxy blk -> Decoder s (HeaderHash blk)
nodeDecodeLedgerState :: forall s. NodeConfig (BlockProtocol blk) -> Decoder s (LedgerState blk)
nodeDecodeChainState :: forall s. Proxy blk -> Decoder s (ChainState (BlockProtocol blk))
nodeDecodeApplyTxError :: forall s. Proxy blk -> Decoder s (ApplyTxErr blk)