aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGavin Andresen <gavinandresen@gmail.com>2014-04-02 21:31:17 -0400
committerGavin Andresen <gavinandresen@gmail.com>2014-04-02 21:31:17 -0400
commit8556b0298d6b7101b063862fb4ab6b4a67dd2361 (patch)
treeef7d39b0c429113b6eb18d78f2b1fa742208daad /src
parent397521d632b4a49e61c8ea2246135f9cc00e57c4 (diff)
parent5cfd3a70a67ba707a8f074a1730724a6e86353b8 (diff)
downloadbitcoin-8556b0298d6b7101b063862fb4ab6b4a67dd2361.tar.xz
Merge pull request #3842 from ditto-b/master
Fix for GetBlockValue() after block 13,440,000
Diffstat (limited to 'src')
-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;