| 501 | } |
| 502 | |
| 503 | void CTxMemPool::removeRecursive(const CTransaction &origTx, MemPoolRemovalReason reason) |
| 504 | { |
| 505 | // Remove transaction from memory pool |
| 506 | { |
| 507 | LOCK(cs); |
| 508 | setEntries txToRemove; |
| 509 | txiter origit = mapTx.find(origTx.GetHash()); |
| 510 | if (origit != mapTx.end()) { |
| 511 | txToRemove.insert(origit); |
| 512 | } else { |
| 513 | // When recursively removing but origTx isn't in the mempool |
| 514 | // be sure to remove any children that are in the pool. This can |
| 515 | // happen during chain re-orgs if origTx isn't re-accepted into |
| 516 | // the mempool for any reason. |
| 517 | for (unsigned int i = 0; i < origTx.vout.size(); i++) { |
| 518 | auto it = mapNextTx.find(COutPoint(origTx.GetHash(), i)); |
| 519 | if (it == mapNextTx.end()) |
| 520 | continue; |
| 521 | txiter nextit = mapTx.find(it->second->GetHash()); |
| 522 | assert(nextit != mapTx.end()); |
| 523 | txToRemove.insert(nextit); |
| 524 | } |
| 525 | } |
| 526 | setEntries setAllRemoves; |
| 527 | for (txiter it : txToRemove) { |
| 528 | CalculateDescendants(it, setAllRemoves); |
| 529 | } |
| 530 | |
| 531 | RemoveStaged(setAllRemoves, false, reason); |
| 532 | } |
| 533 | } |
| 534 | |
| 535 | void CTxMemPool::removeForReorg(const CCoinsViewCache *pcoins, unsigned int nMemPoolHeight, int flags) |
| 536 | { |