mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-21 14:34:49 +01:00
opt: Tie-break UTXO sort by waste for BnB
Since we are searching for the minimal waste, we sort UTXOs with equal effective value by ascending waste to be able to cut barren branches earlier.
This commit is contained in:
parent
aaee65823c
commit
89d0956643
1 changed files with 5 additions and 1 deletions
|
@ -25,10 +25,14 @@ static util::Result<SelectionResult> ErrorMaxWeightExceeded()
|
|||
"Please try sending a smaller amount or manually consolidating your wallet's UTXOs")};
|
||||
}
|
||||
|
||||
// Descending order comparator
|
||||
// Sort by descending (effective) value prefer lower waste on tie
|
||||
struct {
|
||||
bool operator()(const OutputGroup& a, const OutputGroup& b) const
|
||||
{
|
||||
if (a.GetSelectionAmount() == b.GetSelectionAmount()) {
|
||||
// Lower waste is better when effective_values are tied
|
||||
return (a.fee - a.long_term_fee) < (b.fee - b.long_term_fee);
|
||||
}
|
||||
return a.GetSelectionAmount() > b.GetSelectionAmount();
|
||||
}
|
||||
} descending;
|
||||
|
|
Loading…
Add table
Reference in a new issue