mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-06-19 13:22:02 +02:00
mempool: Calculate descendant maximum thoroughly
This commit is contained in:
parent
6d3568371e
commit
a08d76bcfe
@ -1056,14 +1056,25 @@ void CTxMemPool::TrimToSize(size_t sizelimit, std::vector<COutPoint>* pvNoSpends
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint64_t CTxMemPool::CalculateDescendantMaximum(txiter entry) const {
|
uint64_t CTxMemPool::CalculateDescendantMaximum(txiter entry) const {
|
||||||
// find top parent
|
// find parent with highest descendant count
|
||||||
txiter top = entry;
|
std::vector<txiter> candidates;
|
||||||
for (;;) {
|
setEntries counted;
|
||||||
const setEntries& parents = GetMemPoolParents(top);
|
candidates.push_back(entry);
|
||||||
if (parents.size() == 0) break;
|
uint64_t maximum = 0;
|
||||||
top = *parents.begin();
|
while (candidates.size()) {
|
||||||
|
txiter candidate = candidates.back();
|
||||||
|
candidates.pop_back();
|
||||||
|
if (!counted.insert(candidate).second) continue;
|
||||||
|
const setEntries& parents = GetMemPoolParents(candidate);
|
||||||
|
if (parents.size() == 0) {
|
||||||
|
maximum = std::max(maximum, candidate->GetCountWithDescendants());
|
||||||
|
} else {
|
||||||
|
for (txiter i : parents) {
|
||||||
|
candidates.push_back(i);
|
||||||
}
|
}
|
||||||
return top->GetCountWithDescendants();
|
}
|
||||||
|
}
|
||||||
|
return maximum;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTxMemPool::GetTransactionAncestry(const uint256& txid, size_t& ancestors, size_t& descendants) const {
|
void CTxMemPool::GetTransactionAncestry(const uint256& txid, size_t& ancestors, size_t& descendants) const {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user