MCPcopy Create free account
hub / github.com/LUX-Core/lux / CheckBlockHeader

Function CheckBlockHeader

src/main.cpp:4276–4304  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4274}
4275
4276bool CheckBlockHeader(const CBlockHeader& block, CValidationState& state, const Consensus::Params& consensusParams, bool fCheckPOW) {
4277 // Get prev block index
4278
4279 int nBlockHeight = 0;
4280 const CChainParams& chainparams = Params();
4281 CBlockIndex* pindexPrev = LookupBlockIndex(block.hashPrevBlock);
4282 if (pindexPrev) {
4283 nBlockHeight = pindexPrev->nHeight + 1;
4284 bool isScVersioned = block.nVersion & (1 << consensusParams.vDeployments[Consensus::SMART_CONTRACTS_HARDFORK].bit);
4285 if (nBlockHeight >= chainparams.FirstSCBlock() && !isScVersioned) {
4286 return error("invalid block version after smart-contract hardfork");
4287 }
4288 if (nBlockHeight >= chainparams.FirstSCBlock() && (block.hashStateRoot == uint256(0) || block.hashUTXORoot == uint256(0))) {
4289 return error("utxo root or state root uninitialized after smart-contract hardfork");
4290 }
4291 }
4292
4293
4294 if (chainActive.Height()<nBlockHeight-1 && fReindex) {
4295 chainActive.SetTip(LookupBlockIndex(block.hashPrevBlock));}
4296
4297
4298 if (fCheckPOW && !CheckProofOfWork(block.GetHash(nBlockHeight,2), block.nBits, consensusParams))
4299 return state.DoS(50, false, REJECT_INVALID, "high-hash", false, "proof of work failed");
4300
4301 if (fReindex )
4302 chainActive.SetTip(LookupBlockIndex(pcoinsTip->GetBestBlock()));
4303 return true;
4304}
4305
4306bool CheckForMasternodePayment(const CTransaction& tx, const CBlockHeader& header) {
4307 // Regular transactions don't have to share anything with masternodes

Callers 2

CheckBlockFunction · 0.85
AcceptBlockHeaderFunction · 0.85

Calls 11

LookupBlockIndexFunction · 0.85
errorFunction · 0.85
CheckProofOfWorkFunction · 0.85
FirstSCBlockMethod · 0.80
HeightMethod · 0.80
SetTipMethod · 0.80
DoSMethod · 0.80
ParamsClass · 0.70
uint256Class · 0.70
GetHashMethod · 0.45
GetBestBlockMethod · 0.45

Tested by

no test coverage detected