Skip to content

Commit

Permalink
Merge pull request #4669 from filecoin-project/feat/minerinfo-sync
Browse files Browse the repository at this point in the history
Add sync status to miner info command
  • Loading branch information
magik6k authored Oct 30, 2020
2 parents 696a686 + 885c6c9 commit a7ff906
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions cmd/lotus-storage-miner/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a7ff906

Please sign in to comment.