Skip to content

Commit 25e0061

Browse files
committed
tx-submission: cleaned up TraceTxSubmissionInbound
1 parent d135c84 commit 25e0061

File tree

3 files changed

+29
-28
lines changed

3 files changed

+29
-28
lines changed

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -315,15 +315,14 @@ txSubmissionInbound tracer initDelay (NumTxIdsToAck maxUnacked) mpReader mpWrite
315315
txidsAccepted <- mempoolAddTxs txsReady
316316
!end <- getMonotonicTime
317317
let duration = diffTime end start
318-
traceWith tracer $
319-
TraceTxInboundAddedToMempool txidsAccepted duration
320318
let !accepted = length txidsAccepted
321319

322320
traceWith tracer $ TraceTxSubmissionProcessed ProcessedTxCount {
323321
ptxcAccepted = accepted
324322
, ptxcRejected = length txs - accepted
325323
, ptxcScore = 0 -- This implementatin does not track score
326324
}
325+
duration
327326

328327
continueWithStateM (serverIdle n) st {
329328
bufferedTxs = bufferedTxs3,

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

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -256,18 +256,16 @@ withPeer tracer
256256
bracket_ (atomically $ waitTSem mempoolSem)
257257
(atomically $ signalTSem mempoolSem)
258258
$ do
259-
res <- addTx
259+
(res, cnts) <- addTx
260260
start <- getMonotonicTime
261261
atomically $ modifyTVar sharedStateVar (updateBufferedTx start res)
262262
end <- getMonotonicTime
263263
let duration = end `diffTime` start
264-
case res of
265-
TxAccepted -> traceWith txTracer (TraceTxInboundAddedToMempool [txid] duration)
266-
TxRejected -> traceWith txTracer (TraceTxInboundRejectedFromMempool [txid] duration)
264+
traceWith txTracer (TraceTxSubmissionProcessed cnts duration)
267265

268266
where
269267
-- add the tx to the mempool
270-
addTx :: m TxMempoolResult
268+
addTx :: m (TxMempoolResult, ProcessedTxCount)
271269
addTx = do
272270
mpSnapshot <- atomically mempoolGetSnapshot
273271

@@ -278,32 +276,38 @@ withPeer tracer
278276
then do
279277
!now <- getMonotonicTime
280278
!s <- countRejectedTxs now 1
281-
traceWith txTracer $ TraceTxSubmissionProcessed ProcessedTxCount {
282-
ptxcAccepted = 0
283-
, ptxcRejected = 1
284-
, ptxcScore = s
285-
}
286-
return TxRejected
279+
return
280+
( TxRejected
281+
, ProcessedTxCount {
282+
ptxcAccepted = 0
283+
, ptxcRejected = 1
284+
, ptxcScore = s
285+
}
286+
)
287287
else do
288288
acceptedTxs <- mempoolAddTxs [tx]
289289
end <- getMonotonicTime
290290
if null acceptedTxs
291291
then do
292292
!s <- countRejectedTxs end 1
293-
traceWith txTracer $ TraceTxSubmissionProcessed ProcessedTxCount {
294-
ptxcAccepted = 0
295-
, ptxcRejected = 1
296-
, ptxcScore = s
297-
}
298-
return TxRejected
293+
return
294+
( TxRejected
295+
, ProcessedTxCount {
296+
ptxcAccepted = 0
297+
, ptxcRejected = 1
298+
, ptxcScore = s
299+
}
300+
)
299301
else do
300302
!s <- countRejectedTxs end 0
301-
traceWith txTracer $ TraceTxSubmissionProcessed ProcessedTxCount {
302-
ptxcAccepted = 1
303-
, ptxcRejected = 0
304-
, ptxcScore = s
305-
}
306-
return TxAccepted
303+
return
304+
( TxAccepted
305+
, ProcessedTxCount {
306+
ptxcAccepted = 1
307+
, ptxcRejected = 0
308+
, ptxcScore = s
309+
}
310+
)
307311

308312
updateBufferedTx :: Time
309313
-> TxMempoolResult

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -362,11 +362,9 @@ data TraceTxSubmissionInbound txid tx =
362362
-- | Number of transactions just about to be inserted.
363363
TraceTxSubmissionCollected [txid]
364364
-- | Just processed transaction pass/fail breakdown.
365-
| TraceTxSubmissionProcessed ProcessedTxCount
365+
| TraceTxSubmissionProcessed ProcessedTxCount DiffTime
366366
| TraceTxInboundCanRequestMoreTxs Int
367367
| TraceTxInboundCannotRequestMoreTxs Int
368-
| TraceTxInboundAddedToMempool [txid] DiffTime
369-
| TraceTxInboundRejectedFromMempool [txid] DiffTime
370368

371369
--
372370
-- messages emitted by the new implementation of the server in

0 commit comments

Comments
 (0)