Permalink
Browse files

Make sure m_timestamps has the correct number for computing difficulty

  • Loading branch information...
miltonf committed Nov 7, 2018
1 parent 7934b52 commit ae562730ff5e1c612206f9ac39fd5ba99a81c477
Showing with 1 addition and 1 deletion.
  1. +1 −1 src/cryptonote_core/blockchain.cpp
@@ -775,7 +775,7 @@ difficulty_type Blockchain::get_difficulty_for_next_block()
// then when the next block difficulty is queried, push the latest height data and
// pop the oldest one from the list. This only requires 1x read per height instead
// of doing 735 (DIFFICULTY_BLOCKS_COUNT).
if (m_timestamps_and_difficulties_height != 0 && ((height - m_timestamps_and_difficulties_height) == 1))
if (m_timestamps_and_difficulties_height != 0 && ((height - m_timestamps_and_difficulties_height) == 1) && m_timestamps.size() >= DIFFICULTY_BLOCKS_COUNT)
{
uint64_t index = height - 1;
m_timestamps.push_back(m_db->get_block_timestamp(index));

0 comments on commit ae56273

Please sign in to comment.