Merge pull request #5223

cc618f2f blockchain: fix off by one brought by the regtest mode fix (moneromooo-monero)
This commit is contained in:
Riccardo Spagni 2019-03-04 11:39:16 +02:00
commit 43d03c1050
No known key found for this signature in database
GPG Key ID: 55432DF31CCD4FCD
1 changed files with 4 additions and 2 deletions

View File

@ -3683,10 +3683,12 @@ bool Blockchain::update_next_cumulative_weight_limit(uint64_t *long_term_effecti
}
else
{
const uint64_t nblocks = std::min<uint64_t>(m_long_term_block_weights_window, db_height - 1);
uint64_t nblocks = std::min<uint64_t>(m_long_term_block_weights_window, db_height);
if (nblocks == db_height)
--nblocks;
weights.resize(nblocks);
for (uint64_t h = 0; h < nblocks; ++h)
weights[h] = m_db->get_block_long_term_weight(db_height - nblocks + h);
weights[h] = m_db->get_block_long_term_weight(db_height - nblocks + h - 1);
new_weights = weights;
long_term_median = epee::misc_utils::median(weights);
}