Skip to content

Commit

Permalink
txdb: remove consistency checks
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkLTZ committed Aug 26, 2024
1 parent b43243c commit a005954
Showing 1 changed file with 3 additions and 17 deletions.
20 changes: 3 additions & 17 deletions src/txdb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -509,23 +509,9 @@ bool CBlockTreeDB::LoadBlockIndexGuts(std::function<CBlockIndex*(const uint256&)
pindexNew->nSproutValue = diskindex.nSproutValue;
pindexNew->nSaplingValue = diskindex.nSaplingValue;

// Consistency checks
CBlockHeader header;
{
LOCK(cs_main);
try {
header = pindexNew->GetBlockHeader();
} catch (const runtime_error&) {
return error("LoadBlockIndex(): failed to read index entry: diskindex hash = %s",
diskindex.GetBlockHash().ToString());
}
}
if (header.GetHash() != diskindex.GetBlockHash())
return error("LoadBlockIndex(): inconsistent header vs diskindex hash: header hash = %s, diskindex hash = %s",
header.GetHash().ToString(), diskindex.GetBlockHash().ToString());
if (header.GetHash() != pindexNew->GetBlockHash())
return error("LoadBlockIndex(): block header inconsistency detected: on-disk = %s, in-memory = %s",
diskindex.ToString(), pindexNew->ToString());
// Check the block hash against the required difficulty as encoded in the
// nBits field. The probability of this succeeding randomly is low enough
// that it is a useful check to detect logic or disk storage errors.
if (pindexNew->nHeight > 0 && !CheckProofOfWork(pindexNew->GetBlockHash(), pindexNew->nBits, Params().GetConsensus()))
return error("LoadBlockIndex(): CheckProofOfWork failed: %s", pindexNew->ToString());

Expand Down

0 comments on commit a005954

Please sign in to comment.