diff --git a/src/cryptonote_core/blockchain.cpp b/src/cryptonote_core/blockchain.cpp index 70cfb9137..1a533822f 100644 --- a/src/cryptonote_core/blockchain.cpp +++ b/src/cryptonote_core/blockchain.cpp @@ -502,7 +502,8 @@ bool Blockchain::init(BlockchainDB* db, const network_type nettype, bool offline const uint64_t nblocks = std::min(m_long_term_block_weights.capacity(), db_height); while (m_long_term_block_weights.size() < nblocks) { - m_long_term_block_weights.push_front(db_height - 1 - m_long_term_block_weights.size()); + uint64_t weight = m_db->get_block_long_term_weight(db_height - 1 - m_long_term_block_weights.size()); + m_long_term_block_weights.push_front(weight); } m_long_term_block_weights_height = db_height; @@ -3636,7 +3637,8 @@ void Blockchain::pop_from_long_term_block_weights() if (m_long_term_block_weights_height + 1 > m_long_term_block_weights.capacity()) { uint64_t block_height = m_long_term_block_weights_height - m_long_term_block_weights.capacity() + 1; - m_long_term_block_weights.push_front(block_height); + uint64_t weight = m_db->get_block_long_term_weight(block_height); + m_long_term_block_weights.push_front(weight); } } //------------------------------------------------------------------ diff --git a/tests/block_weight/block_weight.cpp b/tests/block_weight/block_weight.cpp index 9b7343ca3..3b0b6f1e6 100644 --- a/tests/block_weight/block_weight.cpp +++ b/tests/block_weight/block_weight.cpp @@ -167,16 +167,9 @@ static void test(test_t t, uint64_t blocks) if (!bc->update_next_cumulative_weight_limit()) { - fprintf(stderr, "Failed to update cumulative weight limit 2\n"); + fprintf(stderr, "Failed to update cumulative weight limit\n"); exit(1); } - if(0)if (!bc->update_next_cumulative_weight_limit()) - { - fprintf(stderr, "Failed to update cumulative weight limit 2\n"); - exit(1); - } -uint64_t last = bc->get_db().get_block_long_term_weight(bc->get_db().height() - 1); -if (last != ltw) std::cout << "Inconsistency at " << h << std::endl; std::cout << "H " << h << ", BW " << w << ", EMBW " << effective_block_weight_median << ", LTBW " << ltw << std::endl; } }