| 358 | } |
| 359 | |
| 360 | void CTxMemPool::removeForReorg(CChain& chain, std::function<bool(txiter)> check_final_and_mature) |
| 361 | { |
| 362 | // Remove transactions spending a coinbase which are now immature and no-longer-final transactions |
| 363 | AssertLockHeld(cs); |
| 364 | AssertLockHeld(::cs_main); |
| 365 | Assume(!m_have_changeset); |
| 366 | |
| 367 | std::vector<const TxGraph::Ref*> to_remove; |
| 368 | for (txiter it = mapTx.begin(); it != mapTx.end(); it++) { |
| 369 | if (check_final_and_mature(it)) { |
| 370 | to_remove.emplace_back(&*it); |
| 371 | } |
| 372 | } |
| 373 | |
| 374 | auto all_to_remove = m_txgraph->GetDescendantsUnion(to_remove, TxGraph::Level::MAIN); |
| 375 | |
| 376 | for (auto ref : all_to_remove) { |
| 377 | auto it = mapTx.iterator_to(static_cast<const CTxMemPoolEntry&>(*ref)); |
| 378 | removeUnchecked(it, MemPoolRemovalReason::REORG); |
| 379 | } |
| 380 | for (indexed_transaction_set::const_iterator it = mapTx.begin(); it != mapTx.end(); it++) { |
| 381 | assert(TestLockPointValidity(chain, it->GetLockPoints())); |
| 382 | } |
| 383 | if (!m_txgraph->DoWork(/*max_cost=*/POST_CHANGE_COST)) { |
| 384 | LogDebug(BCLog::MEMPOOL, "Mempool in non-optimal ordering after reorg."); |
| 385 | } |
| 386 | } |
| 387 | |
| 388 | void CTxMemPool::removeConflicts(const CTransaction &tx) |
| 389 | { |
no test coverage detected