MCPcopy Create free account
hub / github.com/LUX-Core/lux / UpdateForDescendants

Method UpdateForDescendants

src/txmempool.cpp:83–123  ·  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

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

Callers

nothing calls this directly

Calls 13

GetSigOpCostMethod · 0.80
emptyMethod · 0.45
beginMethod · 0.45
insertMethod · 0.45
eraseMethod · 0.45
findMethod · 0.45
endMethod · 0.45
countMethod · 0.45
GetHashMethod · 0.45
GetTxSizeMethod · 0.45

Tested by

no test coverage detected