| 89 | } |
| 90 | |
| 91 | void 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 | |
| 122 | bool CTxMemPool::HasDescendants(const Txid& txid) const |
| 123 | { |