| 533 | } |
| 534 | |
| 535 | void CTxMemPool::removeForReorg(const CCoinsViewCache *pcoins, unsigned int nMemPoolHeight, int flags) |
| 536 | { |
| 537 | // Remove transactions spending a coinbase which are now immature and no-longer-final transactions |
| 538 | LOCK(cs); |
| 539 | setEntries txToRemove; |
| 540 | for (indexed_transaction_set::const_iterator it = mapTx.begin(); it != mapTx.end(); it++) { |
| 541 | const CTransaction& tx = it->GetTx(); |
| 542 | LockPoints lp = it->GetLockPoints(); |
| 543 | bool validLP = TestLockPointValidity(&lp); |
| 544 | if (!CheckFinalTx(tx, flags) || !CheckSequenceLocks(tx, flags, &lp, validLP)) { |
| 545 | // Note if CheckSequenceLocks fails the LockPoints may still be invalid |
| 546 | // So it's critical that we remove the tx and not depend on the LockPoints. |
| 547 | txToRemove.insert(it); |
| 548 | } else if (it->GetSpendsCoinbase()) { |
| 549 | for (const CTxIn& txin : tx.vin) { |
| 550 | indexed_transaction_set::const_iterator it2 = mapTx.find(txin.prevout.hash); |
| 551 | if (it2 != mapTx.end()) |
| 552 | continue; |
| 553 | const CCoins* coins = pcoins->AccessCoins(txin.prevout.hash); |
| 554 | const int nMaturity = Params().COINBASE_MATURITY(); |
| 555 | if (nCheckFrequency != 0) assert(coins); |
| 556 | if (!coins || (coins->IsCoinGenerated() && ((signed long)nMemPoolHeight) - coins->nHeight < nMaturity)) { |
| 557 | txToRemove.insert(it); |
| 558 | break; |
| 559 | } |
| 560 | } |
| 561 | } |
| 562 | if (!validLP) { |
| 563 | mapTx.modify(it, update_lock_points(lp)); |
| 564 | } |
| 565 | } |
| 566 | setEntries setAllRemoves; |
| 567 | for (txiter it : txToRemove) { |
| 568 | CalculateDescendants(it, setAllRemoves); |
| 569 | } |
| 570 | RemoveStaged(setAllRemoves, false, MemPoolRemovalReason::REORG); |
| 571 | } |
| 572 | |
| 573 | void CTxMemPool::removeConflicts(const CTransaction &tx) |
| 574 | { |
nothing calls this directly
no test coverage detected