Skip to content

Commit

Permalink
IBD: do not check PoW (Yespower) during Downloading headers
Browse files Browse the repository at this point in the history
This means PoW check during IBD is not actually skipped, but still its checking in another places. What we skipped is only when Downloading headers, but not else. This makes IBD much faster.
  • Loading branch information
decryp2kanon committed May 6, 2020
1 parent 43bb57c commit 275088d
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3047,6 +3047,13 @@ static bool CheckBlockHeader(const CBlockHeader& block, CValidationState& state,
if (fCheckPOW && !CheckProofOfWork(block.GetPoWHash_cached(), block.nBits, consensusParams))
return state.DoS(50, false, REJECT_INVALID, "high-hash", false, "proof of work failed");

// FIXME.SUGAR // PoW check: SKIPPED during IBD
// You can see this log when IBD.
// This means PoW check during IBD is not actually skipped, but still its checking in another places.
// What we skipped is only when Downloading headers, but not else. This makes IBD much faster.
if (IsInitialBlockDownload())
printf("%s IBD=%d CBH=%s\n", DateTimeStrFormat("%Y-%m-%d %H:%M:%S", GetTime()).c_str(), IsInitialBlockDownload(), block.GetHash().ToString().c_str());

return true;
}

Expand Down Expand Up @@ -3334,7 +3341,9 @@ bool CChainState::AcceptBlockHeader(const CBlockHeader& block, CValidationState&
return true;
}

if (!CheckBlockHeader(block, state, chainparams.GetConsensus()))
// FIXME.SUGAR // PoW check: SKIPPED during IBD
// IBD: Do not PoW check during "Downloading Headers" for performance reason
if (!IsInitialBlockDownload() && !CheckBlockHeader(block, state, chainparams.GetConsensus()))
return error("%s: Consensus::CheckBlockHeader: %s, %s", __func__, hash.ToString(), FormatStateMessage(state));

// Get prev block index
Expand Down

0 comments on commit 275088d

Please sign in to comment.