forked from lthn/blockchain
minor refactoring: get_base_block_reward() now requires only block height (for clarity)
This commit is contained in:
parent
b102d0d3b9
commit
15e653a8ae
6 changed files with 18 additions and 9 deletions
|
|
@ -6533,7 +6533,7 @@ bool blockchain_storage::handle_block_to_main_chain(const block& bl, const crypt
|
|||
}
|
||||
|
||||
boost::multiprecision::uint128_t already_generated_coins = m_db_blocks.size() ? m_db_blocks.back()->already_generated_coins:0;
|
||||
uint64_t base_reward = get_base_block_reward(is_pos_bl, already_generated_coins, height);
|
||||
uint64_t base_reward = get_base_block_reward(height);
|
||||
|
||||
if (!m_is_in_checkpoint_zone)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -4057,7 +4057,7 @@ namespace currency
|
|||
pei_rpc.miner_text_info = eud.buff;
|
||||
}
|
||||
|
||||
pei_rpc.base_reward = get_base_block_reward(is_pos_block(bei_chain.bl), bei_chain.already_generated_coins, bei_chain.height);
|
||||
pei_rpc.base_reward = get_base_block_reward(bei_chain.height);
|
||||
pei_rpc.summary_reward = get_reward_from_miner_tx(bei_chain.bl.miner_tx);
|
||||
pei_rpc.penalty = (pei_rpc.base_reward + pei_rpc.total_fee) - pei_rpc.summary_reward;
|
||||
return true;
|
||||
|
|
@ -4110,7 +4110,7 @@ namespace currency
|
|||
return CURRENCY_MAX_BLOCK_SIZE;
|
||||
}
|
||||
//-----------------------------------------------------------------------------------------------
|
||||
uint64_t get_base_block_reward(bool is_pos, const boost::multiprecision::uint128_t& already_generated_coins, uint64_t height)
|
||||
uint64_t get_base_block_reward(uint64_t height)
|
||||
{
|
||||
if (!height)
|
||||
return PREMINE_AMOUNT;
|
||||
|
|
@ -4118,9 +4118,18 @@ namespace currency
|
|||
return CURRENCY_BLOCK_REWARD;
|
||||
}
|
||||
//-----------------------------------------------------------------------------------------------
|
||||
// Modern version, requires only necessary arguments. Returns 0 if block is too big (current_block_size > 2 * median_block_size)
|
||||
uint64_t get_block_reward(uint64_t height, size_t median_block_size, size_t current_block_size)
|
||||
{
|
||||
uint64_t reward = 0;
|
||||
get_block_reward(/* is_pos - doesn't matter */ false, median_block_size, current_block_size, /* boost::multiprecision::uint128_t -- doesn't matter*/ boost::multiprecision::uint128_t(0), reward, height);
|
||||
return reward;
|
||||
}
|
||||
//-----------------------------------------------------------------------------------------------
|
||||
// legacy version, some arguments are unnecessary now
|
||||
bool get_block_reward(bool is_pos, size_t median_size, size_t current_block_size, const boost::multiprecision::uint128_t& already_generated_coins, uint64_t &reward, uint64_t height)
|
||||
{
|
||||
uint64_t base_reward = get_base_block_reward(is_pos, already_generated_coins, height);
|
||||
uint64_t base_reward = get_base_block_reward(height);
|
||||
|
||||
//make it soft
|
||||
if (median_size < CURRENCY_BLOCK_GRANTED_FULL_REWARD_ZONE)
|
||||
|
|
|
|||
|
|
@ -523,7 +523,7 @@ namespace currency
|
|||
size_t get_max_block_size();
|
||||
size_t get_max_tx_size();
|
||||
bool get_block_reward(bool is_pos, size_t median_size, size_t current_block_size, const boost::multiprecision::uint128_t& already_generated_coins, uint64_t &reward, uint64_t height);
|
||||
uint64_t get_base_block_reward(bool is_pos, const boost::multiprecision::uint128_t& already_generated_coins, uint64_t height);
|
||||
uint64_t get_base_block_reward(uint64_t height);
|
||||
bool is_payment_id_size_ok(const payment_id_t& payment_id);
|
||||
std::string get_account_address_as_str(const account_public_address& addr);
|
||||
std::string get_account_address_and_payment_id_as_str(const account_public_address& addr, const payment_id_t& payment_id);
|
||||
|
|
|
|||
|
|
@ -176,7 +176,7 @@ namespace currency
|
|||
res.pow_sequence_factor = m_core.get_blockchain_storage().get_current_sequence_factor(false);
|
||||
if (req.flags&(COMMAND_RPC_GET_INFO_FLAG_POS_DIFFICULTY | COMMAND_RPC_GET_INFO_FLAG_TOTAL_COINS))
|
||||
{
|
||||
res.block_reward = currency::get_base_block_reward(true, total_coins, res.height);
|
||||
res.block_reward = currency::get_base_block_reward(res.height);
|
||||
currency::block b = AUTO_VAL_INIT(b);
|
||||
m_core.get_blockchain_storage().get_top_block(b);
|
||||
res.last_block_total_reward = currency::get_reward_from_miner_tx(b.miner_tx);
|
||||
|
|
|
|||
|
|
@ -69,8 +69,8 @@ bool block_template_against_txs_size::c1(currency::core& c, size_t ev_index, con
|
|||
|
||||
uint64_t top_block_height = bcs.get_top_block_height();
|
||||
uint64_t blocksize_limit = bcs.get_current_comulative_blocksize_limit();
|
||||
uint64_t base_block_reward_pow = get_base_block_reward(false, bcs.total_coins(), top_block_height + 1);
|
||||
uint64_t base_block_reward_pos = get_base_block_reward(true, bcs.total_coins(), top_block_height + 1);
|
||||
uint64_t base_block_reward_pow = get_base_block_reward(top_block_height + 1);
|
||||
uint64_t base_block_reward_pos = base_block_reward_pow;
|
||||
|
||||
g_block_txs_fee = TESTS_DEFAULT_FEE; // passing an argument to custom_fill_block_template_func via global variable (not perfect but works well)
|
||||
|
||||
|
|
|
|||
|
|
@ -828,7 +828,7 @@ uint64_t test_generator::get_base_reward_for_next_block(const crypto::hash& head
|
|||
auto it = m_blocks_info.find(head_id);
|
||||
if (it == m_blocks_info.end())
|
||||
return 0;
|
||||
return get_base_block_reward(!pow, it->second.already_generated_coins, get_block_height(it->second.b));
|
||||
return get_base_block_reward(get_block_height(it->second.b));
|
||||
}
|
||||
|
||||
bool test_generator::find_nounce(currency::block& blk, std::vector<const block_info*>& blocks, wide_difficulty_type dif, uint64_t height) const
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue