From 51434cfff52d23705fd6e298c0f72e12ed0144a1 Mon Sep 17 00:00:00 2001 From: UdjinM6 Date: Sun, 21 Aug 2016 06:18:04 +0300 Subject: [PATCH] Add ability to calculate only superblock part of subsidy in GetBlockSubsidy() --- src/main.cpp | 6 +++--- src/main.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 17ec86690a..5ddd8d164a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -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 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); @@ -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; // 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) diff --git a/src/main.h b/src/main.h index a35c03ca6a..5f5a30266a 100644 --- a/src/main.h +++ b/src/main.h @@ -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 */ bool ActivateBestChain(CValidationState& state, const CChainParams& chainparams, const CBlock* pblock = NULL); 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*** double ConvertBitsToDouble(unsigned int nBits);