From c5a9d2ca9e3234db9687c8cbec4b5b93ec161190 Mon Sep 17 00:00:00 2001 From: ditto-b Date: Mon, 10 Mar 2014 19:02:36 -0500 Subject: [PATCH 1/2] Fix for GetBlockValue() after block 13,440,000 Forces the block reward to zero when right shift in GetBlockValue() is undefined, after 64 reward halvings (block height 13,440,000). --- src/main.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 2d8ac0c9b..305d7045b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1176,9 +1176,14 @@ void static PruneOrphanBlocks() int64_t GetBlockValue(int nHeight, int64_t nFees) { int64_t nSubsidy = 50 * COIN; + int halvings = nHeight / Params().SubsidyHalvingInterval(); + + // Force block reward to zero when right shift is undefined. + if (halvings >= 64) + return nFees; // Subsidy is cut in half every 210,000 blocks which will occur approximately every 4 years. - nSubsidy >>= (nHeight / Params().SubsidyHalvingInterval()); + nSubsidy >>= halvings; return nSubsidy + nFees; } From 5cfd3a70a67ba707a8f074a1730724a6e86353b8 Mon Sep 17 00:00:00 2001 From: ditto-b Date: Wed, 2 Apr 2014 18:00:08 -0500 Subject: [PATCH 2/2] Edit subsidy_limit_test to account for BIP42 Because no one wants 4 gold mines being discovered every mibillenium. --- src/test/main_tests.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/main_tests.cpp b/src/test/main_tests.cpp index b7f4312cd..d2917bcb3 100644 --- a/src/test/main_tests.cpp +++ b/src/test/main_tests.cpp @@ -8,7 +8,7 @@ BOOST_AUTO_TEST_SUITE(main_tests) BOOST_AUTO_TEST_CASE(subsidy_limit_test) { uint64_t nSum = 0; - for (int nHeight = 0; nHeight < 7000000; nHeight += 1000) { + for (int nHeight = 0; nHeight < 14000000; nHeight += 1000) { uint64_t nSubsidy = GetBlockValue(nHeight, 0); BOOST_CHECK(nSubsidy <= 50 * COIN); nSum += nSubsidy * 1000;