Skip to content

Commit

Permalink
Make sure m_timestamps has the correct number for computing difficulty
Browse files Browse the repository at this point in the history
  • Loading branch information
miltonf committed Nov 7, 2018
1 parent 7934b52 commit ae56273
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/cryptonote_core/blockchain.cpp
Expand Up @@ -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));
Expand Down

0 comments on commit ae56273

Please sign in to comment.