OSDN Git Service

update
authorChengcheng Zhang <943420582@qq.com>
Wed, 5 Jun 2019 07:41:09 +0000 (15:41 +0800)
committerChengcheng Zhang <943420582@qq.com>
Wed, 5 Jun 2019 07:41:09 +0000 (15:41 +0800)
protocol/validation/block.go

index c073a01..ef63947 100644 (file)
@@ -27,6 +27,12 @@ var (
 
 func checkBlockTime(b *bc.Block, parent *state.BlockNode) error {
        now := uint64(time.Now().UnixNano() / 1e6)
+       if parent.Timestamp >= b.Timestamp {
+               return errBadTimestamp
+       }
+       if b.Timestamp%consensus.BlockTimeInterval != 0 {
+               return errBadTimestamp
+       }
        if b.Timestamp > (now + consensus.MaxTimeOffsetMs) {
                return errBadTimestamp
        }