mirror of
https://codeberg.org/anoncontributorxmr/monero.git
synced 2024-11-23 11:23:26 +01:00
Merge pull request #237
41a95e7
add comment about avoiding overflow (smooth)754a785
minimum subsidy for mining incentives, remove unused LEGACY_FEE define (smooth)
This commit is contained in:
commit
8237705964
@ -51,6 +51,7 @@
|
|||||||
// MONEY_SUPPLY - total number coins to be generated
|
// MONEY_SUPPLY - total number coins to be generated
|
||||||
#define MONEY_SUPPLY ((uint64_t)(-1))
|
#define MONEY_SUPPLY ((uint64_t)(-1))
|
||||||
#define EMISSION_SPEED_FACTOR (20)
|
#define EMISSION_SPEED_FACTOR (20)
|
||||||
|
#define FINAL_SUBSIDY_PER_MINUTE ((uint64_t)300000000000) // 3 * pow(10, 11)
|
||||||
|
|
||||||
#define CRYPTONOTE_REWARD_BLOCKS_WINDOW 100
|
#define CRYPTONOTE_REWARD_BLOCKS_WINDOW 100
|
||||||
#define CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE 20000 //size of block (bytes) after which reward for block calculated using block size
|
#define CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE 20000 //size of block (bytes) after which reward for block calculated using block size
|
||||||
@ -61,9 +62,6 @@
|
|||||||
|
|
||||||
#define FEE_PER_KB ((uint64_t)10000000000) // pow(10, 10)
|
#define FEE_PER_KB ((uint64_t)10000000000) // pow(10, 10)
|
||||||
|
|
||||||
// temporarily to allow backward compatibility during the switch to per-kb
|
|
||||||
//#define MINING_ALLOWED_LEGACY_FEE ((uint64_t)100000000000) // pow(10, 11)
|
|
||||||
|
|
||||||
#define ORPHANED_BLOCKS_MAX_COUNT 100
|
#define ORPHANED_BLOCKS_MAX_COUNT 100
|
||||||
|
|
||||||
|
|
||||||
|
@ -1709,7 +1709,14 @@ bool blockchain_storage::handle_block_to_main_chain(const block& bl, const crypt
|
|||||||
bei.bl = bl;
|
bei.bl = bl;
|
||||||
bei.block_cumulative_size = cumulative_block_size;
|
bei.block_cumulative_size = cumulative_block_size;
|
||||||
bei.cumulative_difficulty = current_diffic;
|
bei.cumulative_difficulty = current_diffic;
|
||||||
bei.already_generated_coins = already_generated_coins + base_reward;
|
|
||||||
|
// 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())
|
if(m_blocks.size())
|
||||||
bei.cumulative_difficulty += m_blocks.back().cumulative_difficulty;
|
bei.cumulative_difficulty += m_blocks.back().cumulative_difficulty;
|
||||||
|
|
||||||
|
@ -60,6 +60,10 @@ namespace cryptonote {
|
|||||||
//-----------------------------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------------------------
|
||||||
bool get_block_reward(size_t median_size, size_t current_block_size, uint64_t already_generated_coins, uint64_t &reward) {
|
bool get_block_reward(size_t median_size, size_t current_block_size, uint64_t already_generated_coins, uint64_t &reward) {
|
||||||
uint64_t base_reward = (MONEY_SUPPLY - already_generated_coins) >> EMISSION_SPEED_FACTOR;
|
uint64_t base_reward = (MONEY_SUPPLY - already_generated_coins) >> EMISSION_SPEED_FACTOR;
|
||||||
|
if (base_reward < FINAL_SUBSIDY_PER_MINUTE)
|
||||||
|
{
|
||||||
|
base_reward = FINAL_SUBSIDY_PER_MINUTE;
|
||||||
|
}
|
||||||
|
|
||||||
//make it soft
|
//make it soft
|
||||||
if (median_size < CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE) {
|
if (median_size < CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE) {
|
||||||
|
Loading…
Reference in New Issue
Block a user