diff --git a/node/modules/services.go b/node/modules/services.go index 62f8063e9..e7a2fddf6 100644 --- a/node/modules/services.go +++ b/node/modules/services.go @@ -85,13 +85,13 @@ func RunChainExchange(h host.Host, svc exchange.Server) { } func waitForSync(stmgr *stmgr.StateManager, epochs int, subscribe func()) { - nearsync := uint64(epochs) * uint64(build.BlockDelaySecs) //nolint + nearsync := time.Duration(epochs*int(build.BlockDelaySecs)) * time.Second // early check, are we synced at start up? ts := stmgr.ChainStore().GetHeaviestTipSet() timestamp := ts.MinTimestamp() - now := uint64(build.Clock.Now().Unix()) - if timestamp > now-nearsync { + timestampTime := time.Unix(int64(timestamp), 0) + if build.Clock.Since(timestampTime) < nearsync { subscribe() return } @@ -110,8 +110,8 @@ func waitForSync(stmgr *stmgr.StateManager, epochs int, subscribe func()) { } } - now := uint64(build.Clock.Now().Unix()) - if latest > now-nearsync { + latestTime := time.Unix(int64(latest), 0) + if build.Clock.Since(latestTime) < nearsync { subscribe() return store.ErrNotifeeDone }