MCPcopy Create free account
hub / github.com/bitcoinxt/bitcoinxt / UpdateForDescendants

Method UpdateForDescendants

src/txmempool.cpp:71–111  ·  view source on GitHub ↗

Update the given tx for any in-mempool descendants. Assumes that setMemPoolChildren is correct for the given tx and all descendants.

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 5

emptyMethod · 0.45
beginMethod · 0.45
insertMethod · 0.45
eraseMethod · 0.45

Tested by

no test coverage detected