MCPcopy Create free account
hub / github.com/LUX-Core/lux / removeForReorg

Method removeForReorg

src/txmempool.cpp:535–571  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

533}
534
535void CTxMemPool::removeForReorg(const CCoinsViewCache *pcoins, unsigned int nMemPoolHeight, int flags)
536{
537 // Remove transactions spending a coinbase which are now immature and no-longer-final transactions
538 LOCK(cs);
539 setEntries txToRemove;
540 for (indexed_transaction_set::const_iterator it = mapTx.begin(); it != mapTx.end(); it++) {
541 const CTransaction& tx = it->GetTx();
542 LockPoints lp = it->GetLockPoints();
543 bool validLP = TestLockPointValidity(&lp);
544 if (!CheckFinalTx(tx, flags) || !CheckSequenceLocks(tx, flags, &lp, validLP)) {
545 // Note if CheckSequenceLocks fails the LockPoints may still be invalid
546 // So it's critical that we remove the tx and not depend on the LockPoints.
547 txToRemove.insert(it);
548 } else if (it->GetSpendsCoinbase()) {
549 for (const CTxIn& txin : tx.vin) {
550 indexed_transaction_set::const_iterator it2 = mapTx.find(txin.prevout.hash);
551 if (it2 != mapTx.end())
552 continue;
553 const CCoins* coins = pcoins->AccessCoins(txin.prevout.hash);
554 const int nMaturity = Params().COINBASE_MATURITY();
555 if (nCheckFrequency != 0) assert(coins);
556 if (!coins || (coins->IsCoinGenerated() && ((signed long)nMemPoolHeight) - coins->nHeight < nMaturity)) {
557 txToRemove.insert(it);
558 break;
559 }
560 }
561 }
562 if (!validLP) {
563 mapTx.modify(it, update_lock_points(lp));
564 }
565 }
566 setEntries setAllRemoves;
567 for (txiter it : txToRemove) {
568 CalculateDescendants(it, setAllRemoves);
569 }
570 RemoveStaged(setAllRemoves, false, MemPoolRemovalReason::REORG);
571}
572
573void CTxMemPool::removeConflicts(const CTransaction &tx)
574{

Callers

nothing calls this directly

Calls 13

TestLockPointValidityFunction · 0.85
CheckFinalTxFunction · 0.85
CheckSequenceLocksFunction · 0.85
update_lock_pointsClass · 0.85
GetSpendsCoinbaseMethod · 0.80
AccessCoinsMethod · 0.80
COINBASE_MATURITYMethod · 0.80
ParamsClass · 0.70
beginMethod · 0.45
endMethod · 0.45
insertMethod · 0.45
findMethod · 0.45

Tested by

no test coverage detected