Skip to content

Commit

Permalink
nicer check using Time objects
Browse files Browse the repository at this point in the history
  • Loading branch information
vyzo committed Sep 8, 2020
1 parent bd9ef17 commit 1c0c4f8
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions chain/sub/incoming.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"errors"
"fmt"
"sync"
"time"

"golang.org/x/xerrors"

Expand Down Expand Up @@ -368,9 +369,8 @@ func (bv *BlockValidator) decodeAndCheckBlock(msg *pubsub.Message) (*types.Block
func (bv *BlockValidator) isChainNearSynced() bool {
ts := bv.chain.GetHeaviestTipSet()
timestamp := ts.MinTimestamp()
now := build.Clock.Now().Unix()
cutoff := uint64(now) - uint64(6*3600) // 6 hours
return timestamp > cutoff
timestampTime := time.Unix(int64(timestamp), 0)
return build.Clock.Since(timestampTime) < 6*time.Hour
}

func (bv *BlockValidator) validateMsgMeta(ctx context.Context, msg *types.BlockMsg) error {
Expand Down

0 comments on commit 1c0c4f8

Please sign in to comment.