mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 15:09:59 +01:00
bnb: exit selection when best_waste is 0
If we find a solution which has no waste, just use that. This solution is what we would consider to be optimal, and other solutions we find would have to also have 0 waste, so they are equivalent to the first one with 0 waste. Thus we can optimize by just choosing the first one with 0 waste.
This commit is contained in:
@@ -106,6 +106,9 @@ bool SelectCoinsBnB(std::vector<OutputGroup>& utxo_pool, const CAmount& target_v
|
||||
best_selection = curr_selection;
|
||||
best_selection.resize(utxo_pool.size());
|
||||
best_waste = curr_waste;
|
||||
if (best_waste == 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
curr_waste -= (curr_value - actual_target); // Remove the excess value as we will be selecting different coins now
|
||||
backtrack = true;
|
||||
|
||||
Reference in New Issue
Block a user