MCPcopy Create free account
hub / github.com/ElementsProject/elements / removeUnchecked

Method removeUnchecked

src/txmempool.cpp:557–593  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

555}
556
557void CTxMemPool::removeUnchecked(txiter it, MemPoolRemovalReason reason)
558{
559 // We increment mempool sequence value no matter removal reason
560 // even if not directly reported below.
561 uint64_t mempool_sequence = GetAndIncrementSequence();
562
563 if (reason != MemPoolRemovalReason::BLOCK) {
564 // Notify clients that a transaction has been removed from the mempool
565 // for any reason except being included in a block. Clients interested
566 // in transactions included in blocks can subscribe to the BlockConnected
567 // notification.
568 GetMainSignals().TransactionRemovedFromMempool(it->GetSharedTx(), reason, mempool_sequence);
569 }
570
571 const uint256 hash = it->GetTx().GetHash();
572 for (const CTxIn& txin : it->GetTx().vin)
573 mapNextTx.erase(txin.prevout);
574
575 RemoveUnbroadcastTx(hash, true /* add logging because unchecked */ );
576
577 if (vTxHashes.size() > 1) {
578 vTxHashes[it->vTxHashesIdx] = std::move(vTxHashes.back());
579 vTxHashes[it->vTxHashesIdx].second->vTxHashesIdx = it->vTxHashesIdx;
580 vTxHashes.pop_back();
581 if (vTxHashes.size() * 2 < vTxHashes.capacity())
582 vTxHashes.shrink_to_fit();
583 } else
584 vTxHashes.clear();
585
586 totalTxSize -= it->GetTxSize();
587 m_total_fee -= it->GetFee();
588 cachedInnerUsage -= it->DynamicMemoryUsage();
589 cachedInnerUsage -= memusage::DynamicUsage(it->GetMemPoolParentsConst()) + memusage::DynamicUsage(it->GetMemPoolChildrenConst());
590 mapTx.erase(it);
591 nTransactionsUpdated++;
592 if (minerPolicyEstimator) {minerPolicyEstimator->removeTx(hash, false);}
593}
594
595// Calculates descendants of entry that are not already in setDescendants, and adds to
596// setDescendants. Assumes entryit is already a tx in the mempool and CTxMemPoolEntry::m_children

Callers

nothing calls this directly

Calls 15

DynamicUsageFunction · 0.85
GetSharedTxMethod · 0.80
GetTxMethod · 0.80
GetFeeMethod · 0.80
removeTxMethod · 0.80
GetHashMethod · 0.45
eraseMethod · 0.45
sizeMethod · 0.45
pop_backMethod · 0.45
capacityMethod · 0.45
shrink_to_fitMethod · 0.45

Tested by

no test coverage detected