@@ -503,16 +503,17 @@ void CTxMemPool::removeRecursive(const CTransaction &origTx, MemPoolRemovalReaso
503
503
RemoveStaged (setAllRemoves, false , reason);
504
504
}
505
505
506
- void CTxMemPool::removeForReorg (const CCoinsViewCache *pcoins, unsigned int nMemPoolHeight , int flags)
506
+ void CTxMemPool::removeForReorg (CChainState& active_chainstate , int flags)
507
507
{
508
508
// Remove transactions spending a coinbase which are now immature and no-longer-final transactions
509
509
AssertLockHeld (cs);
510
510
setEntries txToRemove;
511
511
for (indexed_transaction_set::const_iterator it = mapTx.begin (); it != mapTx.end (); it++) {
512
512
const CTransaction& tx = it->GetTx ();
513
513
LockPoints lp = it->GetLockPoints ();
514
- bool validLP = TestLockPointValidity (::ChainActive (), &lp);
515
- if (!CheckFinalTx (::ChainActive ().Tip (), tx, flags) || !CheckSequenceLocks (::ChainstateActive (), *this , tx, flags, &lp, validLP)) {
514
+ assert (std::addressof (::ChainstateActive ()) == std::addressof (active_chainstate));
515
+ bool validLP = TestLockPointValidity (active_chainstate.m_chain , &lp);
516
+ if (!CheckFinalTx (active_chainstate.m_chain .Tip (), tx, flags) || !CheckSequenceLocks (active_chainstate, *this , tx, flags, &lp, validLP)) {
516
517
// Note if CheckSequenceLocks fails the LockPoints may still be invalid
517
518
// So it's critical that we remove the tx and not depend on the LockPoints.
518
519
txToRemove.insert (it);
@@ -521,8 +522,9 @@ void CTxMemPool::removeForReorg(const CCoinsViewCache *pcoins, unsigned int nMem
521
522
indexed_transaction_set::const_iterator it2 = mapTx.find (txin.prevout .hash );
522
523
if (it2 != mapTx.end ())
523
524
continue ;
524
- const Coin &coin = pcoins-> AccessCoin (txin.prevout );
525
+ const Coin &coin = active_chainstate. CoinsTip (). AccessCoin (txin.prevout );
525
526
if (m_check_ratio != 0 ) assert (!coin.IsSpent ());
527
+ unsigned int nMemPoolHeight = active_chainstate.m_chain .Tip ()->nHeight + 1 ;
526
528
if (coin.IsSpent () || (coin.IsCoinBase () && ((signed long )nMemPoolHeight) - coin.nHeight < COINBASE_MATURITY)) {
527
529
txToRemove.insert (it);
528
530
break ;
0 commit comments