Skip to content

Commit 6a34ff5

Browse files
committed
Have SelectCoinsMinConf and SelectCoins use BnB or Knapsack and use it
Allows SelectCoinsMinConf and SelectCoins be able to switch between using BnB or Knapsack for choosing coins. Has SelectCoinsMinConf do the preprocessing necessary to support either BnB or Knapsack. This includes calculating the filtering the effective values for each input. Uses BnB in CreateTransaction to find an exact match for the output. If BnB fails, it will fallback to the Knapsack solver.
1 parent fab0488 commit 6a34ff5

File tree

4 files changed

+198
-67
lines changed

4 files changed

+198
-67
lines changed

src/bench/coin_selection.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,11 @@ static void CoinSelection(benchmark::State& state)
4444

4545
std::set<CInputCoin> setCoinsRet;
4646
CAmount nValueRet;
47+
bool bnb_used;
4748
CoinEligibilityFilter filter_standard(1, 6, 0);
48-
bool success = wallet.SelectCoinsMinConf(1003 * COIN, filter_standard, vCoins, setCoinsRet, nValueRet);
49+
CoinSelectionParams coin_selection_params(false, 34, 148, CFeeRate(0), 0);
50+
bool success = wallet.SelectCoinsMinConf(1003 * COIN, filter_standard, vCoins, setCoinsRet, nValueRet, coin_selection_params, bnb_used)
51+
|| wallet.SelectCoinsMinConf(1003 * COIN, filter_standard, vCoins, setCoinsRet, nValueRet, coin_selection_params, bnb_used);
4952
assert(success);
5053
assert(nValueRet == 1003 * COIN);
5154
assert(setCoinsRet.size() == 2);

0 commit comments

Comments
 (0)