@@ -1076,32 +1076,34 @@ MempoolAcceptResult MemPoolAccept::AcceptSingleTransaction(const CTransactionRef
10761076
10771077/* * (try to) add transaction to memory pool with a specified acceptance time **/
10781078static MempoolAcceptResult AcceptToMemoryPoolWithTime (const CChainParams& chainparams, CTxMemPool& pool,
1079+ CChainState& active_chainstate,
10791080 const CTransactionRef &tx, int64_t nAcceptTime,
10801081 bool bypass_limits, bool test_accept)
10811082 EXCLUSIVE_LOCKS_REQUIRED(cs_main)
10821083{
10831084 std::vector<COutPoint> coins_to_uncache;
10841085 MemPoolAccept::ATMPArgs args { chainparams, nAcceptTime, bypass_limits, coins_to_uncache, test_accept };
10851086
1086- const MempoolAcceptResult result = MemPoolAccept (pool, ::ChainstateActive ()).AcceptSingleTransaction (tx, args);
1087+ assert (std::addressof (::ChainstateActive ()) == std::addressof (active_chainstate));
1088+ const MempoolAcceptResult result = MemPoolAccept (pool, active_chainstate).AcceptSingleTransaction (tx, args);
10871089 if (result.m_result_type != MempoolAcceptResult::ResultType::VALID) {
10881090 // Remove coins that were not present in the coins cache before calling ATMPW;
10891091 // this is to prevent memory DoS in case we receive a large number of
10901092 // invalid transactions that attempt to overrun the in-memory coins cache
10911093 // (`CCoinsViewCache::cacheCoins`).
10921094
10931095 for (const COutPoint& hashTx : coins_to_uncache)
1094- ::ChainstateActive () .CoinsTip().Uncache(hashTx);
1096+ active_chainstate .CoinsTip ().Uncache (hashTx);
10951097 }
10961098 // After we've (potentially) uncached entries, ensure our coins cache is still within its size limits
10971099 BlockValidationState state_dummy;
1098- ::ChainstateActive () .FlushStateToDisk(chainparams, state_dummy, FlushStateMode::PERIODIC);
1100+ active_chainstate .FlushStateToDisk (chainparams, state_dummy, FlushStateMode::PERIODIC);
10991101 return result;
11001102}
11011103
11021104MempoolAcceptResult AcceptToMemoryPool (CTxMemPool& pool, const CTransactionRef &tx, bool bypass_limits, bool test_accept)
11031105{
1104- return AcceptToMemoryPoolWithTime (Params (), pool, tx, GetTime (), bypass_limits, test_accept);
1106+ return AcceptToMemoryPoolWithTime (Params (), pool, :: ChainstateActive (), tx, GetTime (), bypass_limits, test_accept);
11051107}
11061108
11071109CTransactionRef GetTransaction (const CBlockIndex* const block_index, const CTxMemPool* const mempool, const uint256& hash, const Consensus::Params& consensusParams, uint256& hashBlock)
@@ -5050,7 +5052,7 @@ bool LoadMempool(CTxMemPool& pool)
50505052 }
50515053 if (nTime > nNow - nExpiryTimeout) {
50525054 LOCK (cs_main);
5053- if (AcceptToMemoryPoolWithTime (chainparams, pool, tx, nTime, false /* bypass_limits */ ,
5055+ if (AcceptToMemoryPoolWithTime (chainparams, pool, :: ChainstateActive (), tx, nTime, false /* bypass_limits */ ,
50545056 false /* test_accept */ ).m_result_type == MempoolAcceptResult::ResultType::VALID) {
50555057 ++count;
50565058 } else {
0 commit comments