Skip to content

Commit

Permalink
Merge pull request filecoin-project#4914 from filecoin-project/asr/ve…
Browse files Browse the repository at this point in the history
…rsion-cli

CLI to get network version
  • Loading branch information
magik6k authored and bibibong committed Jan 7, 2021
1 parent 8948878 commit 88b1caa
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions cli/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ var stateCmd = &cli.Command{
stateExecTraceCmd,
stateVoteFundCmd,
stateKnowFundInfoCmd,
stateNtwkVersionCmd,
},
}

Expand Down Expand Up @@ -2071,3 +2072,35 @@ var stateKnowFundInfoCmd = &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())
if err != nil {
return err
}

fmt.Printf("Network Version: %d\n", nv)

return nil
},
}

0 comments on commit 88b1caa

Please sign in to comment.