Skip to content

Commit 49a9513

Browse files
committed
softwareexpiry: Defer rejecting blocks an extra day
1 parent 1802dcc commit 49a9513

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/validation.cpp

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3911,10 +3911,6 @@ static bool CheckBlockHeader(const CBlockHeader& block, BlockValidationState& st
39113911
if (fCheckPOW && !CheckProofOfWork(block.GetHash(), block.nBits, consensusParams))
39123912
return state.Invalid(BlockValidationResult::BLOCK_INVALID_HEADER, "high-hash", "proof of work failed");
39133913

3914-
if (IsThisSoftwareExpired(block.nTime)) {
3915-
return state.Invalid(BlockValidationResult::BLOCK_TIME_FUTURE, "node-expired", "node software has expired");
3916-
}
3917-
39183914
return true;
39193915
}
39203916

@@ -4211,6 +4207,19 @@ static bool ContextualCheckBlockHeader(const CBlockHeader& block, BlockValidatio
42114207
strprintf("rejected nVersion=0x%08x block", block.nVersion));
42124208
}
42134209

4210+
if (IsThisSoftwareExpired(block.nTime)) {
4211+
// Wait an extra day before we start rejecting blocks
4212+
CBlockIndex const *blockindex_old = pindexPrev;
4213+
for (int i = 0; i < 144; ++i) {
4214+
assert(blockindex_old);
4215+
blockindex_old = blockindex_old->pprev;
4216+
}
4217+
assert(blockindex_old);
4218+
if (IsThisSoftwareExpired(blockindex_old->GetMedianTimePast())) {
4219+
return state.Invalid(BlockValidationResult::BLOCK_TIME_FUTURE, "node-expired", "node software has expired");
4220+
}
4221+
}
4222+
42144223
return true;
42154224
}
42164225

0 commit comments

Comments
 (0)