mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-18 13:17:55 +02:00
block header commits to height
This commit is contained in:
parent
88802e76f1
commit
372e20d8b1
6 changed files with 22 additions and 1 deletions
|
|
@ -2037,6 +2037,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
|
|||
if (block.GetHash() == chainparams.GetConsensus().hashGenesisBlock) {
|
||||
if (!fJustCheck) {
|
||||
assert(block.vtx.size() == 1);
|
||||
assert(block.nHeight == 0);
|
||||
|
||||
std::vector<std::pair<uint256, CDiskTxPos> > vPos;
|
||||
std::multimap<uint256, std::pair<COutPoint, CAmount> > mLocksCreated;
|
||||
|
|
@ -3347,6 +3348,11 @@ bool ContextualCheckBlockHeader(const CBlockHeader& block, CValidationState& sta
|
|||
if (block.GetBlockTime() <= pindexPrev->GetMedianTimePast())
|
||||
return state.Invalid(false, REJECT_INVALID, "time-too-old", "block's timestamp is too early");
|
||||
|
||||
// Check height in header against prev
|
||||
if ((uint32_t)pindexPrev->nHeight + 1 != block.nHeight)
|
||||
return state.Invalid(error("%s: block height in header is incorrect", __func__),
|
||||
REJECT_INVALID, "bad-header-height");
|
||||
|
||||
// Check timestamp
|
||||
if (block.GetBlockTime() > nAdjustedTime + 2 * 60 * 60)
|
||||
return state.Invalid(false, REJECT_INVALID, "time-too-new", "block timestamp too far in the future");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue