aboutsummaryrefslogtreecommitdiff
path: root/src/cryptonote_core/blockchain.cpp
diff options
context:
space:
mode:
authoriamamyth <user@example.com>2019-08-18 17:26:58 -0700
committeriamamyth <user@example.com>2019-08-18 17:26:58 -0700
commit07cb087e5dd932c7afb9a7b2eafb99a003929e1f (patch)
tree0544616fe063fe1c7bb78ca099e24a62cbd0c29b /src/cryptonote_core/blockchain.cpp
parentMerge pull request #5779 (diff)
downloadmonero-07cb087e5dd932c7afb9a7b2eafb99a003929e1f.tar.xz
blockchain: Fix alt chain generated coins overflow
Apply the overflow logic used for computing already_generated_coins in the main chain to alternative chains.
Diffstat (limited to 'src/cryptonote_core/blockchain.cpp')
-rw-r--r--src/cryptonote_core/blockchain.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/cryptonote_core/blockchain.cpp b/src/cryptonote_core/blockchain.cpp
index 31e2ac136..6f1ca8526 100644
--- a/src/cryptonote_core/blockchain.cpp
+++ b/src/cryptonote_core/blockchain.cpp
@@ -1739,7 +1739,8 @@ bool Blockchain::handle_alternative_block(const block& b, const crypto::hash& id
const uint64_t prev_height = alt_chain.size() ? prev_data.height : m_db->get_block_height(b.prev_id);
bei.height = prev_height + 1;
uint64_t block_reward = get_outs_money_amount(b.miner_tx);
- bei.already_generated_coins = block_reward + (alt_chain.size() ? prev_data.already_generated_coins : m_db->get_block_already_generated_coins(prev_height));
+ const uint64_t prev_generated_coins = alt_chain.size() ? prev_data.already_generated_coins : m_db->get_block_already_generated_coins(prev_height);
+ bei.already_generated_coins = (block_reward < (MONEY_SUPPLY - prev_generated_coins)) ? prev_generated_coins + block_reward : MONEY_SUPPLY;
// verify that the block's timestamp is within the acceptable range
// (not earlier than the median of the last X blocks)