aboutsummaryrefslogtreecommitdiff
path: root/src/txmempool.cpp
diff options
context:
space:
mode:
authorAndrew Chow <github@achow101.com>2023-03-20 12:35:36 -0400
committerAndrew Chow <github@achow101.com>2023-03-20 12:42:24 -0400
commit60f142e395171ab8b093a5dfae59a6a9761b38ab (patch)
tree3aea1c048dc64cefe19c016ed295eb32ad46756a /src/txmempool.cpp
parent40e1c4d4024b8ad35f2511b2e10bf80c5531dfde (diff)
parent4b7aec2951fe4595946cdc804b0dec1921d79d05 (diff)
downloadbitcoin-60f142e395171ab8b093a5dfae59a6a9761b38ab.tar.xz
Merge bitcoin/bitcoin#26531: mempool: Add mempool tracepoints
4b7aec2951fe4595946cdc804b0dec1921d79d05 Add mempool tracepoints (virtu) Pull request description: This PR adds multiple mempool tracepoints. | tracepoint | description | | ------------- | ------------- | | `mempool:added` | Is called when a transaction enters the mempool | | `mempool:removed` | ... when a transaction is removed from the mempool | | `mempool:replaced` | ... when a transaction is replaced in the mempool | | `mempool:rejected` | ... when a transaction is rejected from entering the mempool | The tracepoints are further documented in `docs/tracing.md`. Usage is demonstrated in the example script `contrib/tracing/mempool_monitor.py`. Interface tests are provided in `test/functional/interface_usdt_mempool.py`. The rationale for passing the removal reason as a string instead of numerically is that the benefits of not having to maintain a redundant enum-string mapping seem to outweigh the small cost of string generation. The reject reason is passed as string as well, although in this instance the string does not have to be generated but is readily available. ACKs for top commit: 0xB10C: ACK 4b7aec2951fe4595946cdc804b0dec1921d79d05 achow101: ACK 4b7aec2951fe4595946cdc804b0dec1921d79d05 Tree-SHA512: 6deb3ba2d1a061292fb9b0f885f7a5c4d11b109b838102d8a8f4828cd68f5cd03fa3fc64adc6fdf54a08a1eaccce261b0aa90c2b8c33cd5fd3828c8f74978958
Diffstat (limited to 'src/txmempool.cpp')
-rw-r--r--src/txmempool.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/txmempool.cpp b/src/txmempool.cpp
index 378123ce0f..032dfee3ea 100644
--- a/src/txmempool.cpp
+++ b/src/txmempool.cpp
@@ -20,6 +20,7 @@
#include <util/result.h>
#include <util/system.h>
#include <util/time.h>
+#include <util/trace.h>
#include <util/translation.h>
#include <validationinterface.h>
@@ -464,6 +465,12 @@ void CTxMemPool::addUnchecked(const CTxMemPoolEntry &entry, setEntries &setAnces
vTxHashes.emplace_back(tx.GetWitnessHash(), newit);
newit->vTxHashesIdx = vTxHashes.size() - 1;
+
+ TRACE3(mempool, added,
+ entry.GetTx().GetHash().data(),
+ entry.GetTxSize(),
+ entry.GetFee()
+ );
}
void CTxMemPool::removeUnchecked(txiter it, MemPoolRemovalReason reason)
@@ -479,6 +486,13 @@ void CTxMemPool::removeUnchecked(txiter it, MemPoolRemovalReason reason)
// notification.
GetMainSignals().TransactionRemovedFromMempool(it->GetSharedTx(), reason, mempool_sequence);
}
+ TRACE5(mempool, removed,
+ it->GetTx().GetHash().data(),
+ RemovalReasonToString(reason).c_str(),
+ it->GetTxSize(),
+ it->GetFee(),
+ std::chrono::duration_cast<std::chrono::duration<std::uint64_t>>(it->GetTime()).count()
+ );
const uint256 hash = it->GetTx().GetHash();
for (const CTxIn& txin : it->GetTx().vin)