blockchain: use high bound block reward on error where appropriate

If the block reward to use for the fee calculation can't be
calculated (should not happen in practice), use a high bound,
so we use a fee overestimate that will be accepted by the network.
This commit is contained in:
moneromooo-monero 2016-12-01 10:28:46 +00:00
parent c36cb54340
commit 204b1bff62
No known key found for this signature in database
GPG Key ID: 686F07454D6CEFC3
1 changed files with 7 additions and 1 deletions

View File

@ -73,6 +73,9 @@ extern "C" void slow_hash_free_state();
DISABLE_VS_WARNINGS(4267) DISABLE_VS_WARNINGS(4267)
// used to overestimate the block reward when estimating a per kB to use
#define BLOCK_REWARD_OVERESTIMATE (10 * 1000000000000)
static const struct { static const struct {
uint8_t version; uint8_t version;
uint64_t height; uint64_t height;
@ -2783,7 +2786,10 @@ uint64_t Blockchain::get_dynamic_per_kb_fee_estimate(uint64_t grace_blocks) cons
uint64_t already_generated_coins = m_db->height() ? m_db->get_block_already_generated_coins(m_db->height() - 1) : 0; uint64_t already_generated_coins = m_db->height() ? m_db->get_block_already_generated_coins(m_db->height() - 1) : 0;
uint64_t base_reward; uint64_t base_reward;
if (!get_block_reward(median, 1, already_generated_coins, base_reward, version)) if (!get_block_reward(median, 1, already_generated_coins, base_reward, version))
return false; {
LOG_PRINT_L1("Failed to determine block reward, using placeholder " << print_money(BLOCK_REWARD_OVERESTIMATE) << " as a high bound");
base_reward = BLOCK_REWARD_OVERESTIMATE;
}
uint64_t fee = get_dynamic_per_kb_fee(base_reward, median); uint64_t fee = get_dynamic_per_kb_fee(base_reward, median);
LOG_PRINT_L2("Estimating " << grace_blocks << "-block fee at " << print_money(fee) << "/kB"); LOG_PRINT_L2("Estimating " << grace_blocks << "-block fee at " << print_money(fee) << "/kB");