mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-26 11:13:23 -03:00
[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.
This commit is contained in:
parent
ce1fabe545
commit
ec7d73628a
2 changed files with 2 additions and 1 deletions
|
@ -163,6 +163,8 @@ std::optional<SelectionResult> SelectCoinsBnB(std::vector<OutputGroup>& utxo_poo
|
||||||
result.AddInput(utxo_pool.at(i));
|
result.AddInput(utxo_pool.at(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
result.ComputeAndSetWaste(CAmount{0});
|
||||||
|
assert(best_waste == result.GetWaste());
|
||||||
|
|
||||||
return result;
|
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.
|
// 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 */);
|
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)}) {
|
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);
|
results.push_back(*bnb_result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue