aboutsummaryrefslogtreecommitdiff
path: root/src/wallet/coinselection.cpp
diff options
context:
space:
mode:
authorAndrew Chow <achow101-github@achow101.com>2020-03-04 16:35:15 -0500
committerAndrew Chow <achow101-github@achow101.com>2020-03-04 16:35:15 -0500
commit9b5950db8683f9b4be03f79ee0aae8a780b01a4b (patch)
treec7deccff2bbd4c744bc288bddd5e097ddd4a2a8b /src/wallet/coinselection.cpp
parenta71c34742c24245a0d642e68f9e61f46cc7573fb (diff)
downloadbitcoin-9b5950db8683f9b4be03f79ee0aae8a780b01a4b.tar.xz
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.
Diffstat (limited to 'src/wallet/coinselection.cpp')
-rw-r--r--src/wallet/coinselection.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/wallet/coinselection.cpp b/src/wallet/coinselection.cpp
index 5bbb2c0ad0..079a5d3d53 100644
--- a/src/wallet/coinselection.cpp
+++ b/src/wallet/coinselection.cpp
@@ -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;