From cc618f2fe48302157ea17d600f3820aab72f29c0 Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Mon, 4 Mar 2019 09:31:06 +0000 Subject: [PATCH] blockchain: fix off by one brought by the regtest mode fix --- src/cryptonote_core/blockchain.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/cryptonote_core/blockchain.cpp b/src/cryptonote_core/blockchain.cpp index c956eea7b..0ed7a66b4 100644 --- a/src/cryptonote_core/blockchain.cpp +++ b/src/cryptonote_core/blockchain.cpp @@ -3683,10 +3683,12 @@ bool Blockchain::update_next_cumulative_weight_limit(uint64_t *long_term_effecti } else { - const uint64_t nblocks = std::min(m_long_term_block_weights_window, db_height - 1); + uint64_t nblocks = std::min(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); }