Update the given tx for any in-mempool descendants. Assumes that setMemPoolChildren is correct for the given tx and all descendants.
| 60 | // Assumes that setMemPoolChildren is correct for the given tx and all |
| 61 | // descendants. |
| 62 | void CTxMemPool::UpdateForDescendants(txiter updateIt, cacheMap &cachedDescendants, const std::set<uint256> &setExclude) |
| 63 | { |
| 64 | setEntries stageEntries, setAllDescendants; |
| 65 | stageEntries = GetMemPoolChildren(updateIt); |
| 66 | |
| 67 | while (!stageEntries.empty()) { |
| 68 | const txiter cit = *stageEntries.begin(); |
| 69 | setAllDescendants.insert(cit); |
| 70 | stageEntries.erase(cit); |
| 71 | const setEntries &setChildren = GetMemPoolChildren(cit); |
| 72 | for (txiter childEntry : setChildren) { |
| 73 | cacheMap::iterator cacheIt = cachedDescendants.find(childEntry); |
| 74 | if (cacheIt != cachedDescendants.end()) { |
| 75 | // We've already calculated this one, just add the entries for this set |
| 76 | // but don't traverse again. |
| 77 | for (txiter cacheEntry : cacheIt->second) { |
| 78 | setAllDescendants.insert(cacheEntry); |
| 79 | } |
| 80 | } else if (!setAllDescendants.count(childEntry)) { |
| 81 | // Schedule for later processing |
| 82 | stageEntries.insert(childEntry); |
| 83 | } |
| 84 | } |
| 85 | } |
| 86 | // setAllDescendants now contains all in-mempool descendants of updateIt. |
| 87 | // Update and add to cached descendant map |
| 88 | int64_t modifySize = 0; |
| 89 | CAmount modifyFee = 0; |
| 90 | int64_t modifyCount = 0; |
| 91 | for (txiter cit : setAllDescendants) { |
| 92 | if (!setExclude.count(cit->GetTx().GetHash())) { |
| 93 | modifySize += cit->GetTxSize(); |
| 94 | modifyFee += cit->GetModifiedFee(); |
| 95 | modifyCount++; |
| 96 | cachedDescendants[updateIt].insert(cit); |
| 97 | // Update ancestor state for each descendant |
| 98 | mapTx.modify(cit, update_ancestor_state(updateIt->GetTxSize(), updateIt->GetModifiedFee(), 1, updateIt->GetSigOpCost())); |
| 99 | } |
| 100 | } |
| 101 | mapTx.modify(updateIt, update_descendant_state(modifySize, modifyFee, modifyCount)); |
| 102 | } |
| 103 | |
| 104 | // vHashesToUpdate is the set of transaction hashes from a disconnected block |
| 105 | // which has been re-added to the mempool. |
nothing calls this directly
no test coverage detected