@@ -2114,9 +2114,15 @@ bool CWallet::SelectStakeCoins(std::list<std::unique_ptr<CStakeInput> >& listInp
2114
2114
2115
2115
// zPIV
2116
2116
if (GetBoolArg (" -zpivstake" , true ) && chainActive.Height () > Params ().Zerocoin_Block_V2_Start () && !IsSporkActive (SPORK_16_ZEROCOIN_MAINTENANCE_MODE)) {
2117
- // Add zPIV
2118
- set<CMintMeta> setMints = zpivTracker->ListMints (true , true , true );
2117
+ // Only update zPIV set once per update interval
2118
+ bool fUpdate = false ;
2119
+ static int64_t nTimeLastUpdate = 0 ;
2120
+ if (GetAdjustedTime () - nTimeLastUpdate > nStakeSetUpdateTime) {
2121
+ fUpdate = true ;
2122
+ nTimeLastUpdate = GetAdjustedTime ();
2123
+ }
2119
2124
2125
+ set<CMintMeta> setMints = zpivTracker->ListMints (true , true , fUpdate );
2120
2126
for (auto meta : setMints) {
2121
2127
if (meta.hashStake == 0 ) {
2122
2128
CZerocoinMint mint;
@@ -2943,16 +2949,10 @@ bool CWallet::CreateCoinStake(const CKeyStore& keystore, unsigned int nBits, int
2943
2949
if (nBalance > 0 && nBalance <= nReserveBalance)
2944
2950
return false ;
2945
2951
2946
- // Initialize as static and don't update the set on every run of CreateCoinStake() in order to lighten resource use
2947
- static int nLastStakeSetUpdate = 0 ;
2948
- static list<std::unique_ptr<CStakeInput> > listInputs;
2949
- if (GetTime () - nLastStakeSetUpdate > nStakeSetUpdateTime) {
2950
- listInputs.clear ();
2951
- if (!SelectStakeCoins (listInputs, nBalance - nReserveBalance))
2952
- return false ;
2953
-
2954
- nLastStakeSetUpdate = GetTime ();
2955
- }
2952
+ // Get the list of stakable inputs
2953
+ std::list<std::unique_ptr<CStakeInput> > listInputs;
2954
+ if (!SelectStakeCoins (listInputs, nBalance - nReserveBalance))
2955
+ return false ;
2956
2956
2957
2957
if (listInputs.empty ())
2958
2958
return false ;
@@ -3083,7 +3083,6 @@ bool CWallet::CreateCoinStake(const CKeyStore& keystore, unsigned int nBits, int
3083
3083
}
3084
3084
3085
3085
// Successfully generated coinstake
3086
- nLastStakeSetUpdate = 0 ; // this will trigger stake set to repopulate next round
3087
3086
return true ;
3088
3087
}
3089
3088
0 commit comments