mirror of
https://github.com/dashpay/dash.git
synced 2024-12-27 04:52:59 +01:00
Merge #8298: wallet: Revert input selection post-pruning
20f3cd7
wallet: Revert input selection post-pruning (Wladimir J. van der Laan)
This commit is contained in:
commit
aef381161f
@ -349,20 +349,6 @@ BOOST_AUTO_TEST_CASE(ApproximateBestSubset)
|
|||||||
BOOST_CHECK(wallet.SelectCoinsMinConf(1003 * COIN, 1, 6, vCoins, setCoinsRet, nValueRet));
|
BOOST_CHECK(wallet.SelectCoinsMinConf(1003 * COIN, 1, 6, vCoins, setCoinsRet, nValueRet));
|
||||||
BOOST_CHECK_EQUAL(nValueRet, 1003 * COIN);
|
BOOST_CHECK_EQUAL(nValueRet, 1003 * COIN);
|
||||||
BOOST_CHECK_EQUAL(setCoinsRet.size(), 2U);
|
BOOST_CHECK_EQUAL(setCoinsRet.size(), 2U);
|
||||||
|
|
||||||
empty_wallet();
|
|
||||||
|
|
||||||
// Test trimming
|
|
||||||
for (int i = 0; i < 100; i++)
|
|
||||||
add_coin(10 * COIN);
|
|
||||||
for (int i = 0; i < 100; i++)
|
|
||||||
add_coin(1000 * COIN);
|
|
||||||
|
|
||||||
BOOST_CHECK(wallet.SelectCoinsMinConf(100001 * COIN, 1, 6, vCoins, setCoinsRet, nValueRet));
|
|
||||||
// We need all 100 larger coins and exactly one small coin.
|
|
||||||
// Superfluous small coins must be trimmed from the set:
|
|
||||||
BOOST_CHECK_EQUAL(nValueRet, 100010 * COIN);
|
|
||||||
BOOST_CHECK_EQUAL(setCoinsRet.size(), 101);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_SUITE_END()
|
BOOST_AUTO_TEST_SUITE_END()
|
||||||
|
@ -1879,16 +1879,6 @@ 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 New Issue
Block a user