1- {-# LANGUAGE BlockArguments #-}
2- {-# LANGUAGE DataKinds #-}
3- {-# LANGUAGE DeriveAnyClass #-}
4- {-# LANGUAGE DeriveGeneric #-}
5- {-# LANGUAGE DerivingStrategies #-}
6- {-# LANGUAGE FlexibleContexts #-}
7- {-# LANGUAGE LambdaCase #-}
8- {-# LANGUAGE NamedFieldPuns #-}
9- {-# LANGUAGE PolyKinds #-}
10- {-# LANGUAGE RankNTypes #-}
11- {-# LANGUAGE ScopedTypeVariables #-}
12- {-# LANGUAGE TypeApplications #-}
1+ {-# LANGUAGE BlockArguments #-}
2+ {-# LANGUAGE DataKinds #-}
3+ {-# LANGUAGE DeriveAnyClass #-}
4+ {-# LANGUAGE DeriveGeneric #-}
5+ {-# LANGUAGE DerivingStrategies #-}
6+ {-# LANGUAGE FlexibleContexts #-}
7+ {-# LANGUAGE LambdaCase #-}
8+ {-# LANGUAGE NamedFieldPuns #-}
9+ {-# LANGUAGE PartialTypeSignatures #-}
10+ {-# LANGUAGE PolyKinds #-}
11+ {-# LANGUAGE RankNTypes #-}
12+ {-# LANGUAGE ScopedTypeVariables #-}
13+ {-# LANGUAGE TypeApplications #-}
1314
1415-- | Implements a server that waits for an incoming connection to ChainSync or
1516-- BlockFetch, and forwards the resulting channels to a TMVar so they can be
1617-- picked up by the peer simulator.
1718module MiniProtocols (peerSimServer ) where
1819
20+ import Ouroboros.Consensus.Node.Serialisation
21+ import Ouroboros.Network.Protocol.ChainSync.Codec
22+ import Ouroboros.Network.Block
23+ ( Serialised (.. )
24+ , Tip (.. )
25+ , decodePoint
26+ , decodeTip
27+ , encodePoint
28+ , encodeTip
29+ )
1930import Ouroboros.Network.Protocol.BlockFetch.Server
2031import Ouroboros.Network.Util.ShowProxy (ShowProxy )
2132import Ouroboros.Network.Protocol.ChainSync.Server
@@ -57,14 +68,18 @@ import Ouroboros.Network.Protocol.Handshake.Version (Version (..))
5768import Ouroboros.Network.Protocol.KeepAlive.Server
5869 ( keepAliveServerPeer
5970 )
71+ -- import Network.TypedProtocol.Codec
72+ import Codec.CBOR.Read (DeserialiseFailure )
6073
6174peerSimServer ::
6275 forall m blk addr .
6376 ( IOLike m
64- , SerialiseNodeToNodeConstraints blk
77+ -- , SerialiseNodeToNodeConstraints blk
6578 , SupportedNetworkProtocolVersion blk
6679 , ShowProxy blk
6780 , ShowProxy (Header blk )
81+ , ConvertRawHash blk
82+ , SerialiseNodeToNode blk (Header blk )
6883 , MonadSay m
6984 ) =>
7085 PeerResources m blk ->
@@ -113,8 +128,9 @@ peerSimServer res csChanTMV bfChanTMV codecCfg encAddr decAddr networkMagic = do
113128 N2N. keepAliveProtocolLimits
114129 $ MiniProtocolCb
115130 $ \ _ctx channel ->
116- runPeer nullTracer cKeepAliveCodec channel $
117- keepAliveServerPeer keepAliveServer
131+ undefined
132+ -- runPeer nullTracer cKeepAliveCodec channel $
133+ -- keepAliveServerPeer keepAliveServer
118134 , mkMiniProtocol
119135 Mux. StartOnDemand
120136 N2N. chainSyncMiniProtocolNum
@@ -123,7 +139,21 @@ peerSimServer res csChanTMV bfChanTMV codecCfg encAddr decAddr networkMagic = do
123139 $ \ _ctx channel -> do
124140 say " hello from cs"
125141 atomically $ writeTVar csChanTMV True
126- runPeer nullTracer cChainSyncCodec channel
142+ let p :: Proxy blk
143+ p = Proxy @ blk
144+ runPeer nullTracer
145+
146+ (codecChainSync
147+ (encodeNodeToNode codecCfg blockVersion)
148+ (decodeNodeToNode codecCfg blockVersion)
149+ (encodePoint (encodeRawHash @ blk p))
150+ (decodePoint (decodeRawHash @ blk p))
151+ (encodeTip (encodeRawHash @ blk p))
152+ (decodeTip (decodeRawHash @ blk p))
153+ :: _ (_ (Header blk ) (Point blk ) (Tip blk )) DeserialiseFailure m BL. ByteString
154+ )
155+
156+ channel
127157 $ chainSyncServerPeer $ csrServer $ prChainSync res
128158 , mkMiniProtocol
129159 Mux. StartOnDemand
@@ -133,8 +163,9 @@ peerSimServer res csChanTMV bfChanTMV codecCfg encAddr decAddr networkMagic = do
133163 $ \ _ctx channel -> do
134164 say " hello from bf"
135165 atomically $ writeTVar bfChanTMV True
136- runPeer nullTracer cBlockFetchCodec channel
137- $ blockFetchServerPeer $ bfrServer $ prBlockFetch res
166+ undefined
167+ -- runPeer nullTracer cBlockFetchCodec channel
168+ -- $ blockFetchServerPeer $ bfrServer $ prBlockFetch res
138169 , mkMiniProtocol
139170 Mux. StartOnDemand
140171 N2N. txSubmissionMiniProtocolNum
@@ -143,12 +174,12 @@ peerSimServer res csChanTMV bfChanTMV codecCfg encAddr decAddr networkMagic = do
143174 $ \ _ctx _channel -> forever $ threadDelay 10
144175 ]
145176 where
146- Consensus.N2N. Codecs
147- { cKeepAliveCodec
148- , cChainSyncCodec
149- , cBlockFetchCodec
150- } =
151- Consensus.N2N. defaultCodecs codecCfg blockVersion encAddr decAddr version
177+ -- Consensus.N2N.Codecs
178+ -- { cKeepAliveCodec
179+ -- , cChainSyncCodec
180+ -- , cBlockFetchCodec
181+ -- } =
182+ -- Consensus.N2N.defaultCodecs codecCfg blockVersion encAddr decAddr version
152183
153184 mkMiniProtocol miniProtocolStart miniProtocolNum limits proto =
154185 MiniProtocol
0 commit comments