cli: Support --tipset in chain get /pstate
This commit is contained in:
parent
c2806fe189
commit
fcc51f3591
16
cli/chain.go
16
cli/chain.go
@ -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)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user