aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main.cpp7
-rw-r--r--src/test/main_tests.cpp2
2 files changed, 7 insertions, 2 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 12f76cc9ea..45f4935e44 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;
}
diff --git a/src/test/main_tests.cpp b/src/test/main_tests.cpp
index 3f8ad20020..8863ba4004 100644
--- a/src/test/main_tests.cpp
+++ b/src/test/main_tests.cpp
@@ -12,7 +12,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;