OSDN Git Service

add mac function, modify nextBlockTime (#122)
[bytom/vapor.git] / protocol / validation / block.go
index 8b63df0..630a87d 100644 (file)
@@ -26,13 +26,14 @@ var (
 )
 
 func checkBlockTime(b *bc.Block, parent *state.BlockNode) error {
-       if b.Timestamp > uint64(time.Now().UnixNano()/int64(time.Millisecond))+consensus.MaxTimeOffsetMs {
+       now := uint64(time.Now().UnixNano() / 1e6)
+       if b.Timestamp < (parent.Timestamp + consensus.BlockTimeInterval) {
                return errBadTimestamp
        }
-
-       if b.Timestamp <= parent.CalcPastMedianTime() {
+       if b.Timestamp > (now + consensus.MaxTimeOffsetMs) {
                return errBadTimestamp
        }
+
        return nil
 }