Merge pull request #4038 from filecoin-project/feat/state-compute-json

add json output to state compute
This commit is contained in:
Łukasz Magiera 2020-09-26 10:20:30 +02:00 committed by GitHub
commit e15065b142
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -821,6 +821,10 @@ var stateComputeStateCmd = &cli.Command{
Name: "html",
Usage: "generate html report",
},
&cli.BoolFlag{
Name: "json",
Usage: "generate json output",
},
},
Action: func(cctx *cli.Context) error {
api, closer, err := GetFullNodeAPI(cctx)
@ -865,6 +869,15 @@ var stateComputeStateCmd = &cli.Command{
return err
}
if cctx.Bool("json") {
out, err := json.Marshal(stout)
if err != nil {
return err
}
fmt.Println(string(out))
return nil
}
if cctx.Bool("html") {
st, err := state.LoadStateTree(cbor.NewCborStore(apibstore.NewAPIBlockstore(api)), stout.Root)
if err != nil {