@@ -541,24 +541,24 @@ void CTxMemPool::removeForReorg(const CCoinsViewCache *pcoins, unsigned int nMem
541
541
{
542
542
// Remove transactions spending a coinbase which are now immature and no-longer-final transactions
543
543
LOCK (cs);
544
- list<CTransaction> transactionsToRemove ;
544
+ setEntries txToRemove ;
545
545
for (indexed_transaction_set::const_iterator it = mapTx.begin (); it != mapTx.end (); it++) {
546
546
const CTransaction& tx = it->GetTx ();
547
547
LockPoints lp = it->GetLockPoints ();
548
548
bool validLP = TestLockPointValidity (&lp);
549
549
if (!CheckFinalTx (tx, flags) || !CheckSequenceLocks (tx, flags, &lp, validLP)) {
550
550
// Note if CheckSequenceLocks fails the LockPoints may still be invalid
551
551
// So it's critical that we remove the tx and not depend on the LockPoints.
552
- transactionsToRemove. push_back (tx );
552
+ txToRemove. insert (it );
553
553
} else if (it->GetSpendsCoinbase ()) {
554
554
BOOST_FOREACH (const CTxIn& txin, tx.vin ) {
555
555
indexed_transaction_set::const_iterator it2 = mapTx.find (txin.prevout .hash );
556
556
if (it2 != mapTx.end ())
557
557
continue ;
558
558
const CCoins *coins = pcoins->AccessCoins (txin.prevout .hash );
559
- if (nCheckFrequency != 0 ) assert (coins);
559
+ if (nCheckFrequency != 0 ) assert (coins);
560
560
if (!coins || (coins->IsCoinBase () && ((signed long )nMemPoolHeight) - coins->nHeight < COINBASE_MATURITY)) {
561
- transactionsToRemove. push_back (tx );
561
+ txToRemove. insert (it );
562
562
break ;
563
563
}
564
564
}
@@ -567,10 +567,11 @@ void CTxMemPool::removeForReorg(const CCoinsViewCache *pcoins, unsigned int nMem
567
567
mapTx.modify (it, update_lock_points (lp));
568
568
}
569
569
}
570
- BOOST_FOREACH ( const CTransaction& tx, transactionsToRemove) {
571
- list<CTransaction> removed;
572
- removeRecursive (tx, removed );
570
+ setEntries setAllRemoves;
571
+ for (txiter it : txToRemove) {
572
+ CalculateDescendants (it, setAllRemoves );
573
573
}
574
+ RemoveStaged (setAllRemoves, false );
574
575
}
575
576
576
577
void CTxMemPool::removeConflicts (const CTransaction &tx, std::list<CTransaction>& removed)
0 commit comments