Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/kernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ bool Stake(CStakeInput* stakeInput, unsigned int nBits, unsigned int nTimeBlockF
bool fSuccess = false;
unsigned int nTryTime = 0;
int nHeightStart = chainActive.Height();
int nHashDrift = 45;
int nHashDrift = 30;
CDataStream ssUniqueID = stakeInput->GetUniqueness();
CAmount nValueIn = stakeInput->GetValue();
for (int i = 0; i < nHashDrift; i++) //iterate the hashing
Expand Down
25 changes: 12 additions & 13 deletions src/wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2114,9 +2114,15 @@ bool CWallet::SelectStakeCoins(std::list<std::unique_ptr<CStakeInput> >& listInp

//zPIV
if (GetBoolArg("-zpivstake", true) && chainActive.Height() > Params().Zerocoin_Block_V2_Start() && !IsSporkActive(SPORK_16_ZEROCOIN_MAINTENANCE_MODE)) {
//Add zPIV
set<CMintMeta> setMints = zpivTracker->ListMints(true, true, true);
//Only update zPIV set once per update interval
bool fUpdate = false;
static int64_t nTimeLastUpdate = 0;
if (GetAdjustedTime() - nTimeLastUpdate > nStakeSetUpdateTime) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Going from GetTime() to GetAdjustedTime() might be a real good change for some users.

fUpdate = true;
nTimeLastUpdate = GetAdjustedTime();
}

set<CMintMeta> setMints = zpivTracker->ListMints(true, true, fUpdate);
for (auto meta : setMints) {
if (meta.hashStake == 0) {
CZerocoinMint mint;
Expand Down Expand Up @@ -2943,16 +2949,10 @@ bool CWallet::CreateCoinStake(const CKeyStore& keystore, unsigned int nBits, int
if (nBalance > 0 && nBalance <= nReserveBalance)
return false;

// Initialize as static and don't update the set on every run of CreateCoinStake() in order to lighten resource use
static int nLastStakeSetUpdate = 0;
static list<std::unique_ptr<CStakeInput> > listInputs;
if (GetTime() - nLastStakeSetUpdate > nStakeSetUpdateTime) {
listInputs.clear();
if (!SelectStakeCoins(listInputs, nBalance - nReserveBalance))
return false;

nLastStakeSetUpdate = GetTime();
}
// Get the list of stakable inputs
std::list<std::unique_ptr<CStakeInput> > listInputs;
if (!SelectStakeCoins(listInputs, nBalance - nReserveBalance))
return false;

if (listInputs.empty())
return false;
Expand Down Expand Up @@ -3083,7 +3083,6 @@ bool CWallet::CreateCoinStake(const CKeyStore& keystore, unsigned int nBits, int
}

// Successfully generated coinstake
nLastStakeSetUpdate = 0; //this will trigger stake set to repopulate next round
return true;
}

Expand Down