@@ -373,10 +373,11 @@ static bool IsCurrentForFeeEstimation(CChainState& active_chainstate) EXCLUSIVE_
373
373
* and instead just erase from the mempool as needed.
374
374
*/
375
375
376
- static void UpdateMempoolForReorg (CTxMemPool& mempool, DisconnectedBlockTransactions& disconnectpool, bool fAddToMempool ) EXCLUSIVE_LOCKS_REQUIRED(cs_main, mempool.cs)
376
+ static void UpdateMempoolForReorg (CChainState& active_chainstate, CTxMemPool& mempool, DisconnectedBlockTransactions& disconnectpool, bool fAddToMempool ) EXCLUSIVE_LOCKS_REQUIRED(cs_main, mempool.cs)
377
377
{
378
378
AssertLockHeld (cs_main);
379
379
AssertLockHeld (mempool.cs );
380
+ assert (std::addressof (::ChainstateActive ()) == std::addressof (active_chainstate));
380
381
std::vector<uint256> vHashUpdate;
381
382
// disconnectpool's insertion_order index sorts the entries from
382
383
// oldest to newest, but the oldest entry will be the last tx from the
@@ -388,7 +389,7 @@ static void UpdateMempoolForReorg(CTxMemPool& mempool, DisconnectedBlockTransact
388
389
while (it != disconnectpool.queuedTx .get <insertion_order>().rend ()) {
389
390
// ignore validation errors in resurrected transactions
390
391
if (!fAddToMempool || (*it)->IsCoinBase () ||
391
- AcceptToMemoryPool (:: ChainstateActive () , mempool, *it, true /* bypass_limits */ ).m_result_type != MempoolAcceptResult::ResultType::VALID) {
392
+ AcceptToMemoryPool (active_chainstate , mempool, *it, true /* bypass_limits */ ).m_result_type != MempoolAcceptResult::ResultType::VALID) {
392
393
// If the transaction doesn't make it in to the mempool, remove any
393
394
// transactions that depend on it (which would now be orphans).
394
395
mempool.removeRecursive (**it, MemPoolRemovalReason::REORG);
@@ -406,9 +407,9 @@ static void UpdateMempoolForReorg(CTxMemPool& mempool, DisconnectedBlockTransact
406
407
mempool.UpdateTransactionsFromBlock (vHashUpdate);
407
408
408
409
// We also need to remove any now-immature transactions
409
- mempool.removeForReorg (:: ChainstateActive () , STANDARD_LOCKTIME_VERIFY_FLAGS);
410
+ mempool.removeForReorg (active_chainstate , STANDARD_LOCKTIME_VERIFY_FLAGS);
410
411
// Re-limit mempool size, in case we added any transactions
411
- LimitMempoolSize (mempool, :: ChainstateActive () .CoinsTip (), gArgs .GetArg (" -maxmempool" , DEFAULT_MAX_MEMPOOL_SIZE) * 1000000 , std::chrono::hours{gArgs .GetArg (" -mempoolexpiry" , DEFAULT_MEMPOOL_EXPIRY)});
412
+ LimitMempoolSize (mempool, active_chainstate .CoinsTip (), gArgs .GetArg (" -maxmempool" , DEFAULT_MAX_MEMPOOL_SIZE) * 1000000 , std::chrono::hours{gArgs .GetArg (" -mempoolexpiry" , DEFAULT_MEMPOOL_EXPIRY)});
412
413
}
413
414
414
415
/* *
@@ -2716,7 +2717,7 @@ bool CChainState::ActivateBestChainStep(BlockValidationState& state, const CChai
2716
2717
if (!DisconnectTip (state, chainparams, &disconnectpool)) {
2717
2718
// This is likely a fatal error, but keep the mempool consistent,
2718
2719
// just in case. Only remove from the mempool in this case.
2719
- UpdateMempoolForReorg (m_mempool, disconnectpool, false );
2720
+ UpdateMempoolForReorg (:: ChainstateActive (), m_mempool, disconnectpool, false );
2720
2721
2721
2722
// If we're unable to disconnect a block during normal operation,
2722
2723
// then that is a failure of our local system -- we should abort
@@ -2760,7 +2761,7 @@ bool CChainState::ActivateBestChainStep(BlockValidationState& state, const CChai
2760
2761
// A system error occurred (disk space, database error, ...).
2761
2762
// Make the mempool consistent with the current tip, just in case
2762
2763
// any observers try to use it before shutdown.
2763
- UpdateMempoolForReorg (m_mempool, disconnectpool, false );
2764
+ UpdateMempoolForReorg (:: ChainstateActive (), m_mempool, disconnectpool, false );
2764
2765
return false ;
2765
2766
}
2766
2767
} else {
@@ -2777,7 +2778,7 @@ bool CChainState::ActivateBestChainStep(BlockValidationState& state, const CChai
2777
2778
if (fBlocksDisconnected ) {
2778
2779
// If any blocks were disconnected, disconnectpool may be non empty. Add
2779
2780
// any disconnected transactions back to the mempool.
2780
- UpdateMempoolForReorg (m_mempool, disconnectpool, true );
2781
+ UpdateMempoolForReorg (:: ChainstateActive (), m_mempool, disconnectpool, true );
2781
2782
}
2782
2783
m_mempool.check (&CoinsTip ());
2783
2784
@@ -3014,7 +3015,7 @@ bool CChainState::InvalidateBlock(BlockValidationState& state, const CChainParam
3014
3015
// transactions back to the mempool if disconnecting was successful,
3015
3016
// and we're not doing a very deep invalidation (in which case
3016
3017
// keeping the mempool up to date is probably futile anyway).
3017
- UpdateMempoolForReorg (m_mempool, disconnectpool, /* fAddToMempool = */ (++disconnected <= 10 ) && ret);
3018
+ UpdateMempoolForReorg (:: ChainstateActive (), m_mempool, disconnectpool, /* fAddToMempool = */ (++disconnected <= 10 ) && ret);
3018
3019
if (!ret) return false ;
3019
3020
assert (invalid_walk_tip->pprev == m_chain.Tip ());
3020
3021
0 commit comments