[wallet] assert BnB internally calculated waste is the same as GetSelectionWaste()

These two implementations of waste calculation should never deviate.
Still keep the SelectCoinsBnB internal calculation because incremental
calculate-as-you-go is much more performant than calling
GetSelectionWaste() over and over again.
pull/24530/head
glozow 3 years ago
parent ce1fabe545
commit ec7d73628a

@ -163,6 +163,8 @@ std::optional<SelectionResult> SelectCoinsBnB(std::vector<OutputGroup>& utxo_poo
result.AddInput(utxo_pool.at(i));
}
}
result.ComputeAndSetWaste(CAmount{0});
assert(best_waste == result.GetWaste());
return result;
}

@ -379,7 +379,6 @@ std::optional<SelectionResult> AttemptSelection(const CWallet& wallet, const CAm
// Note that unlike KnapsackSolver, we do not include the fee for creating a change output as BnB will not create a change output.
std::vector<OutputGroup> positive_groups = GroupOutputs(wallet, coins, coin_selection_params, eligibility_filter, true /* positive_only */);
if (auto bnb_result{SelectCoinsBnB(positive_groups, nTargetValue, coin_selection_params.m_cost_of_change)}) {
bnb_result->ComputeAndSetWaste(CAmount(0));
results.push_back(*bnb_result);
}

Loading…
Cancel
Save