| 466 | } |
| 467 | |
| 468 | void CTxMemPool::removeRecursive(const CTransaction &origTx, MemPoolRemovalReason reason) |
| 469 | { |
| 470 | // Remove transaction from memory pool |
| 471 | { |
| 472 | LOCK(cs); |
| 473 | setEntries txToRemove; |
| 474 | txiter origit = mapTx.find(origTx.GetHash()); |
| 475 | if (origit != mapTx.end()) { |
| 476 | txToRemove.insert(origit); |
| 477 | } else { |
| 478 | // When recursively removing but origTx isn't in the mempool |
| 479 | // be sure to remove any children that are in the pool. This can |
| 480 | // happen during chain re-orgs if origTx isn't re-accepted into |
| 481 | // the mempool for any reason. |
| 482 | for (unsigned int i = 0; i < origTx.vout.size(); i++) { |
| 483 | auto it = mapNextTx.find(COutPoint(origTx.GetHash(), i)); |
| 484 | if (it == mapNextTx.end()) |
| 485 | continue; |
| 486 | txiter nextit = mapTx.find(it->second->GetHash()); |
| 487 | assert(nextit != mapTx.end()); |
| 488 | txToRemove.insert(nextit); |
| 489 | } |
| 490 | } |
| 491 | setEntries setAllRemoves; |
| 492 | for (txiter it : txToRemove) { |
| 493 | CalculateDescendants(it, setAllRemoves); |
| 494 | } |
| 495 | |
| 496 | RemoveStaged(setAllRemoves, false, reason); |
| 497 | } |
| 498 | } |
| 499 | |
| 500 | void CTxMemPool::removeForReorg(const CCoinsViewCache *pcoins, unsigned int nMemPoolHeight, int flags) |
| 501 | { |