Skip to content

Commit 8556b02

Browse files
committed
Merge pull request #3842 from ditto-b/master
Fix for GetBlockValue() after block 13,440,000
2 parents 397521d + 5cfd3a7 commit 8556b02

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/main.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1176,9 +1176,14 @@ void static PruneOrphanBlocks()
11761176
int64_t GetBlockValue(int nHeight, int64_t nFees)
11771177
{
11781178
int64_t nSubsidy = 50 * COIN;
1179+
int halvings = nHeight / Params().SubsidyHalvingInterval();
1180+
1181+
// Force block reward to zero when right shift is undefined.
1182+
if (halvings >= 64)
1183+
return nFees;
11791184

11801185
// Subsidy is cut in half every 210,000 blocks which will occur approximately every 4 years.
1181-
nSubsidy >>= (nHeight / Params().SubsidyHalvingInterval());
1186+
nSubsidy >>= halvings;
11821187

11831188
return nSubsidy + nFees;
11841189
}

src/test/main_tests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ BOOST_AUTO_TEST_SUITE(main_tests)
1212
BOOST_AUTO_TEST_CASE(subsidy_limit_test)
1313
{
1414
uint64_t nSum = 0;
15-
for (int nHeight = 0; nHeight < 7000000; nHeight += 1000) {
15+
for (int nHeight = 0; nHeight < 14000000; nHeight += 1000) {
1616
uint64_t nSubsidy = GetBlockValue(nHeight, 0);
1717
BOOST_CHECK(nSubsidy <= 50 * COIN);
1818
nSum += nSubsidy * 1000;

0 commit comments

Comments
 (0)