aboutsummaryrefslogtreecommitdiff
path: root/src/txmempool.cpp
diff options
context:
space:
mode:
authorJames O'Beirne <james.obeirne@pm.me>2022-10-28 18:59:41 -0400
committerJames O'Beirne <james.obeirne@pm.me>2022-11-04 09:38:39 -0400
commit25ef049d60535ac02508ba71ef60f17d8349f120 (patch)
treecdca765116426110a1fdf170f6b3042d3ab2a647 /src/txmempool.cpp
parent28653a596ab7e0811ffec3bbb7632e17d54f8e43 (diff)
downloadbitcoin-25ef049d60535ac02508ba71ef60f17d8349f120.tar.xz
log: mempool: log removal reason in validation interface
Currently the exact reason a transaction is removed from the mempool isn't logged. It is sometimes detectable from context, but adding the `reason` to the validation interface logs (where it is already passed) seems like an easy way to disambiguate. For example, in the case of mempool expiry, the logs look like this: ``` [validationinterface.cpp:220] [TransactionRemovedFromMempool] [validation] Enqueuing TransactionRemovedFromMempool: txid=<txid> wtxid=<wtxid> [txmempool.cpp:1050] [RemoveUnbroadcastTx] [mempool] Removed <txid> from set of unbroadcast txns before confirmation that txn was sent out [validationinterface.cpp:220] [operator()] [validation] TransactionRemovedFromMempool: txid=<txid> wtxid=<wtxid> [validation.cpp:267] [LimitMempoolSize] [mempool] Expired 1 transactions from the memory pool ``` There is no context-free way to know $txid was evicted on the basis of expiry. This change will make that case (and probably others) clear.
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 84ed2e9ef5..6a4cd842fb 100644
--- a/src/txmempool.cpp
+++ b/src/txmempool.cpp
@@ -1182,3 +1182,17 @@ void CTxMemPool::SetLoadTried(bool load_tried)
LOCK(cs);
m_load_tried = load_tried;
}
+
+
+const std::string RemovalReasonToString(const MemPoolRemovalReason& r) noexcept
+{
+ switch (r) {
+ case MemPoolRemovalReason::EXPIRY: return "expiry";
+ case MemPoolRemovalReason::SIZELIMIT: return "sizelimit";
+ case MemPoolRemovalReason::REORG: return "reorg";
+ case MemPoolRemovalReason::BLOCK: return "block";
+ case MemPoolRemovalReason::CONFLICT: return "conflict";
+ case MemPoolRemovalReason::REPLACED: return "replaced";
+ }
+ assert(false);
+}