Add ability to calculate only superblock part of subsidy in GetBlockSubsidy()

This commit is contained in:
UdjinM6 2016-08-21 06:18:04 +03:00
parent e8f9e5d406
commit 51434cfff5
2 changed files with 4 additions and 4 deletions

View File

@ -1739,7 +1739,7 @@ NOTE: unlike bitcoin we are using PREVIOUS block height here,
might be a good idea to change this to use prev bits might be a good idea to change this to use prev bits
but current height to avoid confusion. but current height to avoid confusion.
*/ */
CAmount GetBlockSubsidy(int nPrevBits, int nPrevHeight, const Consensus::Params& consensusParams) CAmount GetBlockSubsidy(int nPrevBits, int nPrevHeight, const Consensus::Params& consensusParams, bool fSuperblockPartOnly)
{ {
double dDiff = (double)0x0000ffff / (double)(nPrevBits & 0x00ffffff); double dDiff = (double)0x0000ffff / (double)(nPrevBits & 0x00ffffff);
@ -1771,9 +1771,9 @@ CAmount GetBlockSubsidy(int nPrevBits, int nPrevHeight, const Consensus::Params&
for(int i = consensusParams.nSubsidyHalvingInterval; i <= nPrevHeight; i += consensusParams.nSubsidyHalvingInterval) nSubsidy -= nSubsidy/14; for(int i = consensusParams.nSubsidyHalvingInterval; i <= nPrevHeight; i += consensusParams.nSubsidyHalvingInterval) nSubsidy -= nSubsidy/14;
// Hard fork to reduce the block reward by 10 extra percent (allowing budget super-blocks) // Hard fork to reduce the block reward by 10 extra percent (allowing budget super-blocks)
if(nPrevHeight > consensusParams.nBudgetPaymentsStartBlock) nSubsidy -= nSubsidy/10; CAmount nSuperblockPart = (nPrevHeight > consensusParams.nBudgetPaymentsStartBlock) ? nSubsidy/10 : 0;
return nSubsidy; return fSuperblockPartOnly ? nSuperblockPart : nSubsidy - nSuperblockPart;
} }
CAmount GetMasternodePayment(int nHeight, CAmount blockValue) CAmount GetMasternodePayment(int nHeight, CAmount blockValue)

View File

@ -254,7 +254,7 @@ bool GetTransaction(const uint256 &hash, CTransaction &tx, const Consensus::Para
/** Find the best known block, and make it the tip of the block chain */ /** Find the best known block, and make it the tip of the block chain */
bool ActivateBestChain(CValidationState& state, const CChainParams& chainparams, const CBlock* pblock = NULL); bool ActivateBestChain(CValidationState& state, const CChainParams& chainparams, const CBlock* pblock = NULL);
int64_t GetTotalCoinEstimate(int nHeight); int64_t GetTotalCoinEstimate(int nHeight);
CAmount GetBlockSubsidy(int nBits, int nHeight, const Consensus::Params& consensusParams); CAmount GetBlockSubsidy(int nBits, int nHeight, const Consensus::Params& consensusParams, bool fSuperblockPartOnly = false);
// ***TODO*** // ***TODO***
double ConvertBitsToDouble(unsigned int nBits); double ConvertBitsToDouble(unsigned int nBits);