MCPcopy Create free account
hub / github.com/ElementsProject/elements / CalculateDescendants

Method CalculateDescendants

src/txmempool.cpp:601–623  ·  view source on GitHub ↗

Calculates descendants of entry that are not already in setDescendants, and adds to setDescendants. Assumes entryit is already a tx in the mempool and CTxMemPoolEntry::m_children is correct for tx and all descendants. Also assumes that if an entry is in setDescendants already, then all in-mempool descendants of it are already in setDescendants as well, so that we can save time by not iterating ove

Source from the content-addressed store, hash-verified

599// in-mempool descendants of it are already in setDescendants as well, so that we
600// can save time by not iterating over those entries.
601void CTxMemPool::CalculateDescendants(txiter entryit, setEntries& setDescendants) const
602{
603 setEntries stage;
604 if (setDescendants.count(entryit) == 0) {
605 stage.insert(entryit);
606 }
607 // Traverse down the children of entry, only adding children that are not
608 // accounted for in setDescendants already (because those children have either
609 // already been walked, or will be walked in this iteration).
610 while (!stage.empty()) {
611 txiter it = *stage.begin();
612 setDescendants.insert(it);
613 stage.erase(it);
614
615 const CTxMemPoolEntry::Children& children = it->GetMemPoolChildrenConst();
616 for (const CTxMemPoolEntry& child : children) {
617 txiter childiter = mapTx.iterator_to(child);
618 if (!setDescendants.count(childiter)) {
619 stage.insert(childiter);
620 }
621 }
622 }
623}
624
625void CTxMemPool::removeRecursive(const CTransaction &origTx, MemPoolRemovalReason reason)
626{

Callers 3

GetEntriesForConflictsFunction · 0.80
getmempooldescendantsFunction · 0.80

Calls 5

countMethod · 0.80
insertMethod · 0.45
emptyMethod · 0.45
beginMethod · 0.45
eraseMethod · 0.45

Tested by

no test coverage detected