| 653 | } |
| 654 | |
| 655 | void CTxMemPool::removeForReorg(CChain& chain, std::function<bool(txiter)> check_final_and_mature) |
| 656 | { |
| 657 | // Remove transactions spending a coinbase which are now immature and no-longer-final transactions |
| 658 | AssertLockHeld(cs); |
| 659 | AssertLockHeld(::cs_main); |
| 660 | |
| 661 | setEntries txToRemove; |
| 662 | for (indexed_transaction_set::const_iterator it = mapTx.begin(); it != mapTx.end(); it++) { |
| 663 | if (check_final_and_mature(it)) txToRemove.insert(it); |
| 664 | |
| 665 | // On re-org, remove *all* peg-in and PAK-based peg-outs due to possible |
| 666 | // invalidity from dynafed transitions |
| 667 | // TODO: Only boot out now-invalid transactions. Re-orgs are very rare in |
| 668 | // federated systems but can occasionally happen due to consensus algorithm. |
| 669 | |
| 670 | // Little hack to quickly check if any outputs are PAK ones |
| 671 | // by sending in empty(reject) list. |
| 672 | const CTransaction& tx = it->GetTx(); |
| 673 | if (!IsPAKValidTx(tx, CPAKList(), Params().ParentGenesisBlockHash(), Params().GetConsensus().pegged_asset)) { |
| 674 | txToRemove.insert(it); |
| 675 | continue; |
| 676 | } |
| 677 | for (const auto& input : tx.vin) { |
| 678 | if (input.m_is_pegin) { |
| 679 | txToRemove.insert(it); |
| 680 | break; |
| 681 | } |
| 682 | } |
| 683 | } |
| 684 | setEntries setAllRemoves; |
| 685 | for (txiter it : txToRemove) { |
| 686 | CalculateDescendants(it, setAllRemoves); |
| 687 | } |
| 688 | RemoveStaged(setAllRemoves, false, MemPoolRemovalReason::REORG); |
| 689 | for (indexed_transaction_set::const_iterator it = mapTx.begin(); it != mapTx.end(); it++) { |
| 690 | assert(TestLockPointValidity(chain, it->GetLockPoints())); |
| 691 | } |
| 692 | } |
| 693 | |
| 694 | void CTxMemPool::removeConflicts(const CTransaction &tx) |
| 695 | { |
no test coverage detected