Skip to content
Permalink
Browse files

Don't trace mempool events when the batch of txs is empty

  • Loading branch information...
mrBliss committed Jul 12, 2019
1 parent 8456d4f commit 0e889dd0e327bd1320a1662db89bf80ba55a9f47
@@ -129,14 +129,16 @@ implAddTxs mpEnv@MempoolEnv{mpEnvStateVar, mpEnvLedgerCfg, mpEnvTracer} txs = do
mempoolSize <- getMempoolSize mpEnv
return (removed, accepted, rejected, mempoolSize)

trace $ TraceMempoolRemoveTxs (map fst removed) mempoolSize
trace $ TraceMempoolAddTxs accepted mempoolSize
trace $ TraceMempoolRejectedTxs (map fst rejected) mempoolSize
traceBatch TraceMempoolRemoveTxs mempoolSize (map fst removed)
traceBatch TraceMempoolAddTxs mempoolSize accepted
traceBatch TraceMempoolRejectedTxs mempoolSize (map fst rejected)

return $ [(tx, Just err) | (tx, err) <- rejected] ++
zip accepted (repeat Nothing)
where
trace = traceWith mpEnvTracer
traceBatch mkEv size batch
| null batch = return ()
| otherwise = traceWith mpEnvTracer (mkEv batch size)

-- | We first reset 'vrInvalid' to an empty list such that afterwards it
-- will only contain the /new/ invalid transactions.
@@ -158,7 +160,8 @@ implSyncState mpEnv@MempoolEnv{mpEnvTracer, mpEnvStateVar} = do
-- transactions.
mempoolSize <- getMempoolSize mpEnv
return (map fst vrInvalid, mempoolSize)
traceWith mpEnvTracer $ TraceMempoolRemoveTxs removed mempoolSize
unless (null removed) $
traceWith mpEnvTracer $ TraceMempoolRemoveTxs removed mempoolSize

implGetSnapshot :: ( MonadSTM m
, ApplyTx blk
@@ -124,7 +124,7 @@ prop_Mempool_TraceValidTxs bc txs =
traceProp :: [GenTx TestBlock] -> [TraceEventMempool TestBlock] -> Property
traceProp genTxs es =
let addedTxs = maybe
(error "prop_Mempool_TraceValidTxs: No TraceMempoolAddTxs traces")
[]
(\(TraceMempoolAddTxs ts _) -> ts)
(find isAddTxsEvent es)
in sort (filter genTxIsValid genTxs) === sort addedTxs
@@ -148,7 +148,7 @@ prop_Mempool_TraceRejectedTxs bc txs =
traceProp :: [GenTx TestBlock] -> [TraceEventMempool TestBlock] -> Property
traceProp genTxs es =
let rejectedTxs = maybe
(error "prop_Mempool_TraceRejectedTxs: No TraceMempoolRejectedTxs traces")
[]
(\(TraceMempoolRejectedTxs ts _) -> ts)
(find isRejectedTxsEvent es)
in sort (filter genTxIsInvalid genTxs) === sort rejectedTxs

0 comments on commit 0e889dd

Please sign in to comment.
You can’t perform that action at this time.