| 129 | } |
| 130 | |
| 131 | void CTxMemPool::UpdateForDescendants(txiter updateIt, cacheMap& cachedDescendants, |
| 132 | const std::set<uint256>& setExclude, std::set<uint256>& descendants_to_remove, |
| 133 | uint64_t ancestor_size_limit, uint64_t ancestor_count_limit) |
| 134 | { |
| 135 | CTxMemPoolEntry::Children stageEntries, descendants; |
| 136 | stageEntries = updateIt->GetMemPoolChildrenConst(); |
| 137 | |
| 138 | while (!stageEntries.empty()) { |
| 139 | const CTxMemPoolEntry& descendant = *stageEntries.begin(); |
| 140 | descendants.insert(descendant); |
| 141 | stageEntries.erase(descendant); |
| 142 | const CTxMemPoolEntry::Children& children = descendant.GetMemPoolChildrenConst(); |
| 143 | for (const CTxMemPoolEntry& childEntry : children) { |
| 144 | cacheMap::iterator cacheIt = cachedDescendants.find(mapTx.iterator_to(childEntry)); |
| 145 | if (cacheIt != cachedDescendants.end()) { |
| 146 | // We've already calculated this one, just add the entries for this set |
| 147 | // but don't traverse again. |
| 148 | for (txiter cacheEntry : cacheIt->second) { |
| 149 | descendants.insert(*cacheEntry); |
| 150 | } |
| 151 | } else if (!descendants.count(childEntry)) { |
| 152 | // Schedule for later processing |
| 153 | stageEntries.insert(childEntry); |
| 154 | } |
| 155 | } |
| 156 | } |
| 157 | // descendants now contains all in-mempool descendants of updateIt. |
| 158 | // Update and add to cached descendant map |
| 159 | int64_t modifySize = 0; |
| 160 | CAmount modifyFee = 0; |
| 161 | int64_t modifyCount = 0; |
| 162 | for (const CTxMemPoolEntry& descendant : descendants) { |
| 163 | if (!setExclude.count(descendant.GetTx().GetHash())) { |
| 164 | modifySize += descendant.GetTxSize(); |
| 165 | modifyFee += descendant.GetModifiedFee(); |
| 166 | modifyCount++; |
| 167 | cachedDescendants[updateIt].insert(mapTx.iterator_to(descendant)); |
| 168 | // Update ancestor state for each descendant |
| 169 | mapTx.modify(mapTx.iterator_to(descendant), update_ancestor_state(updateIt->GetTxSize(), updateIt->GetModifiedFee(), 1, updateIt->GetSigOpCost(), updateIt->GetDiscountTxSize())); |
| 170 | // Don't directly remove the transaction here -- doing so would |
| 171 | // invalidate iterators in cachedDescendants. Mark it for removal |
| 172 | // by inserting into descendants_to_remove. |
| 173 | if (descendant.GetCountWithAncestors() > ancestor_count_limit || descendant.GetSizeWithAncestors() > ancestor_size_limit) { |
| 174 | descendants_to_remove.insert(descendant.GetTx().GetHash()); |
| 175 | } |
| 176 | } |
| 177 | } |
| 178 | mapTx.modify(updateIt, update_descendant_state(modifySize, modifyFee, modifyCount)); |
| 179 | } |
| 180 | |
| 181 | void CTxMemPool::UpdateTransactionsFromBlock(const std::vector<uint256> &vHashesToUpdate, uint64_t ancestor_size_limit, uint64_t ancestor_count_limit) |
| 182 | { |
nothing calls this directly
no test coverage detected