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.
This commit is contained in:
Andrew Chow
2018-03-05 16:42:49 -05:00
parent fab04887c2
commit 6a34ff5335
4 changed files with 198 additions and 67 deletions

View File

@@ -44,8 +44,11 @@ static void CoinSelection(benchmark::State& state)
std::set<CInputCoin> setCoinsRet;
CAmount nValueRet;
bool bnb_used;
CoinEligibilityFilter filter_standard(1, 6, 0);
bool success = wallet.SelectCoinsMinConf(1003 * COIN, filter_standard, vCoins, setCoinsRet, nValueRet);
CoinSelectionParams coin_selection_params(false, 34, 148, CFeeRate(0), 0);
bool success = wallet.SelectCoinsMinConf(1003 * COIN, filter_standard, vCoins, setCoinsRet, nValueRet, coin_selection_params, bnb_used)
|| wallet.SelectCoinsMinConf(1003 * COIN, filter_standard, vCoins, setCoinsRet, nValueRet, coin_selection_params, bnb_used);
assert(success);
assert(nValueRet == 1003 * COIN);
assert(setCoinsRet.size() == 2);