Skip to content

Commit 229bc37

Browse files
committed
validation: Pass in chainstate to ::AcceptToMemoryPool
1 parent d0da7ea commit 229bc37

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/validation.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ static void UpdateMempoolForReorg(CTxMemPool& mempool, DisconnectedBlockTransact
387387
while (it != disconnectpool.queuedTx.get<insertion_order>().rend()) {
388388
// ignore validation errors in resurrected transactions
389389
if (!fAddToMempool || (*it)->IsCoinBase() ||
390-
AcceptToMemoryPool(mempool, *it, true /* bypass_limits */).m_result_type != MempoolAcceptResult::ResultType::VALID) {
390+
AcceptToMemoryPool(::ChainstateActive(), mempool, *it, true /* bypass_limits */).m_result_type != MempoolAcceptResult::ResultType::VALID) {
391391
// If the transaction doesn't make it in to the mempool, remove any
392392
// transactions that depend on it (which would now be orphans).
393393
mempool.removeRecursive(**it, MemPoolRemovalReason::REORG);
@@ -1103,7 +1103,13 @@ static MempoolAcceptResult AcceptToMemoryPoolWithTime(const CChainParams& chainp
11031103

11041104
MempoolAcceptResult AcceptToMemoryPool(CTxMemPool& pool, const CTransactionRef &tx, bool bypass_limits, bool test_accept)
11051105
{
1106-
return AcceptToMemoryPoolWithTime(Params(), pool, ::ChainstateActive(), tx, GetTime(), bypass_limits, test_accept);
1106+
return AcceptToMemoryPool(::ChainstateActive(), pool, tx, bypass_limits, test_accept);
1107+
}
1108+
1109+
MempoolAcceptResult AcceptToMemoryPool(CChainState& active_chainstate, CTxMemPool& pool, const CTransactionRef& tx, bool bypass_limits, bool test_accept)
1110+
{
1111+
assert(std::addressof(::ChainstateActive()) == std::addressof(active_chainstate));
1112+
return AcceptToMemoryPoolWithTime(Params(), pool, active_chainstate, tx, GetTime(), bypass_limits, test_accept);
11071113
}
11081114

11091115
CTransactionRef GetTransaction(const CBlockIndex* const block_index, const CTxMemPool* const mempool, const uint256& hash, const Consensus::Params& consensusParams, uint256& hashBlock)

src/validation.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,8 @@ struct MempoolAcceptResult {
225225
*/
226226
MempoolAcceptResult AcceptToMemoryPool(CTxMemPool& pool, const CTransactionRef& tx,
227227
bool bypass_limits, bool test_accept=false) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
228+
MempoolAcceptResult AcceptToMemoryPool(CChainState& active_chainstate, CTxMemPool& pool, const CTransactionRef& tx,
229+
bool bypass_limits, bool test_accept=false) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
228230

229231
/** Get the BIP9 state for a given deployment at the current tip. */
230232
ThresholdState VersionBitsTipState(const Consensus::Params& params, Consensus::DeploymentPos pos);

0 commit comments

Comments
 (0)