From 885c6c94d38167f395268c96c747ea6810fec87b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Fri, 30 Oct 2020 19:39:31 +0100 Subject: [PATCH] Add sync status to miner info command --- cmd/lotus-storage-miner/info.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/cmd/lotus-storage-miner/info.go b/cmd/lotus-storage-miner/info.go index 213d62e6e..b16b4dde8 100644 --- a/cmd/lotus-storage-miner/info.go +++ b/cmd/lotus-storage-miner/info.go @@ -59,6 +59,24 @@ func infoCmdAct(cctx *cli.Context) error { ctx := lcli.ReqContext(cctx) + fmt.Print("Full node: ") + + head, err := api.ChainHead(ctx) + if err != nil { + return err + } + + switch { + case time.Now().Unix()-int64(head.MinTimestamp()) < int64(build.BlockDelaySecs*3/2): // within 1.5 epochs + fmt.Printf("[%s]", color.GreenString("sync ok")) + case time.Now().Unix()-int64(head.MinTimestamp()) < int64(build.BlockDelaySecs*5): // within 5 epochs + fmt.Printf("[%s]", color.YellowString("sync slow (%s behind)", time.Now().Sub(time.Unix(int64(head.MinTimestamp()), 0)).Truncate(time.Second))) + default: + fmt.Printf("[%s]", color.RedString("sync behind! (%s behind)", time.Now().Sub(time.Unix(int64(head.MinTimestamp()), 0)).Truncate(time.Second))) + } + + fmt.Println() + maddr, err := getActorAddress(ctx, nodeApi, cctx.String("actor")) if err != nil { return err