From 7ecea1dc5dcea31ea166cb779f458d3993ee733e Mon Sep 17 00:00:00 2001 From: Murch Date: Wed, 26 Mar 2025 17:18:18 -0700 Subject: [PATCH] coinselection: Track whether BnB completed BnB may not be able to exhaustively search all potentially interesting combinations for large UTXO pools, so we keep track of whether the search was terminated by the iteration limit. --- src/wallet/coinselection.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/wallet/coinselection.cpp b/src/wallet/coinselection.cpp index 6755376ff51..e671c3d091f 100644 --- a/src/wallet/coinselection.cpp +++ b/src/wallet/coinselection.cpp @@ -131,6 +131,7 @@ util::Result SelectCoinsBnB(std::vector& utxo_pool }; size_t curr_try = 0; + SelectionResult result(selection_target, SelectionAlgorithm::BNB); while (true) { bool should_shift{false}, should_cut{false}; // Select `next_utxo` @@ -166,6 +167,7 @@ util::Result SelectCoinsBnB(std::vector& utxo_pool if (curr_try >= TOTAL_TRIES) { // Solution is not guaranteed to be optimal if `curr_try` hit TOTAL_TRIES + result.SetAlgoCompleted(false); break; } @@ -185,6 +187,7 @@ util::Result SelectCoinsBnB(std::vector& utxo_pool if (should_shift) { if (curr_selection.empty()) { // Exhausted search space before running into attempt limit + result.SetAlgoCompleted(true); break; } // Set `next_utxo` to one after last selected, then deselect last selected UTXO @@ -193,7 +196,6 @@ util::Result SelectCoinsBnB(std::vector& utxo_pool } } - SelectionResult result(selection_target, SelectionAlgorithm::BNB); result.SetSelectionsEvaluated(curr_try); if (best_selection.empty()) {