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.
This commit is contained in:
Greg Sanders
2026-02-18 09:49:53 -05:00
parent 2706758dc3
commit a3fb3dd55c

View File

@@ -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<bool(txiter)> 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<CTransactionRef>& 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