nicer check using Time objects

This commit is contained in:
vyzo 2020-09-08 10:39:16 +03:00
parent 27fa9969f3
commit 37ec1a978e

View File

@ -6,6 +6,7 @@ import (
"errors"
"fmt"
"sync"
"time"
"golang.org/x/xerrors"
@ -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 {