From 4c94a061c060e8c7efc8a851bd4fec9ef787ab84 Mon Sep 17 00:00:00 2001 From: KabDeveloper Date: Wed, 26 May 2021 23:01:51 +0100 Subject: [PATCH] Remove GetBlockSubsidy (Not Used - replaced) --- src/test/main_tests.cpp | 48 ----------------------------------------- src/validation.cpp | 13 ----------- src/validation.h | 1 - 3 files changed, 62 deletions(-) diff --git a/src/test/main_tests.cpp b/src/test/main_tests.cpp index 143c63243..b7c9d6358 100644 --- a/src/test/main_tests.cpp +++ b/src/test/main_tests.cpp @@ -13,54 +13,6 @@ BOOST_FIXTURE_TEST_SUITE(main_tests, TestingSetup) -static void TestBlockSubsidyHalvings(const Consensus::Params& consensusParams) -{ - // tested in dogecoin_tests.cpp - //int maxHalvings = 64; - //CAmount nInitialSubsidy = 50 * COIN; - - //CAmount nPreviousSubsidy = nInitialSubsidy * 2; // for height == 0 - //BOOST_CHECK_EQUAL(nPreviousSubsidy, nInitialSubsidy * 2); - //for (int nHalvings = 0; nHalvings < maxHalvings; nHalvings++) { - // int nHeight = nHalvings * consensusParams.nSubsidyHalvingInterval; - // CAmount nSubsidy = GetBlockSubsidy(nHeight, consensusParams); - // BOOST_CHECK(nSubsidy <= nInitialSubsidy); - // BOOST_CHECK_EQUAL(nSubsidy, nPreviousSubsidy / 2); - // nPreviousSubsidy = nSubsidy; - //} - //BOOST_CHECK_EQUAL(GetBlockSubsidy(maxHalvings * consensusParams.nSubsidyHalvingInterval, consensusParams), 0); -} - -static void TestBlockSubsidyHalvings(int nSubsidyHalvingInterval) -{ - // tested in dogecoin_tests.cpp - //Consensus::Params consensusParams; - //consensusParams.nSubsidyHalvingInterval = nSubsidyHalvingInterval; - //TestBlockSubsidyHalvings(consensusParams); -} - -BOOST_AUTO_TEST_CASE(block_subsidy_test) -{ - // tested in dogecoin_tests.cpp - //TestBlockSubsidyHalvings(Params(CBaseChainParams::MAIN).GetConsensus()); // As in main - //TestBlockSubsidyHalvings(150); // As in regtest - //TestBlockSubsidyHalvings(1000); // Just another interval -} - -BOOST_AUTO_TEST_CASE(subsidy_limit_test) -{ - // tested in dogecoin_tests.cpp - //const Consensus::Params& consensusParams = Params(CBaseChainParams::MAIN).GetConsensus(); - //CAmount nSum = 0; - //for (int nHeight = 0; nHeight < 14000000; nHeight += 1000) { - // CAmount nSubsidy = GetBlockSubsidy(nHeight, consensusParams); - // BOOST_CHECK(nSubsidy <= 50 * COIN); - // nSum += nSubsidy * 1000; - // BOOST_CHECK(MoneyRange(nSum)); - //} - //BOOST_CHECK_EQUAL(nSum, 2099999997690000ULL); -} - bool ReturnFalse() { return false; } bool ReturnTrue() { return true; } diff --git a/src/validation.cpp b/src/validation.cpp index 8fc4ef6c7..93532d674 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -1219,19 +1219,6 @@ bool ReadBlockHeaderFromDisk(CBlockHeader& block, const CBlockIndex* pindex, con return ReadBlockOrHeader(block, pindex, consensusParams, fCheckPOW); } -CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams) -{ - int halvings = nHeight / consensusParams.nSubsidyHalvingInterval; - // Force block reward to zero when right shift is undefined. - if (halvings >= 64) - return 0; - - CAmount nSubsidy = 50 * COIN; - // Subsidy is cut in half every 210,000 blocks which will occur approximately every 4 years. - nSubsidy >>= halvings; - return nSubsidy; -} - bool IsInitialBlockDownload() { const CChainParams& chainParams = Params(); diff --git a/src/validation.h b/src/validation.h index f5f0e5bb1..80285d516 100644 --- a/src/validation.h +++ b/src/validation.h @@ -289,7 +289,6 @@ std::string GetWarnings(const std::string& strFor); bool GetTransaction(const uint256 &hash, CTransactionRef &tx, const Consensus::Params& params, uint256 &hashBlock, bool fAllowSlow = false); /** Find the best known block, and make it the tip of the block chain */ bool ActivateBestChain(CValidationState& state, const CChainParams& chainparams, std::shared_ptr pblock = std::shared_ptr()); -CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams); /** Guess verification progress (as a fraction between 0.0=genesis and 1.0=current tip). */ double GuessVerificationProgress(const ChainTxData& data, CBlockIndex* pindex);