@@ -203,7 +203,7 @@ func (sm *BlockProcessor) processWithParent(block, parent *types.Block) (logs st
203203 txs := block .Transactions ()
204204
205205 // Block validation
206- if err = ValidateHeader (sm .Pow , header , parent , false ); err != nil {
206+ if err = ValidateHeader (sm .Pow , header , parent , false , false ); err != nil {
207207 return
208208 }
209209
@@ -327,7 +327,7 @@ func (sm *BlockProcessor) VerifyUncles(statedb *state.StateDB, block, parent *ty
327327 return UncleError ("uncle[%d](%x)'s parent is not ancestor (%x)" , i , hash [:4 ], uncle .ParentHash [0 :4 ])
328328 }
329329
330- if err := ValidateHeader (sm .Pow , uncle , ancestors [uncle .ParentHash ], true ); err != nil {
330+ if err := ValidateHeader (sm .Pow , uncle , ancestors [uncle .ParentHash ], true , true ); err != nil {
331331 return ValidationError (fmt .Sprintf ("uncle[%d](%x) header invalid: %v" , i , hash [:4 ], err ))
332332 }
333333 }
@@ -358,19 +358,25 @@ func (sm *BlockProcessor) GetLogs(block *types.Block) (logs state.Logs, err erro
358358
359359// See YP section 4.3.4. "Block Header Validity"
360360// Validates a block. Returns an error if the block is invalid.
361- func ValidateHeader (pow pow.PoW , block * types.Header , parent * types.Block , checkPow bool ) error {
361+ func ValidateHeader (pow pow.PoW , block * types.Header , parent * types.Block , checkPow , uncle bool ) error {
362362 if big .NewInt (int64 (len (block .Extra ))).Cmp (params .MaximumExtraDataSize ) == 1 {
363363 return fmt .Errorf ("Block extra data too long (%d)" , len (block .Extra ))
364364 }
365365
366- if block .Time > uint64 (time .Now ().Unix ()) {
367- return BlockFutureErr
366+ if uncle {
367+ if block .Time .Cmp (common .MaxBig ) == 1 {
368+ return BlockTSTooBigErr
369+ }
370+ } else {
371+ if block .Time .Cmp (big .NewInt (time .Now ().Unix ())) == 1 {
372+ return BlockFutureErr
373+ }
368374 }
369- if block .Time <= parent .Time () {
375+ if block .Time . Cmp ( parent .Time ()) != 1 {
370376 return BlockEqualTSErr
371377 }
372378
373- expd := CalcDifficulty (block .Time , parent .Time (), parent .Number (), parent .Difficulty ())
379+ expd := CalcDifficulty (block .Time . Uint64 () , parent .Time (). Uint64 (), parent .Number (), parent .Difficulty ())
374380 if expd .Cmp (block .Difficulty ) != 0 {
375381 return fmt .Errorf ("Difficulty check failed for block %v, %v" , block .Difficulty , expd )
376382 }
0 commit comments