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

Method DeleteAncestorPackage

src/node/mini_miner.cpp:199–229  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

197};
198
199void MiniMiner::DeleteAncestorPackage(const std::set<MockEntryMap::iterator, IteratorComparator>& ancestors)
200{
201 Assume(ancestors.size() >= 1);
202 // "Mine" all transactions in this ancestor set.
203 for (auto& anc : ancestors) {
204 Assume(!m_in_block.contains(anc->first));
205 m_in_block.insert(anc->first);
206 m_total_fees += anc->second.GetModifiedFee();
207 m_total_vsize += anc->second.GetTxSize();
208 auto it = m_descendant_set_by_txid.find(anc->first);
209 // Each entry’s descendant set includes itself
210 Assume(it != m_descendant_set_by_txid.end());
211 for (auto& descendant : it->second) {
212 // If this fails, we must be double-deducting. Don't check fees because negative is possible.
213 Assume(descendant->second.GetSizeWithAncestors() >= anc->second.GetTxSize());
214 descendant->second.UpdateAncestorState(-anc->second.GetTxSize(), -anc->second.GetModifiedFee());
215 }
216 }
217 // Delete these entries.
218 for (const auto& anc : ancestors) {
219 m_descendant_set_by_txid.erase(anc->first);
220 // The above loop should have deducted each ancestor's size and fees from each of their
221 // respective descendants exactly once.
222 Assume(anc->second.GetModFeesWithAncestors() == 0);
223 Assume(anc->second.GetSizeWithAncestors() == 0);
224 auto vec_it = std::find(m_entries.begin(), m_entries.end(), anc);
225 Assume(vec_it != m_entries.end());
226 m_entries.erase(vec_it);
227 m_entries_by_txid.erase(anc);
228 }
229}
230
231void MiniMiner::SanityCheck() const
232{

Callers

nothing calls this directly

Calls 12

findMethod · 0.80
GetSizeWithAncestorsMethod · 0.80
UpdateAncestorStateMethod · 0.80
sizeMethod · 0.45
containsMethod · 0.45
insertMethod · 0.45
GetModifiedFeeMethod · 0.45
GetTxSizeMethod · 0.45
endMethod · 0.45
eraseMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected