You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copying util::Result values is less efficient than moving them because they
allocate memory and contain strings. Also this is needed to avoid compile
errors in bitcoin/bitcoin#25722 which adds a
std::unique_ptr member to util::Result which implicity disables copying.
auto append_error = [&] (constutil::Result<SelectionResult>& result) {
686
+
auto append_error = [&] (util::Result<SelectionResult>&& result) {
687
687
// If any specific error message appears here, then something different from a simple "no selection found" happened.
688
688
// Let's save it, so it can be retrieved to the user if no other selection algorithm succeeded.
689
689
if (HasErrorMsg(result)) {
690
-
errors.emplace_back(result);
690
+
errors.emplace_back(std::move(result));
691
691
}
692
692
};
693
693
@@ -698,7 +698,7 @@ util::Result<SelectionResult> ChooseSelectionResult(interfaces::Chain& chain, co
698
698
if (!coin_selection_params.m_subtract_fee_outputs) {
699
699
if (auto bnb_result{SelectCoinsBnB(groups.positive_group, nTargetValue, coin_selection_params.m_cost_of_change, max_inputs_weight)}) {
700
700
results.push_back(*bnb_result);
701
-
} elseappend_error(bnb_result);
701
+
} elseappend_error(std::move(bnb_result));
702
702
}
703
703
704
704
// As Knapsack and SRD can create change, also deduce change weight.
@@ -707,25 +707,25 @@ util::Result<SelectionResult> ChooseSelectionResult(interfaces::Chain& chain, co
707
707
// The knapsack solver has some legacy behavior where it will spend dust outputs. We retain this behavior, so don't filter for positive only here.
708
708
if (auto knapsack_result{KnapsackSolver(groups.mixed_group, nTargetValue, coin_selection_params.m_min_change_target, coin_selection_params.rng_fast, max_inputs_weight)}) {
709
709
results.push_back(*knapsack_result);
710
-
} elseappend_error(knapsack_result);
710
+
} elseappend_error(std::move(knapsack_result));
711
711
712
712
if (coin_selection_params.m_effective_feerate > CFeeRate{3 * coin_selection_params.m_long_term_feerate}) { // Minimize input set for feerates of at least 3×LTFRE (default: 30 ṩ/vB+)
713
713
if (auto cg_result{CoinGrinder(groups.positive_group, nTargetValue, coin_selection_params.m_min_change_target, max_inputs_weight)}) {
if (CAmount total_amount = available_coins.GetTotalAmount() - total_discarded < value_to_select) {
867
867
// Special case, too-long-mempool cluster.
868
868
if (total_amount + total_unconf_long_chain > value_to_select) {
869
-
return util::Result<SelectionResult>({_("Unconfirmed UTXOs are available, but spending them creates a chain of transactions that will be rejected by the mempool")});
869
+
return util::Error{_("Unconfirmed UTXOs are available, but spending them creates a chain of transactions that will be rejected by the mempool")};
870
870
}
871
-
return util::Result<SelectionResult>(util::Error()); // General "Insufficient Funds"
871
+
return util::Error{}; // General "Insufficient Funds"
872
872
}
873
873
874
874
// Walk-through the filters until the solution gets found.
0 commit comments