Skip to content

Commit

Permalink
Add Stake Yearly Interest to getmininginfo
Browse files Browse the repository at this point in the history
  • Loading branch information
Tranz5 committed May 20, 2014
1 parent e401751 commit 99a22a9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
16 changes: 10 additions & 6 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -956,7 +956,7 @@ int64 GetProofOfWorkReward(unsigned int nHeight)
}

// miner's coin stake reward based on nBits and coin age spent (coin-days)
int64 GetProofOfStakeReward(int64 nCoinAge, unsigned int nBits, unsigned int nTime)
int64 GetProofOfStakeReward(int64 nCoinAge, unsigned int nBits, unsigned int nTime, bool bCoinYearOnly)
{
int64 nRewardCoinYear;

Expand Down Expand Up @@ -992,21 +992,25 @@ int64 GetProofOfStakeReward(int64 nCoinAge, unsigned int nBits, unsigned int nTi
}

nRewardCoinYear = bnUpperBound.getuint64();
if (nTime > REWARD_FIX_SWITCH_TIME)
nRewardCoinYear = min(nRewardCoinYear, MAX_MINT_PROOF_OF_STAKE);
else
nRewardCoinYear = min((nRewardCoinYear / CENT) * CENT, MAX_MINT_PROOF_OF_STAKE);
if (nTime > REWARD_FIX_SWITCH_TIME)
nRewardCoinYear = min(nRewardCoinYear, MAX_MINT_PROOF_OF_STAKE);
else
nRewardCoinYear = min((nRewardCoinYear / CENT) * CENT, MAX_MINT_PROOF_OF_STAKE);
}
else
{
// Old creation amount per coin-year, 5% fixed stake mint rate
nRewardCoinYear = 0.015 * CENT;
}

if(bCoinYearOnly)
return nRewardCoinYear;


int64 nSubsidy = nCoinAge * 33 / (365 * 33 + 8) * nRewardCoinYear;
if (nTime > REWARD_FIX_SWITCH_TIME)
nSubsidy = (nCoinAge * 33 * nRewardCoinYear) / (365 * 33 + 8) ;
else
else
nSubsidy = nCoinAge * 33 / (365 * 33 + 8) * nRewardCoinYear;

if (fDebug && GetBoolArg("-printcreation"))
Expand Down
2 changes: 1 addition & 1 deletion src/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ void FormatHashBuffers(CBlock* pblock, char* pmidstate, char* pdata, char* phash
bool CheckWork(CBlock* pblock, CWallet& wallet, CReserveKey& reservekey);
bool CheckProofOfWork(uint256 hash, unsigned int nBits);
int64 GetProofOfWorkReward(unsigned int nBits);
int64 GetProofOfStakeReward(int64 nCoinAge, unsigned int nBits, unsigned int nTime);
int64 GetProofOfStakeReward(int64 nCoinAge, unsigned int nBits, unsigned int nTime, bool bCoinYearOnly=false);
unsigned int ComputeMinWork(unsigned int nBase, int64 nTime);
unsigned int ComputeMinStake(unsigned int nBase, int64 nTime, unsigned int nBlockTime);
int GetNumBlocksOfPeers();
Expand Down
1 change: 1 addition & 0 deletions src/rpcmining.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ Value getmininginfo(const Array& params, bool fHelp)
obj.push_back(Pair("genproclimit", (int)GetArg("-genproclimit", -1)));
obj.push_back(Pair("hashespersec", gethashespersec(params, false)));
obj.push_back(Pair("pooledtx", (uint64_t)mempool.size()));
obj.push_back(Pair("stakeinterest", (uint64_t)GetProofOfStakeReward(0, GetLastBlockIndex(pindexBest, true)->nBits, GetTime(), true)));
obj.push_back(Pair("testnet", fTestNet));
return obj;
}
Expand Down

0 comments on commit 99a22a9

Please sign in to comment.