@@ -25,6 +25,8 @@ module Ouroboros.Network.Protocol.TxSubmission2.Server
25
25
) where
26
26
27
27
import Data.List.NonEmpty (NonEmpty )
28
+ import Data.Map.Strict (Map )
29
+ import Data.Map.Strict qualified as Map
28
30
29
31
import Network.TypedProtocol.Core
30
32
import Network.TypedProtocol.Peer.Server
@@ -51,7 +53,7 @@ data Collect txid tx =
51
53
-- contains the transactions sent, but this pairs them up with the
52
54
-- transactions requested. This is because the peer can determine that
53
55
-- some transactions are no longer needed.
54
- | CollectTxs [ txid ] [tx ]
56
+ | CollectTxs ( Map txid SizeInBytes ) [tx ]
55
57
56
58
57
59
data ServerStIdle (n :: N ) txid tx m a where
@@ -77,16 +79,16 @@ data ServerStIdle (n :: N) txid tx m a where
77
79
-- |
78
80
--
79
81
SendMsgRequestTxsPipelined
80
- :: [ txid ]
82
+ :: Map txid SizeInBytes
81
83
-> m (ServerStIdle (S n ) txid tx m a )
82
84
-> ServerStIdle n txid tx m a
83
85
84
86
-- | Collect a pipelined result.
85
87
--
86
88
CollectPipelined
87
- :: Maybe (ServerStIdle (S n ) txid tx m a )
88
- -> (Collect txid tx -> m (ServerStIdle n txid tx m a ))
89
- -> ServerStIdle (S n ) txid tx m a
89
+ :: Maybe (m ( ServerStIdle (S n ) txid tx m a ) )
90
+ -> (Collect txid tx -> m ( ServerStIdle n txid tx m a ))
91
+ -> ServerStIdle (S n ) txid tx m a
90
92
91
93
92
94
-- | Transform a 'TxSubmissionServerPipelined' into a 'PeerPipelined'.
@@ -127,12 +129,12 @@ txSubmissionServerPeerPipelined (TxSubmissionServerPipelined server) =
127
129
128
130
go (SendMsgRequestTxsPipelined txids k) =
129
131
YieldPipelined
130
- (MsgRequestTxs txids)
132
+ (MsgRequestTxs $ Map. keys txids)
131
133
(ReceiverAwait \ case
132
134
MsgReplyTxs txs -> ReceiverDone (CollectTxs txids txs))
133
135
(Effect (go <$> k))
134
136
135
137
go (CollectPipelined mNone collect) =
136
- Collect (fmap go mNone)
137
- (Effect . fmap go . collect)
138
+ Collect (Effect . fmap go <$> mNone)
139
+ (Effect . fmap go . collect)
138
140
0 commit comments