Move check for block times that are too far ahead of adjusted time, to ContextualCheckBlock.

Signed-off-by: Daira Hopwood <daira@jacaranda.org>
This commit is contained in:
Daira Hopwood 2020-01-31 20:57:06 +00:00
parent b8ca7131c7
commit df6b4639d2
1 changed files with 5 additions and 5 deletions

View File

@ -3692,11 +3692,6 @@ bool CheckBlockHeader(
return state.DoS(50, error("CheckBlockHeader(): proof of work failed"),
REJECT_INVALID, "high-hash");
// Check timestamp
if (block.GetBlockTime() > GetAdjustedTime() + 2 * 60 * 60)
return state.Invalid(error("CheckBlockHeader(): block timestamp too far in the future"),
REJECT_INVALID, "time-too-new");
return true;
}
@ -3786,6 +3781,11 @@ bool ContextualCheckBlockHeader(
return state.Invalid(error("%s: block's timestamp is too early", __func__),
REJECT_INVALID, "time-too-old");
// Check timestamp
if (block.GetBlockTime() > GetAdjustedTime() + 2 * 60 * 60)
return state.Invalid(error("%s: block timestamp too far in the future", __func__),
REJECT_INVALID, "time-too-new");
if (fCheckpointsEnabled)
{
// Don't accept any forks from the main chain prior to last checkpoint