MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / removeForReorg

Method removeForReorg

src/txmempool.cpp:360–386  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

358}
359
360void 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
388void CTxMemPool::removeConflicts(const CTransaction &tx)
389{

Callers 1

validation.cppFile · 0.80

Calls 6

TestLockPointValidityFunction · 0.85
GetDescendantsUnionMethod · 0.80
DoWorkMethod · 0.80
beginMethod · 0.45
endMethod · 0.45
emplace_backMethod · 0.45

Tested by

no test coverage detected