Merge pull request #4906
fc0f52d
Added a test for the pruning of extraneous inputs after ApproximateBestSet (Murch)af9510e
Moved set reduction to the end of ApproximateBestSubset to reduce performance impact (Murch)5c03483
Coinselection prunes extraneous inputs from ApproximateBestSubset (AlSzacrel)
This commit is contained in:
commit
0800092fc2
2 changed files with 28 additions and 0 deletions
|
@ -328,4 +328,22 @@ BOOST_AUTO_TEST_CASE(coin_selection_tests)
|
||||||
empty_wallet();
|
empty_wallet();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(pruning_in_ApproximateBestSet)
|
||||||
|
{
|
||||||
|
CoinSet setCoinsRet;
|
||||||
|
CAmount nValueRet;
|
||||||
|
|
||||||
|
LOCK(wallet.cs_wallet);
|
||||||
|
|
||||||
|
empty_wallet();
|
||||||
|
for (int i = 0; i < 12; i++)
|
||||||
|
{
|
||||||
|
add_coin(10*CENT);
|
||||||
|
}
|
||||||
|
add_coin(100*CENT);
|
||||||
|
add_coin(100*CENT);
|
||||||
|
BOOST_CHECK(wallet.SelectCoinsMinConf(221*CENT, 1, 6, vCoins, setCoinsRet, nValueRet));
|
||||||
|
BOOST_CHECK_EQUAL(nValueRet, 230*CENT);
|
||||||
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_SUITE_END()
|
BOOST_AUTO_TEST_SUITE_END()
|
||||||
|
|
|
@ -1632,6 +1632,16 @@ static void ApproximateBestSubset(vector<pair<CAmount, pair<const CWalletTx*,uns
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Reduces the approximate best subset by removing any inputs that are smaller than the surplus of nTotal beyond nTargetValue.
|
||||||
|
for (unsigned int i = 0; i < vValue.size(); i++)
|
||||||
|
{
|
||||||
|
if (vfBest[i] && (nBest - vValue[i].first) >= nTargetValue )
|
||||||
|
{
|
||||||
|
vfBest[i] = false;
|
||||||
|
nBest -= vValue[i].first;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CWallet::SelectCoinsMinConf(const CAmount& nTargetValue, int nConfMine, int nConfTheirs, vector<COutput> vCoins,
|
bool CWallet::SelectCoinsMinConf(const CAmount& nTargetValue, int nConfMine, int nConfTheirs, vector<COutput> vCoins,
|
||||||
|
|
Loading…
Reference in a new issue