Skip to content

Commit

Permalink
Fix N factor increase interval comment (#37)
Browse files Browse the repository at this point in the history
  • Loading branch information
ryan-shaw authored and retosen committed Jan 31, 2018
1 parent 8e182bf commit 802cc6f
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions src/primitives/block.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,24 @@ uint256 CBlockHeader::GetPoWHash() const
uint256 thash;
unsigned char Nfactor;
const unsigned char minNfactor = 10;
const unsigned char maxNfactor = 20;
const unsigned char maxNfactor = 20;

// epoch times of chain start and current block time
int64_t nChainStartTime = 1515925970;
// epoch times of chain start and current block time
int64_t nChainStartTime = 1515925970;

// n-factor will change every this interval is hit
int64_t nChangeInterval = 36288000; //200 days
// n-factor will change every this interval is hit
int64_t nChangeInterval = 36288000; // 420 days

if (GetBlockTime() <= nChainStartTime) {
Nfactor = minNfactor;
} else {
int64_t s = GetBlockTime() - nChainStartTime;
int n = s/nChangeInterval + 10;

if (n < 0) n = 0;
unsigned char tempN = (unsigned char) n;
Nfactor = std::min(std::max(tempN, minNfactor), maxNfactor);
}
Nfactor = minNfactor;
} else {
int64_t s = GetBlockTime() - nChainStartTime;
int n = s/nChangeInterval + 10;

if (n < 0) n = 0;
unsigned char tempN = (unsigned char) n;
Nfactor = std::min(std::max(tempN, minNfactor), maxNfactor);
}
scrypt_N_1_1_256(BEGIN(nVersion), BEGIN(thash), Nfactor);
return thash;
}
Expand Down

0 comments on commit 802cc6f

Please sign in to comment.