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