Skip to content

Commit

Permalink
Reset network difficulty to 2.0 MHz when hardfork v3 comes to effect
Browse files Browse the repository at this point in the history
  • Loading branch information
sumoprojects committed Apr 2, 2018
1 parent 661828c commit 613ed5b
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/cryptonote_core/blockchain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ DISABLE_VS_WARNINGS(4267)

// used to overestimate the block reward when estimating a per kB to use
#define BLOCK_REWARD_OVERESTIMATE ((uint64_t)(16000000000))
#define MAINNET_HARDFORK_V3_HEIGHT ((uint64_t)(116520))

static const struct {
uint8_t version;
Expand All @@ -83,7 +84,7 @@ static const struct {
} mainnet_hard_forks[] = {
{ 1, 1, 0, 1482806500 },
{ 2, 21300, 0, 1497657600 },
{ 3, 116520, 0, 1522800000 }
{ 3, MAINNET_HARDFORK_V3_HEIGHT, 0, 1522800000 }
};
static const uint64_t mainnet_hard_fork_version_1_till = (uint64_t)-1;

Expand Down Expand Up @@ -676,6 +677,11 @@ difficulty_type Blockchain::get_difficulty_for_next_block()
std::vector<uint64_t> timestamps;
std::vector<difficulty_type> difficulties;
auto height = m_db->height();
// Reset network hashrate to 2.0 MHz when hardfork v3 comes
if (!m_testnet && (uint64_t)height >= MAINNET_HARDFORK_V3_HEIGHT && (uint64_t)height <= MAINNET_HARDFORK_V3_HEIGHT + (uint64_t)DIFFICULTY_BLOCKS_COUNT_V2){
return (difficulty_type) 480000000;
}

size_t difficult_block_count = get_current_hard_fork_version() < 2 ? DIFFICULTY_BLOCKS_COUNT : DIFFICULTY_BLOCKS_COUNT_V2;

// ND: Speedup
Expand Down

0 comments on commit 613ed5b

Please sign in to comment.