Skip to content

Commit

Permalink
Fix bug on AcceptBlock when pindex is null
Browse files Browse the repository at this point in the history
Signed-off-by: cevap <dev@i2pmail.org>
  • Loading branch information
random-zebra authored and cevap committed Feb 7, 2019
1 parent 3175d71 commit f7a3ea9
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4465,7 +4465,7 @@ bool ContextualCheckZerocoinStake(int nHeight, CStakeInput* stake)
return error("%s: failed to get index associated with xION stake checksum", __func__);

if (chainActive.Height() - pindexFrom->nHeight < Params().Zerocoin_RequiredStakeDepth())
return error("%s: xION stake does not have required confirmation depth", __func__);
return error("%s: xION stake does not have required confirmation depth. Current height %d, stakeInput height %d.", __func__, chainActive.Height(), pindexFrom->nHeight);

//The checksum needs to be the exact checksum from 200 blocks ago
uint256 nCheckpoint200 = chainActive[nHeight - Params().Zerocoin_RequiredStakeDepth()]->nAccumulatorCheckpoint;
Expand Down Expand Up @@ -4854,7 +4854,7 @@ bool ProcessNewBlock(CValidationState& state, CNode* pfrom, CBlock* pblock, CDis
CheckBlockIndex ();
if (!ret) {
// Check spamming
if(pfrom && GetBoolArg("-blockspamfilter", DEFAULT_BLOCK_SPAM_FILTER)) {
if(pindex && pfrom && GetBoolArg("-blockspamfilter", DEFAULT_BLOCK_SPAM_FILTER)) {
CNodeState *nodestate = State(pfrom->GetId());
if(nodestate != nullptr) {
nodestate->nodeBlocks.onBlockReceived(pindex->nHeight);
Expand All @@ -4873,6 +4873,9 @@ bool ProcessNewBlock(CValidationState& state, CNode* pfrom, CBlock* pblock, CDis
}
return error("%s : AcceptBlock FAILED", __func__);
}
else {
LogPrintf("%s : AccpetBlock PASSED!", __func__);
}
}

if (!ActivateBestChain(state, pblock, checked))
Expand Down

0 comments on commit f7a3ea9

Please sign in to comment.