Skip to content

Commit

Permalink
Fix segfault on DGW
Browse files Browse the repository at this point in the history
  • Loading branch information
ScriptProdigy committed Jan 14, 2019
1 parent 450b4ce commit 7581002
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/pow.cpp
Expand Up @@ -18,9 +18,8 @@ unsigned int static DarkGravityWave(const CBlockIndex* pindexLast, const CBlockH
int64_t nPastBlocks = 24;

// make sure we have at least (nPastBlocks + 1) blocks, otherwise just return powLimit
if (!pblock || !pindexLast || pindexLast->nHeight < nPastBlocks) {
if (pblock == nullptr || pindexLast == nullptr || pindexLast->nHeight < nPastBlocks)
return bnPowLimit.GetCompact();
}

if (params.fPowAllowMinDifficultyBlocks) {
// recent block is more than 2 hours old
Expand Down Expand Up @@ -56,6 +55,9 @@ unsigned int static DarkGravityWave(const CBlockIndex* pindexLast, const CBlockH

arith_uint256 bnNew(bnPastTargetAvg);

if(pindex == nullptr || pindexLast == nullptr)
return bnPowLimit.GetCompact();

int64_t nActualTimespan = pindexLast->GetBlockTime() - pindex->GetBlockTime();
// NOTE: is this accurate? nActualTimespan counts it for (nPastBlocks - 1) blocks only...
int64_t nTargetTimespan = nPastBlocks * params.nPowTargetSpacing * NUM_ALGOS;
Expand Down

0 comments on commit 7581002

Please sign in to comment.