Skip to content

Commit

Permalink
Merge pull request #5819
Browse files Browse the repository at this point in the history
07cb087 blockchain: Fix alt chain generated coins overflow (iamamyth)
  • Loading branch information
luigi1111 committed Sep 4, 2019
2 parents 6fe281d + 07cb087 commit e4f11a6
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/cryptonote_core/blockchain.cpp
Expand Up @@ -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)
Expand Down

0 comments on commit e4f11a6

Please sign in to comment.