cli: Support --tipset in chain get /pstate

This commit is contained in:
Łukasz Magiera 2020-04-21 17:07:12 +02:00
parent c2806fe189
commit fcc51f3591

View File

@ -422,6 +422,10 @@ var chainGetCmd = &cli.Command{
Name: "verbose",
Value: false,
},
&cli.StringFlag{
Name: "tipset",
Usage: "specify tipset for /pstate (pass comma separated array of cids)",
},
},
Description: `Get ipld node under a specified path:
@ -462,11 +466,19 @@ var chainGetCmd = &cli.Command{
p := path.Clean(cctx.Args().First())
if strings.HasPrefix(p, "/pstate") {
p = p[len("/pstate"):]
head, err := api.ChainHead(ctx)
ts, err := LoadTipSet(ctx, cctx, api)
if err != nil {
return err
}
p = "/ipfs/" + head.ParentState().String() + p
if ts == nil {
ts, err = api.ChainHead(ctx)
if err != nil {
return err
}
}
p = "/ipfs/" + ts.ParentState().String() + p
if cctx.Bool("verbose") {
fmt.Println(p)
}