CLI to get network version

This commit is contained in:
Aayush Rajasekaran 2020-11-19 02:24:32 -05:00
parent dc3d17c9ea
commit 3737a8f3cc

View File

@ -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
},
}