|
|
|
@ -898,7 +898,7 @@ start:
|
|
|
|
|
// of doing 735 (DIFFICULTY_BLOCKS_COUNT).
|
|
|
|
|
bool check = false;
|
|
|
|
|
uint8_t version = get_current_hard_fork_version();
|
|
|
|
|
uint64_t difficulty_blocks_count = version == 20 ? DIFFICULTY_BLOCKS_COUNT_V4 : version <= 17 && version >= 11 ? DIFFICULTY_BLOCKS_COUNT_V3 : version <= 10 && version >= 8 ? DIFFICULTY_BLOCKS_COUNT_V2 : DIFFICULTY_BLOCKS_COUNT;
|
|
|
|
|
uint64_t difficulty_blocks_count = version >= 20 ? DIFFICULTY_BLOCKS_COUNT_V4 : version <= 17 && version >= 11 ? DIFFICULTY_BLOCKS_COUNT_V3 : version <= 10 && version >= 8 ? DIFFICULTY_BLOCKS_COUNT_V2 : DIFFICULTY_BLOCKS_COUNT;
|
|
|
|
|
if (m_reset_timestamps_and_difficulties_height)
|
|
|
|
|
m_timestamps_and_difficulties_height = 0;
|
|
|
|
|
if (m_timestamps_and_difficulties_height != 0 && ((height - m_timestamps_and_difficulties_height) == 1) && m_timestamps.size() >= difficulty_blocks_count)
|
|
|
|
@ -971,7 +971,7 @@ start:
|
|
|
|
|
uint64_t HEIGHT = m_db->height();
|
|
|
|
|
difficulty_type diff;
|
|
|
|
|
if (version >= 20) {
|
|
|
|
|
diff = next_difficulty_v6(timestamps, difficulties, target);
|
|
|
|
|
diff = next_difficulty_v6(timestamps, difficulties, target, HEIGHT);
|
|
|
|
|
} else if (version <= 17 && version >= 11) {
|
|
|
|
|
diff = next_difficulty_v5(timestamps, difficulties, HEIGHT);
|
|
|
|
|
} else if (version == 10) {
|
|
|
|
@ -1042,7 +1042,7 @@ size_t Blockchain::recalculate_difficulties(boost::optional<uint64_t> start_heig
|
|
|
|
|
std::vector<uint64_t> timestamps;
|
|
|
|
|
std::vector<difficulty_type> difficulties;
|
|
|
|
|
uint8_t version = get_current_hard_fork_version();
|
|
|
|
|
uint64_t difficulty_blocks_count = version == 20 ? DIFFICULTY_BLOCKS_COUNT_V4 : version <= 17 && version >= 11 ? DIFFICULTY_BLOCKS_COUNT_V3 : version <= 10 && version >= 8 ? DIFFICULTY_BLOCKS_COUNT_V2 : DIFFICULTY_BLOCKS_COUNT;
|
|
|
|
|
uint64_t difficulty_blocks_count = version >= 20 ? DIFFICULTY_BLOCKS_COUNT_V4 : version <= 17 && version >= 11 ? DIFFICULTY_BLOCKS_COUNT_V3 : version <= 10 && version >= 8 ? DIFFICULTY_BLOCKS_COUNT_V2 : DIFFICULTY_BLOCKS_COUNT;
|
|
|
|
|
timestamps.reserve(difficulty_blocks_count + 1);
|
|
|
|
|
difficulties.reserve(difficulty_blocks_count + 1);
|
|
|
|
|
if (start_height > 1)
|
|
|
|
@ -1332,7 +1332,7 @@ difficulty_type Blockchain::get_next_difficulty_for_alternative_chain(const std:
|
|
|
|
|
std::vector<uint64_t> timestamps;
|
|
|
|
|
std::vector<difficulty_type> cumulative_difficulties;
|
|
|
|
|
uint8_t version = get_current_hard_fork_version();
|
|
|
|
|
uint64_t difficulty_blocks_count = version == 20 ? DIFFICULTY_BLOCKS_COUNT_V4 : version <= 17 && version >= 11 ? DIFFICULTY_BLOCKS_COUNT_V3 : version <= 10 && version >= 8 ? DIFFICULTY_BLOCKS_COUNT_V2 : DIFFICULTY_BLOCKS_COUNT;
|
|
|
|
|
uint64_t difficulty_blocks_count = version >= 20 ? DIFFICULTY_BLOCKS_COUNT_V4 : version <= 17 && version >= 11 ? DIFFICULTY_BLOCKS_COUNT_V3 : version <= 10 && version >= 8 ? DIFFICULTY_BLOCKS_COUNT_V2 : DIFFICULTY_BLOCKS_COUNT;
|
|
|
|
|
|
|
|
|
|
// if the alt chain isn't long enough to calculate the difficulty target
|
|
|
|
|
// based on its blocks alone, need to get more blocks from the main chain
|
|
|
|
|