Skip to content

Commit 152fa3c

Browse files
committed
WIP: tx-submission: inbound side
1 parent d6370fd commit 152fa3c

File tree

5 files changed

+16
-11
lines changed

5 files changed

+16
-11
lines changed

ouroboros-network-protocols/src/Ouroboros/Network/Protocol/TxSubmission2/Server.hs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,9 @@ data ServerStIdle (n :: N) txid tx m a where
8383
-- | Collect a pipelined result.
8484
--
8585
CollectPipelined
86-
:: Maybe (ServerStIdle (S n) txid tx m a)
87-
-> (Collect txid tx -> m (ServerStIdle n txid tx m a))
88-
-> ServerStIdle (S n) txid tx m a
86+
:: Maybe (m (ServerStIdle (S n) txid tx m a))
87+
-> (Collect txid tx -> m ( ServerStIdle n txid tx m a))
88+
-> ServerStIdle (S n) txid tx m a
8989

9090

9191
-- | Transform a 'TxSubmissionServerPipelined' into a 'PeerPipelined'.
@@ -145,6 +145,6 @@ txSubmissionServerPeerPipelined (TxSubmissionServerPipelined server) =
145145

146146
go (CollectPipelined mNone collect) =
147147
SenderCollect
148-
(fmap go mNone)
149-
(SenderEffect . fmap go . collect)
148+
((SenderEffect . fmap go) <$> mNone)
149+
( SenderEffect . fmap go . collect)
150150

ouroboros-network-protocols/testlib/Ouroboros/Network/Protocol/TxSubmission2/Direct.hs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ directPipelined (TxSubmissionServerPipelined mserver)
5454
SendMsgReplyTxs txs client' <- recvMsgRequestTxs txids
5555
directSender (enqueue (CollectTxs txids txs) q) server' client'
5656

57-
directSender q (CollectPipelined (Just server') _) client =
57+
directSender q (CollectPipelined (Just server) _) client = do
58+
server' <- server
5859
directSender q server' client
5960

6061
directSender (ConsQ c q) (CollectPipelined _ collect) client = do

ouroboros-network-protocols/testlib/Ouroboros/Network/Protocol/TxSubmission2/Examples.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ txSubmissionServer tracer txId maxUnacked maxTxIdsToRequest maxTxToRequest =
272272
--
273273
| canRequestMoreTxs st
274274
= CollectPipelined
275-
(Just (serverReqTxs accum (Succ n) st))
275+
(Just (pure $ serverReqTxs accum (Succ n) st))
276276
(handleReply accum n st)
277277

278278
-- In this case there is nothing else to do so we block until we

ouroboros-network/sim-tests-lib/Test/Ouroboros/Network/TxSubmission.hs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import Prelude hiding (seq)
1818

1919
import NoThunks.Class
2020

21+
import Control.Concurrent.Class.MonadMVar (MonadMVar)
2122
import Control.Concurrent.Class.MonadSTM
2223
import Control.Exception (SomeException (..), assert)
2324
import Control.Monad.Class.MonadAsync
@@ -263,6 +264,7 @@ txSubmissionSimulation
263264
, MonadDelay m
264265
, MonadFork m
265266
, MonadMask m
267+
, MonadMVar m
266268
, MonadSay m
267269
, MonadST m
268270
, MonadSTM m
@@ -277,13 +279,14 @@ txSubmissionSimulation
277279

278280
, txid ~ Int
279281
)
280-
=> NumTxIdsToAck
282+
=> Tracer m (String, TraceSendRecv (TxSubmission2 txid (Tx txid)))
283+
-> NumTxIdsToAck
281284
-> [Tx txid]
282285
-> ControlMessageSTM m
283286
-> Maybe DiffTime
284287
-> Maybe DiffTime
285288
-> m ([Tx txid], [Tx txid])
286-
txSubmissionSimulation maxUnacked outboundTxs
289+
txSubmissionSimulation tracer maxUnacked outboundTxs
287290
controlMessageSTM
288291
inboundDelay outboundDelay = do
289292

@@ -292,7 +295,7 @@ txSubmissionSimulation maxUnacked outboundTxs
292295
(outboundChannel, inboundChannel) <- createConnectedChannels
293296
outboundAsync <-
294297
async $ runPeerWithLimits
295-
(("OUTBOUND",) `contramap` verboseTracer)
298+
(("OUTBOUND",) `contramap` tracer)
296299
txSubmissionCodec2
297300
(byteLimitsTxSubmission2 (fromIntegral . BSL.length))
298301
timeLimitsTxSubmission2
@@ -359,6 +362,7 @@ prop_txSubmission (Positive maxUnacked) (NonEmpty outboundTxs) delay =
359362
* realToFrac (length outboundTxs `div` 4))
360363
atomically (writeTVar controlMessageVar Terminate)
361364
txSubmissionSimulation
365+
verboseTracer
362366
(NumTxIdsToAck maxUnacked) outboundTxs
363367
(readTVar controlMessageVar)
364368
mbDelayTime mbDelayTime

ouroboros-network/src/Ouroboros/Network/TxSubmission/Inbound.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ txSubmissionInbound tracer (NumTxIdsToAck maxUnacked) mpReader mpWriter _version
252252
--
253253
traceWith tracer (TraceTxInboundCanRequestMoreTxs (natToInt n))
254254
pure $ CollectPipelined
255-
(Just (continueWithState (serverReqTxs (Succ n')) st))
255+
(Just (pure $ continueWithState (serverReqTxs (Succ n')) st))
256256
(collectAndContinueWithState (handleReply n') st)
257257

258258
else do

0 commit comments

Comments
 (0)