Skip to content

Commit

Permalink
Merge #617: [Wallet] Adjust staking properties to lower orphan rates.
Browse files Browse the repository at this point in the history
4c862f2 Lower stake hashdrift to 30 seconds. (presstab)
355e2d3 Update zPIV stake set more frequently. (presstab)

Tree-SHA512: fcbfeb23bdf5e84c38d64780b97cd0a3f6d7ecb630b2b2e7ba13daf2538d691409be70d889b418b3165c79c0ec0bcc8080dd1aec072d559bf77b1e9093af75e7
  • Loading branch information
Mrs-X committed May 26, 2018
2 parents b8c672c + 4c862f2 commit 6b525f0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/kernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,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 @@ -2115,9 +2115,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) {
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 @@ -2944,16 +2950,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 @@ -3084,7 +3084,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

0 comments on commit 6b525f0

Please sign in to comment.