From 3737a8f3cc0daa0d9c14d86175e89672484f42f8 Mon Sep 17 00:00:00 2001 From: Aayush Rajasekaran Date: Thu, 19 Nov 2020 02:24:32 -0500 Subject: [PATCH 1/2] CLI to get network version --- cli/state.go | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/cli/state.go b/cli/state.go index 31537cc89af..7db7fa719d2 100644 --- a/cli/state.go +++ b/cli/state.go @@ -72,6 +72,7 @@ var stateCmd = &cli.Command{ stateMinerInfo, stateMarketCmd, stateExecTraceCmd, + stateNtwkVersionCmd, }, } @@ -1831,3 +1832,32 @@ var stateMarketBalanceCmd = &cli.Command{ return nil }, } + +var stateNtwkVersionCmd = &cli.Command{ + Name: "network-version", + Usage: "Returns the network version", + Action: func(cctx *cli.Context) error { + if cctx.Args().Present() { + return ShowHelp(cctx, fmt.Errorf("doesn't expect any arguments")) + } + + api, closer, err := GetFullNodeAPI(cctx) + if err != nil { + return err + } + defer closer() + + ctx := ReqContext(cctx) + + ts, err := LoadTipSet(ctx, cctx, api) + if err != nil { + return err + } + + nv, err := api.StateNetworkVersion(ctx, ts.Key()) + + fmt.Printf("Network Version: %d\n", nv) + + return nil + }, +} From 9d2208e0e894035098dd28c71edb376ec68130f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Thu, 19 Nov 2020 17:08:14 +0100 Subject: [PATCH 2/2] fix lint --- cli/state.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cli/state.go b/cli/state.go index 7db7fa719d2..65f8f568653 100644 --- a/cli/state.go +++ b/cli/state.go @@ -1855,6 +1855,9 @@ var stateNtwkVersionCmd = &cli.Command{ } nv, err := api.StateNetworkVersion(ctx, ts.Key()) + if err != nil { + return err + } fmt.Printf("Network Version: %d\n", nv)