1616-- picked up by the peer simulator.
1717module MiniProtocols (peerSimServer ) where
1818
19+ import Ouroboros.Network.Protocol.BlockFetch.Server
20+ import Ouroboros.Network.Util.ShowProxy (ShowProxy )
21+ import Ouroboros.Network.Protocol.ChainSync.Server
22+ import Test.Consensus.PeerSimulator.Resources (PeerResources (.. ), ChainSyncResources (.. ), BlockFetchResources (.. ))
1923import qualified Codec.CBOR.Decoding as CBOR
2024import qualified Codec.CBOR.Encoding as CBOR
2125import Control.Monad (forever )
@@ -59,10 +63,13 @@ peerSimServer ::
5963 ( IOLike m
6064 , SerialiseNodeToNodeConstraints blk
6165 , SupportedNetworkProtocolVersion blk
66+ , ShowProxy blk
67+ , ShowProxy (Header blk )
6268 , MonadSay m
6369 ) =>
64- StrictTMVar m (Mux. Channel m BL. ByteString ) ->
65- StrictTMVar m (Mux. Channel m BL. ByteString ) ->
70+ PeerResources m blk ->
71+ StrictTVar m Bool ->
72+ StrictTVar m Bool ->
6673 CodecConfig blk ->
6774 (NodeToNodeVersion -> addr -> CBOR. Encoding ) ->
6875 (NodeToNodeVersion -> forall s . CBOR. Decoder s addr ) ->
@@ -71,7 +78,7 @@ peerSimServer ::
7178 NodeToNodeVersion
7279 NodeToNodeVersionData
7380 (OuroborosApplicationWithMinimalCtx 'Mux.ResponderMode addr BL. ByteString m Void () )
74- peerSimServer csChanTMV bfChanTMV codecCfg encAddr decAddr networkMagic = do
81+ peerSimServer res csChanTMV bfChanTMV codecCfg encAddr decAddr networkMagic = do
7582 forAllVersions application
7683 where
7784 forAllVersions ::
@@ -115,19 +122,19 @@ peerSimServer csChanTMV bfChanTMV codecCfg encAddr decAddr networkMagic = do
115122 $ MiniProtocolCb
116123 $ \ _ctx channel -> do
117124 say " hello from cs"
118- atomically $
119- putTMVar csChanTMV channel
120- pure ( () , Nothing )
125+ atomically $ writeTVar csChanTMV True
126+ runPeer nullTracer cChainSyncCodec channel
127+ $ chainSyncServerPeer $ csrServer $ prChainSync res
121128 , mkMiniProtocol
122129 Mux. StartOnDemand
123130 N2N. blockFetchMiniProtocolNum
124131 N2N. blockFetchProtocolLimits
125132 $ MiniProtocolCb
126133 $ \ _ctx channel -> do
127134 say " hello from bf"
128- atomically $
129- putTMVar bfChanTMV channel
130- pure ( () , Nothing )
135+ atomically $ writeTVar bfChanTMV True
136+ runPeer nullTracer cBlockFetchCodec channel
137+ $ blockFetchServerPeer $ bfrServer $ prBlockFetch res
131138 , mkMiniProtocol
132139 Mux. StartOnDemand
133140 N2N. txSubmissionMiniProtocolNum
@@ -138,8 +145,8 @@ peerSimServer csChanTMV bfChanTMV codecCfg encAddr decAddr networkMagic = do
138145 where
139146 Consensus.N2N. Codecs
140147 { cKeepAliveCodec
141- -- , cChainSyncCodecSerialised
142- -- , cBlockFetchCodecSerialised
148+ , cChainSyncCodec
149+ , cBlockFetchCodec
143150 } =
144151 Consensus.N2N. defaultCodecs codecCfg blockVersion encAddr decAddr version
145152
0 commit comments