From a3fb3dd55c2326452a5085add220bd3682052352 Mon Sep 17 00:00:00 2001 From: Greg Sanders Date: Wed, 18 Feb 2026 09:49:53 -0500 Subject: [PATCH] mempool: log if we detect a non-optimal mempool We expect this to be rare in practice, and to not be the usual state of the mempool. If we we detect non-optimal ordering after a DoWork() invocation, allow this to be observed in MEMPOOL logs. --- src/txmempool.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/txmempool.cpp b/src/txmempool.cpp index b8be3e080e7..27b4c886093 100644 --- a/src/txmempool.cpp +++ b/src/txmempool.cpp @@ -221,7 +221,9 @@ void CTxMemPool::Apply(ChangeSet* changeset) addNewTransaction(it); } - m_txgraph->DoWork(POST_CHANGE_WORK); + if (!m_txgraph->DoWork(POST_CHANGE_WORK)) { + LogDebug(BCLog::MEMPOOL, "Mempool in non-optimal ordering after addition(s)."); + } } void CTxMemPool::addNewTransaction(CTxMemPool::txiter newit) @@ -378,7 +380,9 @@ void CTxMemPool::removeForReorg(CChain& chain, std::function check for (indexed_transaction_set::const_iterator it = mapTx.begin(); it != mapTx.end(); it++) { assert(TestLockPointValidity(chain, it->GetLockPoints())); } - m_txgraph->DoWork(POST_CHANGE_WORK); + if (!m_txgraph->DoWork(POST_CHANGE_WORK)) { + LogDebug(BCLog::MEMPOOL, "Mempool in non-optimal ordering after reorg."); + } } void CTxMemPool::removeConflicts(const CTransaction &tx) @@ -421,7 +425,9 @@ void CTxMemPool::removeForBlock(const std::vector& vtx, unsigne } lastRollingFeeUpdate = GetTime(); blockSinceLastRollingFeeBump = true; - m_txgraph->DoWork(POST_CHANGE_WORK); + if (!m_txgraph->DoWork(POST_CHANGE_WORK)) { + LogDebug(BCLog::MEMPOOL, "Mempool in non-optimal ordering after block."); + } } void CTxMemPool::check(const CCoinsViewCache& active_coins_tip, int64_t spendheight) const