mirror of
https://github.com/dashpay/dash.git
synced 2024-12-27 13:03:17 +01:00
Coinselection prunes extraneous inputs from ApproximateBestSubset
A further pass over the available inputs has been added to ApproximateBestSubset after a candidate set has been found. It will prune any extraneous inputs in the selected subset, in order to decrease the number of input and the resulting change.
This commit is contained in:
parent
075faaebf2
commit
5c03483e26
@ -1620,6 +1620,19 @@ static void ApproximateBestSubset(vector<pair<CAmount, pair<const CWalletTx*,uns
|
|||||||
if (nTotal >= nTargetValue)
|
if (nTotal >= nTargetValue)
|
||||||
{
|
{
|
||||||
fReachedTarget = true;
|
fReachedTarget = true;
|
||||||
|
|
||||||
|
for (unsigned int i = 0; i < vValue.size(); i++)
|
||||||
|
{
|
||||||
|
//The target has been reached, but the candidate set may contain extraneous inputs.
|
||||||
|
//This iterates over all inputs and deducts any that are included, but smaller
|
||||||
|
//than the amount nTargetValue is still exceeded by.
|
||||||
|
if (vfIncluded[i] && (nTotal - vValue[i].first) >= nTargetValue )
|
||||||
|
{
|
||||||
|
vfIncluded[i] = false;
|
||||||
|
nTotal -= vValue[i].first;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (nTotal < nBest)
|
if (nTotal < nBest)
|
||||||
{
|
{
|
||||||
nBest = nTotal;
|
nBest = nTotal;
|
||||||
|
Loading…
Reference in New Issue
Block a user