diff options
author | MarcoFalke <falke.marco@gmail.com> | 2018-06-29 10:08:52 +1400 |
---|---|---|
committer | MarcoFalke <falke.marco@gmail.com> | 2018-06-29 10:08:54 +1400 |
commit | b330f3fdd56b2dccc106154575af46ebb53e1ad9 (patch) | |
tree | f82b8b543d2b5ac568bde1c429c9f3a5a715c935 /src | |
parent | c93c360eec4de77af8aaa74d9140dba57160e30d (diff) | |
parent | c2e4fc84ecff72c36f6adc1292ba8242fc3cbaee (diff) |
Merge #13563: bench: Simplify CoinSelection
c2e4fc84ec bench: Simplify CoinSelection (João Barbosa)
Pull request description:
Closes #13549.
As pointed by @MarcoFalke:
- `SelectCoinsMinConf` should always succeed as there are enough coins in the wallet.
- Removed creating the coins in the wallet.
Tree-SHA512: 965c363bcaf0ca7a1dec35b5cf4866abcf190c53eb7012dc4aeb4d29830f13a7465644bfb5a47f6ea3eaa86e4d4a57fe41e7b2593bf5094b76a551c4c71625bb
Diffstat (limited to 'src')
-rw-r--r-- | src/bench/coin_selection.cpp | 26 |
1 files changed, 10 insertions, 16 deletions
diff --git a/src/bench/coin_selection.cpp b/src/bench/coin_selection.cpp index 64ec056c4d..f3180809b5 100644 --- a/src/bench/coin_selection.cpp +++ b/src/bench/coin_selection.cpp @@ -34,31 +34,25 @@ static void addCoin(const CAmount& nValue, const CWallet& wallet, std::vector<CO static void CoinSelection(benchmark::State& state) { const CWallet wallet("dummy", WalletDatabase::CreateDummy()); - std::vector<COutput> vCoins; LOCK(wallet.cs_wallet); - while (state.KeepRunning()) { - // Add coins. - for (int i = 0; i < 1000; i++) - addCoin(1000 * COIN, wallet, vCoins); - addCoin(3 * COIN, wallet, vCoins); + // Add coins. + std::vector<COutput> vCoins; + for (int i = 0; i < 1000; ++i) { + addCoin(1000 * COIN, wallet, vCoins); + } + addCoin(3 * COIN, wallet, vCoins); + const CoinEligibilityFilter filter_standard(1, 6, 0); + const CoinSelectionParams coin_selection_params(true, 34, 148, CFeeRate(0), 0); + while (state.KeepRunning()) { std::set<CInputCoin> setCoinsRet; CAmount nValueRet; bool bnb_used; - CoinEligibilityFilter filter_standard(1, 6, 0); - 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); + bool success = wallet.SelectCoinsMinConf(1003 * COIN, filter_standard, vCoins, setCoinsRet, nValueRet, coin_selection_params, bnb_used); assert(success); assert(nValueRet == 1003 * COIN); assert(setCoinsRet.size() == 2); - - // Empty wallet. - for (COutput& output : vCoins) { - delete output.tx; - } - vCoins.clear(); } } |