Skip to content

Commit 0fdb619

Browse files
committed
[validation] Always call mempool.check() after processing a new transaction
CTxMemPool::check() will carry out internal consistency checks 1/n times, where n is set by the `-checkmempool` configuration option. By default, mempool consistency checks are disabled entirely on mainnet. Therefore, this change has no effect on mainnet nodes running with default configuration. It simply removes the responsibility to trigger mempool consistency checks from net_processing.
1 parent 2c64270 commit 0fdb619

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

src/net_processing.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2300,8 +2300,6 @@ void PeerManagerImpl::ProcessOrphanTx(std::set<uint256>& orphan_work_set)
23002300
break;
23012301
}
23022302
}
2303-
CChainState& active_chainstate = m_chainman.ActiveChainstate();
2304-
m_mempool.check(active_chainstate.CoinsTip(), active_chainstate.m_chain.Height() + 1);
23052303
}
23062304

23072305
bool PeerManagerImpl::PrepareBlockFilterRequest(CNode& peer,
@@ -3264,8 +3262,6 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
32643262
const TxValidationState& state = result.m_state;
32653263

32663264
if (result.m_result_type == MempoolAcceptResult::ResultType::VALID) {
3267-
CChainState& active_chainstate = m_chainman.ActiveChainstate();
3268-
m_mempool.check(active_chainstate.CoinsTip(), active_chainstate.m_chain.Height() + 1);
32693265
// As this version of the transaction was acceptable, we can forget about any
32703266
// requests for it.
32713267
m_txrequest.ForgetTxHash(tx.GetHash());

src/validation.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3429,7 +3429,9 @@ MempoolAcceptResult ChainstateManager::ProcessTransaction(const CTransactionRef&
34293429
state.Invalid(TxValidationResult::TX_NO_MEMPOOL, "no-mempool");
34303430
return MempoolAcceptResult::Failure(state);
34313431
}
3432-
return AcceptToMemoryPool(active_chainstate, *active_chainstate.m_mempool, tx, /*bypass_limits=*/ false, test_accept);
3432+
auto result = AcceptToMemoryPool(active_chainstate, *active_chainstate.m_mempool, tx, /*bypass_limits=*/ false, test_accept);
3433+
active_chainstate.m_mempool->check(active_chainstate.CoinsTip(), active_chainstate.m_chain.Height() + 1);
3434+
return result;
34333435
}
34343436

34353437
bool TestBlockValidity(BlockValidationState& state,

0 commit comments

Comments
 (0)