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

Method UpdateTransactionsFromBlock

src/txmempool.cpp:91–120  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

89}
90
91void CTxMemPool::UpdateTransactionsFromBlock(const std::vector<Txid>& vHashesToUpdate)
92{
93 AssertLockHeld(cs);
94
95 // Iterate in reverse, so that whenever we are looking at a transaction
96 // we are sure that all in-mempool descendants have already been processed.
97 for (const Txid& hash : vHashesToUpdate | std::views::reverse) {
98 // calculate children from mapNextTx
99 txiter it = mapTx.find(hash);
100 if (it == mapTx.end()) {
101 continue;
102 }
103 auto iter = mapNextTx.lower_bound(COutPoint(hash, 0));
104 {
105 for (; iter != mapNextTx.end() && iter->first->hash == hash; ++iter) {
106 txiter childIter = iter->second;
107 assert(childIter != mapTx.end());
108 // Add dependencies that are discovered between transactions in the
109 // block and transactions that were in the mempool to txgraph.
110 m_txgraph->AddDependency(/*parent=*/*it, /*child=*/*childIter);
111 }
112 }
113 }
114
115 auto txs_to_remove = m_txgraph->Trim(); // Enforce cluster size limits.
116 for (auto txptr : txs_to_remove) {
117 const CTxMemPoolEntry& entry = *(static_cast<const CTxMemPoolEntry*>(txptr));
118 removeUnchecked(mapTx.iterator_to(entry), MemPoolRemovalReason::SIZELIMIT);
119 }
120}
121
122bool CTxMemPool::HasDescendants(const Txid& txid) const
123{

Callers 3

FinishFunction · 0.80
ComplexMemPoolFunction · 0.80

Calls 6

findMethod · 0.80
lower_boundMethod · 0.80
TrimMethod · 0.80
COutPointClass · 0.70
endMethod · 0.45
AddDependencyMethod · 0.45

Tested by 1

FinishFunction · 0.64