mirror of
https://github.com/jwinterm/aeon.git
synced 2026-10-17 05:01:26 +02:00
properly scale block reward for block target
This commit is contained in:
@@ -32,6 +32,7 @@
|
||||
|
||||
#define HARDFORK_1_HEIGHT 1000
|
||||
#define HARDFORK_1_OLD_TARGET 1
|
||||
#define HARDFORK_1_OLD_SPEED_FACTOR (20)
|
||||
#define HARDFORK_1_POW_SPEED_MULTIPLIER 2
|
||||
#define HARDFORK_1_DIFFADJ HARDFORK_1_POW_SPEED_MULTIPLIER
|
||||
#define HARDFORK_1_DIFFADJ_WINDOW 360
|
||||
@@ -52,7 +53,7 @@
|
||||
|
||||
// MONEY_SUPPLY - total number coins to be generated
|
||||
#define MONEY_SUPPLY ((uint64_t)(-1))
|
||||
#define EMISSION_SPEED_FACTOR (20)
|
||||
#define EMISSION_SPEED_FACTOR (18)
|
||||
|
||||
#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
|
||||
|
||||
@@ -533,7 +533,7 @@ bool blockchain_storage::prevalidate_miner_transaction(const block& b, uint64_t
|
||||
return true;
|
||||
}
|
||||
//------------------------------------------------------------------
|
||||
bool blockchain_storage::validate_miner_transaction(const block& b, size_t cumulative_block_size, uint64_t fee, uint64_t& base_reward, uint64_t already_generated_coins)
|
||||
bool blockchain_storage::validate_miner_transaction(const block& b, size_t cumulative_block_size, uint64_t fee, uint64_t& base_reward, uint64_t already_generated_coins, size_t height)
|
||||
{
|
||||
//validate reward
|
||||
uint64_t money_in_use = 0;
|
||||
@@ -542,7 +542,7 @@ bool blockchain_storage::validate_miner_transaction(const block& b, size_t cumul
|
||||
|
||||
std::vector<size_t> last_blocks_sizes;
|
||||
get_last_n_blocks_sizes(last_blocks_sizes, CRYPTONOTE_REWARD_BLOCKS_WINDOW);
|
||||
if (!get_block_reward(epee::misc_utils::median(last_blocks_sizes), cumulative_block_size, already_generated_coins, base_reward)) {
|
||||
if (!get_block_reward(epee::misc_utils::median(last_blocks_sizes), cumulative_block_size, already_generated_coins, base_reward, height)) {
|
||||
LOG_PRINT_L0("block size " << cumulative_block_size << " is bigger than allowed for this blockchain");
|
||||
return false;
|
||||
}
|
||||
@@ -1632,7 +1632,7 @@ bool blockchain_storage::handle_block_to_main_chain(const block& bl, const crypt
|
||||
}
|
||||
uint64_t base_reward = 0;
|
||||
uint64_t already_generated_coins = m_blocks.size() ? m_blocks.back().already_generated_coins:0;
|
||||
if(!validate_miner_transaction(bl, cumulative_block_size, fee_summary, base_reward, already_generated_coins))
|
||||
if(!validate_miner_transaction(bl, cumulative_block_size, fee_summary, base_reward, already_generated_coins, get_current_blockchain_height()))
|
||||
{
|
||||
LOG_PRINT_L0("Block with id: " << id
|
||||
<< " have wrong miner transaction");
|
||||
|
||||
@@ -225,7 +225,7 @@ namespace cryptonote
|
||||
bool handle_alternative_block(const block& b, const crypto::hash& id, block_verification_context& bvc);
|
||||
difficulty_type get_next_difficulty_for_alternative_chain(const std::list<blocks_ext_by_hash::iterator>& alt_chain, block_extended_info& bei);
|
||||
bool prevalidate_miner_transaction(const block& b, uint64_t height);
|
||||
bool validate_miner_transaction(const block& b, size_t cumulative_block_size, uint64_t fee, uint64_t& base_reward, uint64_t already_generated_coins);
|
||||
bool validate_miner_transaction(const block& b, size_t cumulative_block_size, uint64_t fee, uint64_t& base_reward, uint64_t already_generated_coins, size_t height);
|
||||
bool validate_transaction(const block& b, uint64_t height, const transaction& tx);
|
||||
bool rollback_blockchain_switching(std::list<block>& original_chain, size_t rollback_height);
|
||||
bool add_transaction_from_block(const transaction& tx, const crypto::hash& tx_id, const crypto::hash& bl_id, uint64_t bl_height);
|
||||
|
||||
@@ -58,8 +58,9 @@ namespace cryptonote {
|
||||
return CRYPTONOTE_MAX_TX_SIZE;
|
||||
}
|
||||
//-----------------------------------------------------------------------------------------------
|
||||
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;
|
||||
bool get_block_reward(size_t median_size, size_t current_block_size, uint64_t already_generated_coins, uint64_t &reward, size_t height) {
|
||||
int speed = height < HARDFORK_1_HEIGHT ? HARDFORK_1_OLD_SPEED_FACTOR : EMISSION_SPEED_FACTOR;
|
||||
uint64_t base_reward = (MONEY_SUPPLY - already_generated_coins) >> speed;
|
||||
|
||||
//make it soft
|
||||
if (median_size < CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE) {
|
||||
|
||||
@@ -64,7 +64,7 @@ namespace cryptonote {
|
||||
/************************************************************************/
|
||||
size_t get_max_block_size();
|
||||
size_t get_max_tx_size();
|
||||
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, size_t height);
|
||||
uint8_t get_account_address_checksum(const public_address_outer_blob& bl);
|
||||
std::string get_account_address_as_str(const account_public_address& adr);
|
||||
bool get_account_address_from_str(account_public_address& adr, const std::string& str);
|
||||
|
||||
@@ -95,7 +95,7 @@ namespace cryptonote
|
||||
in.height = height;
|
||||
|
||||
uint64_t block_reward;
|
||||
if(!get_block_reward(median_size, current_block_size, already_generated_coins, block_reward))
|
||||
if(!get_block_reward(median_size, current_block_size, already_generated_coins, block_reward, height))
|
||||
{
|
||||
LOG_PRINT_L0("Block is too big");
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user