mirror of
https://github.com/monero-project/monero.git
synced 2024-12-23 03:59:33 +00:00
blockchain: fix long term block weight for regtest mode
This commit is contained in:
parent
f96e431a15
commit
49896e5c63
1 changed files with 15 additions and 7 deletions
|
@ -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);
|
const uint64_t block_weight = m_db->get_block_weight(db_height - 1);
|
||||||
|
|
||||||
std::vector<uint64_t> weights;
|
std::vector<uint64_t> weights, new_weights;
|
||||||
const uint64_t nblocks = std::min<uint64_t>(m_long_term_block_weights_window, db_height);
|
uint64_t long_term_median;
|
||||||
weights.resize(nblocks);
|
if (db_height == 1)
|
||||||
for (uint64_t h = 0; h < nblocks; ++h)
|
{
|
||||||
weights[h] = m_db->get_block_long_term_weight(db_height - nblocks + h - 1);
|
long_term_median = CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE_V5;
|
||||||
std::vector<uint64_t> new_weights = weights;
|
}
|
||||||
uint64_t long_term_median = epee::misc_utils::median(weights);
|
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);
|
||||||
|
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);
|
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;
|
uint64_t short_term_constraint = m_long_term_effective_median_block_weight + m_long_term_effective_median_block_weight * 2 / 5;
|
||||||
|
|
Loading…
Reference in a new issue