Skip to content

Commit

Permalink
Staking Details
Browse files Browse the repository at this point in the history
Restored the amount of Inputs, Min/Max/Average Age and StakeWeight displayed on the StakeIcon.
  • Loading branch information
Oliver Ziegler authored and Oliver Ziegler committed Feb 6, 2019
1 parent 76d7b02 commit 90543e9
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/qt/bitcoingui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1392,6 +1392,16 @@ void BitcoinGUI::updateStakingStatus()
bool fStakeIcon = getStakingStatus(nEstimateTime, nWeight, stakeText, stakeTime);

/* Don't wrap words */
if (fStakeIcon)
{
stakeText += QString("<br>");
stakeText += tr("Staking enabled for %1 inputs weighing %2 coin days") \
.arg(nMinWeightInputs + nAvgWeightInputs + nMaxWeightInputs).arg(nWeight);
stakeText += QString("<br>");
stakeText += tr("Inputs: %1 min. age, %2 avg. age, %3 max. age") \
.arg(nMinWeightInputs).arg(nAvgWeightInputs).arg(nMaxWeightInputs);
}

stakeText = QString("<nobr>") + stakeText + QString("</nobr>");

labelStakeMining->setToolTip(stakeText);
Expand Down
6 changes: 6 additions & 0 deletions src/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,12 @@ CTranslationInterface translationInterface;
/* NeoScrypt related */
unsigned int nNeoScryptOptions = 0;

/* Shared between getmininginfo and the Qt client */
unsigned long long nMinWeightInputs = 0;
unsigned long long nAvgWeightInputs = 0;
unsigned long long nMaxWeightInputs = 0;
unsigned long long nTotalStakeWeight = 0;

/* Performance counters shown in RPC call getcounters */
uint64_t nBlockHashCacheHits = 0;
uint64_t nBlockHashCacheMisses = 0;
Expand Down
4 changes: 4 additions & 0 deletions src/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ extern unsigned int nNeoScryptOptions;

extern unsigned int nStakeMinTime;
extern unsigned int nStakeMinDepth;
extern unsigned long long nMinWeightInputs;
extern unsigned long long nAvgWeightInputs;
extern unsigned long long nMaxWeightInputs;
extern unsigned long long nTotalStakeWeight;

extern uint64_t nBlockHashCacheHits;
extern uint64_t nBlockHashCacheMisses;
Expand Down
14 changes: 14 additions & 0 deletions src/wallet/wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3767,14 +3767,28 @@ void CWallet::GetStakeWeight(uint64_t& nMinWeight, uint64_t& nMaxWeight, uint64_
if (setCoins.empty())
return;

nMinWeightInputs = 0, nMaxWeightInputs = 0, nAvgWeightInputs = 0;

int64_t nCurrentTime = GetTime();
uint64_t nStakeMaxAge = 15 * 24 * 60 * 60;

LOCK2(cs_main, cs_wallet);
BOOST_FOREACH(PAIRTYPE(const CWalletTx*, unsigned int) pcoin, setCoins)
{
int64_t nTimeWeight = GetWeight((int64_t)pcoin.first->nTime, (int64_t)GetTime());
CBigNum bnCoinDayWeight = CBigNum(pcoin.first->vout[pcoin.second].nValue) * nTimeWeight / COIN / (24 * 60 * 60);

if (nTimeWeight > 0) {
/* Calculate stake weight */
nTotalStakeWeight += bnCoinDayWeight.getuint64();
/* Minimum weight reached */
if (nTimeWeight < (nStakeMaxAge / 2)) nMinWeightInputs++;
/* Average weight reached */
else if (nTimeWeight < nStakeMaxAge) nAvgWeightInputs++;
/* Maximum weight reached */
else nMaxWeightInputs++;
}

if (nTimeWeight > 0)
nWeight += bnCoinDayWeight.getuint64();

Expand Down

0 comments on commit 90543e9

Please sign in to comment.