Changeset View
Changeset View
Standalone View
Standalone View
src/validation.cpp
Show First 20 Lines • Show All 3,503 Lines • ▼ Show 20 Lines | |||||
* By "context", we mean only the previous block headers, but not the UTXO | * By "context", we mean only the previous block headers, but not the UTXO | ||||
* set; UTXO-related validity checks are done in ConnectBlock(). | * set; UTXO-related validity checks are done in ConnectBlock(). | ||||
* NOTE: This function is not currently invoked by ConnectBlock(), so we | * NOTE: This function is not currently invoked by ConnectBlock(), so we | ||||
* should consider upgrade issues if we change which consensus rules are | * should consider upgrade issues if we change which consensus rules are | ||||
* enforced in this function (eg by adding a new consensus rule). See comment | * enforced in this function (eg by adding a new consensus rule). See comment | ||||
* in ConnectBlock(). | * in ConnectBlock(). | ||||
* Note that -reindex-chainstate skips the validation that happens here! | * Note that -reindex-chainstate skips the validation that happens here! | ||||
*/ | */ | ||||
static bool ContextualCheckBlockHeader(const CChainParams ¶ms, | static bool | ||||
const CBlockHeader &block, | ContextualCheckBlockHeader(const CChainParams ¶ms, | ||||
CValidationState &state, | const CBlockHeader &block, CValidationState &state, | ||||
const CBlockIndex *pindexPrev, | const CBlockIndex *pindexPrev, int64_t nAdjustedTime) | ||||
int64_t nAdjustedTime) { | EXCLUSIVE_LOCKS_REQUIRED(cs_main) { | ||||
assert(pindexPrev != nullptr); | assert(pindexPrev != nullptr); | ||||
const int nHeight = pindexPrev->nHeight + 1; | const int nHeight = pindexPrev->nHeight + 1; | ||||
// Check proof of work | // Check proof of work | ||||
const Consensus::Params &consensusParams = params.GetConsensus(); | const Consensus::Params &consensusParams = params.GetConsensus(); | ||||
if (block.nBits != | if (block.nBits != | ||||
GetNextWorkRequired(pindexPrev, &block, consensusParams)) { | GetNextWorkRequired(pindexPrev, &block, consensusParams)) { | ||||
LogPrintf("bad bits after height: %d\n", pindexPrev->nHeight); | LogPrintf("bad bits after height: %d\n", pindexPrev->nHeight); | ||||
▲ Show 20 Lines • Show All 2,121 Lines • Show Last 20 Lines |