Skip to content

Commit

Permalink
Expose signed blocks in validation.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
instagibbs committed Dec 19, 2018
1 parent cd4e553 commit 0e47322
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/txdb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ bool CBlockTreeDB::LoadBlockIndexGuts(const Consensus::Params& consensusParams,
pindexNew->nTx = diskindex.nTx;

const uint256 block_hash = pindexNew->GetBlockHash();
if (!CheckProofOfWork(block_hash, pindexNew->nBits, consensusParams) &&
if (!CheckProof(pindexNew->GetBlockHeader(), consensusParams) &&
block_hash != consensusParams.hashGenesisBlock) {
return error("%s: CheckProofOfWork: %s, %s", __func__, block_hash.ToString(), pindexNew->ToString());
}
Expand Down
10 changes: 5 additions & 5 deletions src/validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1097,7 +1097,7 @@ bool ReadBlockFromDisk(CBlock& block, const CDiskBlockPos& pos, const Consensus:

// Check the header
const uint256 block_hash = block.GetHash();
if (!CheckProofOfWork(block_hash, block.nBits, consensusParams) &&
if (!CheckProof(block, consensusParams) &&
block_hash != consensusParams.hashGenesisBlock) {
return error("ReadBlockFromDisk: Errors in block header at %s", pos.ToString());
}
Expand Down Expand Up @@ -3106,8 +3106,8 @@ static bool CheckBlockHeader(const CBlockHeader& block, CValidationState& state,
{
// Check proof of work matches claimed amount
if (fCheckPOW && block.GetHash() != consensusParams.hashGenesisBlock
&& !CheckProofOfWork(block.GetHash(), block.nBits, consensusParams)) {
return state.DoS(50, false, REJECT_INVALID, "high-hash", false, "proof of work failed");
&& !CheckProof(block, consensusParams)) {
return state.DoS(50, false, REJECT_INVALID, g_signed_blocks ? "block-proof-invalid" : "high-hash", false, "proof of work failed");
}
return true;
}
Expand Down Expand Up @@ -3257,9 +3257,9 @@ static bool ContextualCheckBlockHeader(const CBlockHeader& block, CValidationSta
assert(pindexPrev != nullptr);
const int nHeight = pindexPrev->nHeight + 1;

// Check proof of work
// Check proof of work if necessary
const Consensus::Params& consensusParams = params.GetConsensus();
if (block.nBits != GetNextWorkRequired(pindexPrev, &block, consensusParams))
if (!CheckChallenge(block, *pindexPrev, consensusParams))
return state.DoS(100, false, REJECT_INVALID, "bad-diffbits", false, "incorrect proof of work");

// Check against checkpoints
Expand Down

0 comments on commit 0e47322

Please sign in to comment.