diff options
author | luigi1111 <luigi1111w@gmail.com> | 2019-09-04 09:37:32 -0500 |
---|---|---|
committer | luigi1111 <luigi1111w@gmail.com> | 2019-09-04 09:37:32 -0500 |
commit | e4f11a68fe4d27278a409e37e3d3bcebd20fc39b (patch) | |
tree | b57333794cfe04abd9cc57b17ed50df65c1c9287 /src/cryptonote_core/blockchain.cpp | |
parent | Merge pull request #5814 (diff) | |
parent | blockchain: Fix alt chain generated coins overflow (diff) | |
download | monero-e4f11a68fe4d27278a409e37e3d3bcebd20fc39b.tar.xz |
Merge pull request #5819
07cb087 blockchain: Fix alt chain generated coins overflow (iamamyth)
Diffstat (limited to 'src/cryptonote_core/blockchain.cpp')
-rw-r--r-- | src/cryptonote_core/blockchain.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/cryptonote_core/blockchain.cpp b/src/cryptonote_core/blockchain.cpp index dab1a0a96..8ed0e526a 100644 --- a/src/cryptonote_core/blockchain.cpp +++ b/src/cryptonote_core/blockchain.cpp @@ -1738,7 +1738,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) |