diff --git a/src/main.cpp b/src/main.cpp index 32b0e69bbc..01c8037f7e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1078,7 +1078,7 @@ int64 GetProofOfWorkReward_OPM(const CBlockIndex* pindex0) if (rDiff > rDiffcu && rSubsidy < 3.) { rSubsidy = 6. * exp_n2( pow( abs( rDiff - (18.02428*exp_n(-M7Mv2_move/0.17628) + 6.58466*exp_n(-M7Mv2_move/0.71943) + 0.93489) )/(1./M7Mv2_move), 0.5 ), 0.); } - if (IsMaintainence) rSubsidy *= 0.3; + if (IsMaintainence(pindex0)) rSubsidy *= 0.3; rSubsidy *= double(COIN); if (rSubsidy > 50*COIN) { rSubsidy = 50*COIN; } else if (rSubsidy < MIN_TX_FEE) { rSubsidy = MIN_TX_FEE; } @@ -1239,13 +1239,13 @@ double GetAnnualInterest(int64 nNetWorkWeit, double rMaxAPR) return rAPR; } -double GetAnnualInterestV2(int64 nNetWorkWeit, double rMaxAPR) +double GetAnnualInterestV2(int64 nNetWorkWeit, double rMaxAPR, CBlockIndex* pindex0) { double rAPR, rWeit=500000.; // if (fTestNet) return GetAnnualInterest_TestNet(nNetWorkWeit, rMaxAPR); rAPR = ( ( 2./( 1.+exp_n(1./(nNetWorkWeit/rWeit+1.)) ) - 0.53788 ) * rMaxAPR / ( 2./( 1.+exp_n(1./(rWeit+1.)) ) - 0.53788 ) ); - if (IsMaintainence) rAPR *= 1.2; + if (pindex0 && IsMaintainence(pindex0)) rAPR *= 1.2; if (fDebugMagiPoS) printf("@PoS-APRV2 rAPR = %f\n", rAPR); return rAPR; } @@ -1255,7 +1255,7 @@ int64 GetProofOfStakeReward(int64 nCoinAge, int64 nFees, CBlockIndex* pindex) { int64 nNetWorkWeit = GetPoSKernelPS(pindex); double rAPR = (IsPoSIIProtocolV2(pindex->nHeight+1)) ? - GetAnnualInterestV2(nNetWorkWeit, MAX_MAGI_PROOF_OF_STAKE) : + GetAnnualInterestV2(nNetWorkWeit, MAX_MAGI_PROOF_OF_STAKE, pindex) : GetAnnualInterest(nNetWorkWeit, MAX_MAGI_PROOF_OF_STAKE); int64 nSubsidy = nCoinAge * rAPR * COIN * 33 / (365 * 33 + 8); diff --git a/src/main.h b/src/main.h index 156a5aa643..f49c709805 100644 --- a/src/main.h +++ b/src/main.h @@ -186,6 +186,7 @@ double GetDifficultyFromBitsV2(const CBlockIndex* pindex0, bool fPrintInfo=false double GetDifficultyFromBits(unsigned int nBits); double GetAnnualInterest_TestNet(int64 nNetWorkWeit, double rMaxAPR); double GetAnnualInterest(int64 nNetWorkWeit, double rMaxAPR); +double GetAnnualInterestV2(int64 nNetWorkWeit, double rMaxAPR, CBlockIndex* pindex0 = NULL); bool IsChainInSwitch(const CBlockIndex* pindex_); int GetCoinbaseMaturity(int nHeight); //bool CheckMoneySupply(CBlockIndex* pindexPrev); diff --git a/src/rpcmining.cpp b/src/rpcmining.cpp index 8f912c94ef..4df1eb2889 100644 --- a/src/rpcmining.cpp +++ b/src/rpcmining.cpp @@ -62,10 +62,6 @@ Value gethashespersec(const Array& params, bool fHelp) return (boost::int64_t)dHashesPerSec; } -int64 GetProofOfWorkRewardV2(const CBlockIndex* pindexPrev, int64 nFees, bool fLastBlock); -//double GetDifficultyFromBitsV2(const CBlockIndex* pindex0); -double GetAnnualInterest(int64 nNetWorkWeit, double rMaxAPR); -double GetAnnualInterestV2(int64 nNetWorkWeit, double rMaxAPR); Value getmininginfo(const Array& params, bool fHelp) { if (fHelp || params.size() != 0) @@ -80,7 +76,7 @@ Value getmininginfo(const Array& params, bool fHelp) ((double)GetProofOfWorkRewardV2(pindexBest, 0, true))/((double)COIN) : (double)((uint64_t)(GetProofOfWorkReward(pindexBest->nBits, pindexBest->nHeight, 0)/COIN)); double rAPR = (IsPoSIIProtocolV2(pindexBest->nHeight+1)) ? - GetAnnualInterestV2(nNetWorkWeit, MAX_MAGI_PROOF_OF_STAKE) : + GetAnnualInterestV2(nNetWorkWeit, MAX_MAGI_PROOF_OF_STAKE, pindexBest) : GetAnnualInterest(nNetWorkWeit, MAX_MAGI_PROOF_OF_STAKE); Object obj, diff, blockvalue, weight;