Skip to content

Commit da5377e

Browse files
authored
Merge pull request #578 from dantudor/Coin-sort
Sort available coins for staking by coin age descending
2 parents 0b8cb5d + ebddbcc commit da5377e

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

src/wallet/wallet.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,10 @@ void CWallet::AvailableCoinsForStaking(vector<COutput>& vCoins, unsigned int nSp
274274
}
275275
}
276276
}
277+
278+
if (GetBoolArg("-stakingsortbycoinage",false)) {
279+
std::sort(vCoins.begin(), vCoins.end(), sortByCoinAgeDescending());
280+
}
277281
}
278282

279283
// Select some coins without random shuffle or best subset approximation

src/wallet/wallet.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,13 @@ class COutput
513513
std::string ToString() const;
514514
};
515515

516-
516+
struct sortByCoinAgeDescending
517+
{
518+
inline bool operator() (const COutput& cOutput1, const COutput& cOutput2)
519+
{
520+
return (cOutput1.tx->nTime > cOutput2.tx->nTime);
521+
}
522+
};
517523

518524

519525
/** Private key that includes an expiration date in case it never gets used. */

0 commit comments

Comments
 (0)