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
iamunick committed May 27, 2014
1 parent 9be3702 commit 113318c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -973,12 +973,15 @@ int64 GetProofOfWorkReward(int nHeight, int64 nFees, uint256 prevHash)

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

nRewardCoinYear = MAX_MINT_PROOF_OF_STAKE;

if(bCoinYearOnly)
return nRewardCoinYear;

int64 nSubsidy = nCoinAge * nRewardCoinYear / 365;
if(nTime > REWARD_SWITCH_TIME)
nSubsidy /= 100;
Expand Down
2 changes: 1 addition & 1 deletion src/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,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(int nHeight, int64 nFees, uint256 prevHash);
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);
int GetNumBlocksOfPeers();
bool IsInitialBlockDownload();
Expand Down
1 change: 1 addition & 0 deletions src/rpcmining.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ Value getmininginfo(const Array& params, bool fHelp)
obj.push_back(Pair("hashespersec", gethashespersec(params, false)));
obj.push_back(Pair("networkhashps", getnetworkhashps(params, false)));
obj.push_back(Pair("pooledtx", (uint64_t)mempool.size()));
obj.push_back(Pair("stakeinterest", (uint64_t)GetProofOfStakeReward(0, GetLastBlockIndex(pindexBest, true)->nBits, GetLastBlockIndex(pindexBest, true)->nTime, true)));
obj.push_back(Pair("testnet", fTestNet));
return obj;
}
Expand Down

0 comments on commit 113318c

Please sign in to comment.