Add current PoW reward and stake interest into getmininginfo result
authoralex <alex@alex-VirtualBox.(none)>
Sat, 29 Jun 2013 13:12:05 +0000 (17:12 +0400)
committeralex <alex@alex-VirtualBox.(none)>
Sat, 29 Jun 2013 13:12:05 +0000 (17:12 +0400)
src/main.cpp
src/main.h
src/rpcmining.cpp

index 06040ae..fbc785a 100644 (file)
@@ -994,7 +994,7 @@ int64 GetProofOfWorkReward(unsigned int nBits)
 }
 
 // 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;
 
@@ -1038,7 +1038,11 @@ int64 GetProofOfStakeReward(int64 nCoinAge, unsigned int nBits, unsigned int nTi
         nRewardCoinYear = 5 * CENT;
     }
 
+    if(bCoinYearOnly)
+        return nRewardCoinYear;
+
     int64 nSubsidy = nCoinAge * 33 / (365 * 33 + 8) * nRewardCoinYear;
+
     if (fDebug && GetBoolArg("-printcreation"))
         printf("GetProofOfStakeReward(): create=%s nCoinAge=%"PRI64d" nBits=%d\n", FormatMoney(nSubsidy).c_str(), nCoinAge, nBits);
     return nSubsidy;
index 3f8ecbf..d09dc63 100644 (file)
@@ -113,7 +113,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);
 int GetNumBlocksOfPeers();
 bool IsInitialBlockDownload();
index 02109a5..5ddb3e2 100644 (file)
@@ -38,7 +38,7 @@ Value getmininginfo(const Array& params, bool fHelp)
 
         pindex = pindex->pnext;
     }
-    
+
     double dNetworkMhps = GetDifficulty() * 4294.967296 / nTargetSpacingWork;
     int nNetworkWeight = GetDifficulty(GetLastBlockIndex(pindexBest, true)) * 4294967296 / nTargetSpacingStake;
 
@@ -47,11 +47,13 @@ Value getmininginfo(const Array& params, bool fHelp)
     obj.push_back(Pair("currentblocksize",(uint64_t)nLastBlockSize));
     obj.push_back(Pair("currentblocktx",(uint64_t)nLastBlockTx));
     obj.push_back(Pair("difficulty",    (double)GetDifficulty()));
+    obj.push_back(Pair("blockvalue",    (uint64_t)GetProofOfWorkReward(GetLastBlockIndex(pindexBest, false)->nBits)));
     obj.push_back(Pair("netmhashps",     dNetworkMhps));
     obj.push_back(Pair("netstakeweight", nNetworkWeight));
     obj.push_back(Pair("errors",        GetWarnings("statusbar")));
     obj.push_back(Pair("pooledtx",      (uint64_t)mempool.size()));
-    obj.push_back(Pair("stakepower",    (uint64_t)pwalletMain->GetStakeMintPower(*pwalletMain)));
+    obj.push_back(Pair("stakeweight",    (uint64_t)pwalletMain->GetStakeMintPower(*pwalletMain)));
+    obj.push_back(Pair("stakeinterest",    (uint64_t)GetProofOfStakeReward(0, GetLastBlockIndex(pindexBest, true)->nBits, GetTime(), true)));
     obj.push_back(Pair("testnet",       fTestNet));
     return obj;
 }