I want to change the retarget the difficulty from 960 blocks (1 day) to 40 blocks (1 hours) of a coin.
static int64 nTargetSpacing = 90; // 1.5 minute blocks
static int64 nInterval = nTargetTimespan / nTargetSpacing;
static int64 nReTargetHistoryFact = 4; // look at 4 times the retarget interval into block history
{
unsigned int nProofOfWorkLimit = bnProofOfWorkLimit.GetCompact();
// Genesis block
if (pindexLast == NULL)
return nProofOfWorkLimit;
// From block 28000 reassess the difficulty every 40 blocks
// Reduce Retarget factor to 2
if(pindexLast->nHeight >= 28000)
{
nTargetTimespan = 60 * 60; // 1 hours
nTargetSpacing = 1.5 * 60; // 1.5 minutes
nInterval = nTargetTimespan / nTargetSpacing;
nReTargetHistoryFact = 2;
}
else
{
nTargetTimespan = 1 * 24 * 60 * 60; // 1 day
nTargetSpacing = 1.5 * 60; // 1.5 minutes
nInterval = nTargetTimespan / nTargetSpacing;
nReTargetHistoryFact = 4;
}
What do you think? This code will trigger a change in difficulty upon block 28000? Or do I need to do more stuff?
I appreciate any help.
Best wishes,
itos