mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-12-08 03:33:32 +01:00
Mitigate timeout in CalculateTotalBumpFees
The slow fuzz seed described in #27799 was just slower than expected, not an endless loop. Ensuring that every anscestor is only processed once speeds up the termination of the graph traversal. Fixes #27799
This commit is contained in:
@@ -346,15 +346,20 @@ std::optional<CAmount> MiniMiner::CalculateTotalBumpFees(const CFeeRate& target_
|
|||||||
to_process.insert(iter);
|
to_process.insert(iter);
|
||||||
ancestors.insert(iter);
|
ancestors.insert(iter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::set<uint256> has_been_processed;
|
||||||
while (!to_process.empty()) {
|
while (!to_process.empty()) {
|
||||||
auto iter = to_process.begin();
|
auto iter = to_process.begin();
|
||||||
const CTransaction& tx = (*iter)->second.GetTx();
|
const CTransaction& tx = (*iter)->second.GetTx();
|
||||||
for (const auto& input : tx.vin) {
|
for (const auto& input : tx.vin) {
|
||||||
if (auto parent_it{m_entries_by_txid.find(input.prevout.hash)}; parent_it != m_entries_by_txid.end()) {
|
if (auto parent_it{m_entries_by_txid.find(input.prevout.hash)}; parent_it != m_entries_by_txid.end()) {
|
||||||
to_process.insert(parent_it);
|
if (!has_been_processed.count(input.prevout.hash)) {
|
||||||
|
to_process.insert(parent_it);
|
||||||
|
}
|
||||||
ancestors.insert(parent_it);
|
ancestors.insert(parent_it);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
has_been_processed.insert(tx.GetHash());
|
||||||
to_process.erase(iter);
|
to_process.erase(iter);
|
||||||
}
|
}
|
||||||
const auto ancestor_package_size = std::accumulate(ancestors.cbegin(), ancestors.cend(), int64_t{0},
|
const auto ancestor_package_size = std::accumulate(ancestors.cbegin(), ancestors.cend(), int64_t{0},
|
||||||
|
|||||||
Reference in New Issue
Block a user