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
6a8b2be refactor: Avoid copying util::Result values (Ryan Ofsky)
834f65e refactor: Drop util::Result operator= (Ryan Ofsky)
Pull request description:
This PR just contains the first two commits of #25665.
It disables copying of `util::Result` objects because unnecessary copies are inefficient and not possible after #25665, which makes `util::Result` object move-only.
It disables the assignment operator and replaces it with an `Update()` method, because #25665 adds more information to `util::Result` objects (warning and error messages and failure values) and having an assignment operator that overwrites data instead of merging it would make it easy to accidentally erase existing information while trying to assign new information.
ACKs for top commit:
stickies-v:
re-ACK 6a8b2be
achow101:
ACK 6a8b2be
furszy:
re-ACK bitcoin/bitcoin@6a8b2be
Tree-SHA512: 3f21af9031d50d6c68cca69133de03080f69b1ddcf8b140bdeb762069f14645209b2586037236d15b6ebd8973af0fbefd7e83144aeb7b84078a4cb4df812f984
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