Mercurial > hg > bitcoin
changeset 2719:81d3602d50f8 draft
Preserve the shuffled order of coins with equal value to give more randomized coin selection.
author | Chris Moore <dooglus@gmail.com> |
---|---|
date | Sat, 07 Apr 2012 12:45:39 -0700 |
parents | f9f75bb0460d |
children | ae0b04082aa1 |
files | src/wallet.cpp |
diffstat | 1 files changed, 10 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/wallet.cpp +++ b/src/wallet.cpp @@ -17,6 +17,15 @@ // mapWallet // +struct CompareValueOnly +{ + bool operator()(const pair<int64, pair<const CWalletTx*, unsigned int> >& t1, + const pair<int64, pair<const CWalletTx*, unsigned int> >& t2) const + { + return t1.first < t2.first; + } +}; + CPubKey CWallet::GenerateNewKey() { bool fCompressed = CanSupportFeature(FEATURE_COMPRPUBKEY); // default to compressed public keys if we want 0.6.0 wallets @@ -980,7 +989,7 @@ nTargetValue += CENT; // Solve subset sum by stochastic approximation - sort(vValue.rbegin(), vValue.rend()); + sort(vValue.rbegin(), vValue.rend(), CompareValueOnly()); vector<char> vfIncluded; vector<char> vfBest(vValue.size(), true); int64 nBest = nTotalLower;