diff --git a/consensus/validation.go b/consensus/validation.go index 8519e963..f757721a 100644 --- a/consensus/validation.go +++ b/consensus/validation.go @@ -11,9 +11,16 @@ import ( "go.sia.tech/core/types" ) +var ( + // ErrFutureBlock is returned when a block's timestamp is too far in the future. + ErrFutureBlock = errors.New("block's timestamp is too far in the future") +) + func validateHeader(s State, parentID types.BlockID, timestamp time.Time, nonce uint64, id types.BlockID) error { if parentID != s.Index.ID { return errors.New("wrong parent ID") + } else if timestamp.After(s.MaxFutureTimestamp(time.Now())) { + return ErrFutureBlock } else if timestamp.Before(s.medianTimestamp()) { return errors.New("timestamp is too far in the past") } else if nonce%s.NonceFactor() != 0 {