aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorsmooth <iamjaviersmooth@gmail.com>2015-03-05 00:45:54 -0800
committersmooth <iamjaviersmooth@gmail.com>2015-03-05 00:45:54 -0800
commit41a95e7b11ba9eb7ef94e1708f2407608148b8ed (patch)
tree7bb4ad8cd910c947c709665c347f7a53e3572025 /src
parentminimum subsidy for mining incentives, remove unused LEGACY_FEE define (diff)
downloadmonero-41a95e7b11ba9eb7ef94e1708f2407608148b8ed.tar.xz
add comment about avoiding overflow
Diffstat (limited to 'src')
-rw-r--r--src/cryptonote_core/blockchain_storage.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/cryptonote_core/blockchain_storage.cpp b/src/cryptonote_core/blockchain_storage.cpp
index 1f35e6a5b..42269e05c 100644
--- a/src/cryptonote_core/blockchain_storage.cpp
+++ b/src/cryptonote_core/blockchain_storage.cpp
@@ -1709,6 +1709,12 @@ bool blockchain_storage::handle_block_to_main_chain(const block& bl, const crypt
bei.bl = bl;
bei.block_cumulative_size = cumulative_block_size;
bei.cumulative_difficulty = current_diffic;
+
+ // In the "tail" state when the minimum subsidy (implemented in get_block_reward) is in effect, the number of
+ // coins will eventually exceed MONEY_SUPPLY and overflow a uint64. To prevent overflow, cap already_generated_coins
+ // at MONEY_SUPPLY. already_generated_coins is only used to compute the block subsidy and MONEY_SUPPLY yields a
+ // subsidy of 0 under the base formula and therefore the minimum subsidy >0 in the tail state.
+
bei.already_generated_coins = base_reward < (MONEY_SUPPLY-already_generated_coins) ? already_generated_coins + base_reward : MONEY_SUPPLY;
if(m_blocks.size())