Skip to content

Commit

Permalink
Fix GetNextWorkRequired
Browse files Browse the repository at this point in the history
  • Loading branch information
bitbandi committed Nov 1, 2015
1 parent 85f7437 commit a354c4d
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1337,8 +1337,11 @@ static const int64 nInterval = 2; // retargets every 2 blocks
static const int64 nAveragingInterval = 10; // 10 blocks
static const int64 nAveragingTargetTimespan = nAveragingInterval * nTargetSpacing; // 15 minutes

static const int64 nMaxAdjustDown = 5; // 5% adjustment down
static const int64 nMaxAdjustUp = 5; // 5% adjustment up
static int64 nMaxAdjustDown = 100; // 100% adjustment down
static int64 nMaxAdjustUp = 10; // 10% adjustment up

static const int64 nMaxAdjustDown2 = 5; // 5% adjustment down
static const int64 nMaxAdjustUp2 = 5; // 5% adjustment up

static const int64 nTargetTimespanAdjDown = nTargetTimespan * (100 + nMaxAdjustDown) / 100;

Expand Down Expand Up @@ -1372,8 +1375,6 @@ unsigned int ComputeMinWork(unsigned int nBase, int64 nTime)
return Params().ProofOfWorkLimit(ALGO_SHA256D).GetCompact();
}

static const int64 nMinActualTimespan = nAveragingTargetTimespan * (100 - nMaxAdjustUp) / 100;
static const int64 nMaxActualTimespan = nAveragingTargetTimespan * (100 + nMaxAdjustDown) / 100;

unsigned int static GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHeader *pblock, int algo)
{
Expand Down Expand Up @@ -1401,6 +1402,15 @@ unsigned int static GetNextWorkRequired(const CBlockIndex* pindexLast, const CBl
}
}

if(pindexLast->nHeight+1 >= 955000){
nMaxAdjustDown = nMaxAdjustDown2;
nMaxAdjustUp = nMaxAdjustUp2;
}

int64 nMinActualTimespan = nAveragingTargetTimespan * (100 - nMaxAdjustUp) / 100;
int64 nMaxActualTimespan = nAveragingTargetTimespan * (100 + nMaxAdjustDown) / 100;


// find previous block with same algo
const CBlockIndex* pindexPrev = GetLastBlockIndexForAlgo(pindexLast, algo);

Expand Down

0 comments on commit a354c4d

Please sign in to comment.