fix nearsync check

This commit is contained in:
vyzo 2020-09-08 10:21:20 +03:00
parent 3306bdec29
commit c6cd699f0d

View File

@ -85,12 +85,12 @@ func RunChainExchange(h host.Host, svc exchange.Server) {
} }
func waitForSync(stmgr *stmgr.StateManager, epochs int, subscribe func()) { func waitForSync(stmgr *stmgr.StateManager, epochs int, subscribe func()) {
nearsync := uint64(epochs) * uint64(build.BlockDelaySecs) * uint64(time.Second) //nolint nearsync := uint64(epochs) * uint64(build.BlockDelaySecs) //nolint
// early check, are we synced at start up? // early check, are we synced at start up?
ts := stmgr.ChainStore().GetHeaviestTipSet() ts := stmgr.ChainStore().GetHeaviestTipSet()
timestamp := ts.MinTimestamp() timestamp := ts.MinTimestamp()
now := uint64(build.Clock.Now().UnixNano()) now := uint64(build.Clock.Now().Unix())
if timestamp > now-nearsync { if timestamp > now-nearsync {
subscribe() subscribe()
return return
@ -110,7 +110,7 @@ func waitForSync(stmgr *stmgr.StateManager, epochs int, subscribe func()) {
} }
} }
now := uint64(build.Clock.Now().UnixNano()) now := uint64(build.Clock.Now().Unix())
if latest > now-nearsync { if latest > now-nearsync {
subscribe() subscribe()
return store.ErrNotifeeDone return store.ErrNotifeeDone