blockchain: fix long term block weight for regtest mode

This commit is contained in:
moneromooo-monero 2019-02-26 23:34:15 +00:00
parent f96e431a15
commit 49896e5c63
No known key found for this signature in database
GPG key ID: 686F07454D6CEFC3

View file

@ -3675,13 +3675,21 @@ bool Blockchain::update_next_cumulative_weight_limit(uint64_t *long_term_effecti
{
const uint64_t block_weight = m_db->get_block_weight(db_height - 1);
std::vector<uint64_t> weights;
const uint64_t nblocks = std::min<uint64_t>(m_long_term_block_weights_window, db_height);
std::vector<uint64_t> weights, new_weights;
uint64_t long_term_median;
if (db_height == 1)
{
long_term_median = CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE_V5;
}
else
{
const uint64_t nblocks = std::min<uint64_t>(m_long_term_block_weights_window, db_height - 1);
weights.resize(nblocks);
for (uint64_t h = 0; h < nblocks; ++h)
weights[h] = m_db->get_block_long_term_weight(db_height - nblocks + h - 1);
std::vector<uint64_t> new_weights = weights;
uint64_t long_term_median = epee::misc_utils::median(weights);
weights[h] = m_db->get_block_long_term_weight(db_height - nblocks + h);
new_weights = weights;
long_term_median = epee::misc_utils::median(weights);
}
m_long_term_effective_median_block_weight = std::max<uint64_t>(CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE_V5, long_term_median);
uint64_t short_term_constraint = m_long_term_effective_median_block_weight + m_long_term_effective_median_block_weight * 2 / 5;