| 623 | } |
| 624 | |
| 625 | void CTxMemPool::removeRecursive(const CTransaction &origTx, MemPoolRemovalReason reason) |
| 626 | { |
| 627 | // Remove transaction from memory pool |
| 628 | AssertLockHeld(cs); |
| 629 | setEntries txToRemove; |
| 630 | txiter origit = mapTx.find(origTx.GetHash()); |
| 631 | if (origit != mapTx.end()) { |
| 632 | txToRemove.insert(origit); |
| 633 | } else { |
| 634 | // When recursively removing but origTx isn't in the mempool |
| 635 | // be sure to remove any children that are in the pool. This can |
| 636 | // happen during chain re-orgs if origTx isn't re-accepted into |
| 637 | // the mempool for any reason. |
| 638 | for (unsigned int i = 0; i < origTx.vout.size(); i++) { |
| 639 | auto it = mapNextTx.find(COutPoint(origTx.GetHash(), i)); |
| 640 | if (it == mapNextTx.end()) |
| 641 | continue; |
| 642 | txiter nextit = mapTx.find(it->second->GetHash()); |
| 643 | assert(nextit != mapTx.end()); |
| 644 | txToRemove.insert(nextit); |
| 645 | } |
| 646 | } |
| 647 | setEntries setAllRemoves; |
| 648 | for (txiter it : txToRemove) { |
| 649 | CalculateDescendants(it, setAllRemoves); |
| 650 | } |
| 651 | |
| 652 | RemoveStaged(setAllRemoves, false, reason); |
| 653 | } |
| 654 | |
| 655 | void CTxMemPool::removeForReorg(CChain& chain, std::function<bool(txiter)> check_final_and_mature) |
| 656 | { |