chain get: /pstate prefix
This commit is contained in:
parent
ea135991e3
commit
4ae1238c0c
24
cli/chain.go
24
cli/chain.go
@ -7,6 +7,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
"path"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
@ -415,11 +416,19 @@ var chainGetCmd = &cli.Command{
|
|||||||
Name: "as-type",
|
Name: "as-type",
|
||||||
Usage: "specify type to interpret output as",
|
Usage: "specify type to interpret output as",
|
||||||
},
|
},
|
||||||
|
&cli.BoolFlag{
|
||||||
|
Name: "verbose",
|
||||||
|
Value: false,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
Description: `Get ipld node under a specified path:
|
Description: `Get ipld node under a specified path:
|
||||||
|
|
||||||
lotus chain get /ipfs/[cid]/some/path
|
lotus chain get /ipfs/[cid]/some/path
|
||||||
|
|
||||||
|
Path prefixes:
|
||||||
|
- /ipfs/[cid], /ipld/[cid] - traverse IPLD path
|
||||||
|
- /pstate - traverse from head.ParentStateRoot
|
||||||
|
|
||||||
Note:
|
Note:
|
||||||
You can use special path elements to traverse through some data structures:
|
You can use special path elements to traverse through some data structures:
|
||||||
- /ipfs/[cid]/@H:elem - get 'elem' from hamt
|
- /ipfs/[cid]/@H:elem - get 'elem' from hamt
|
||||||
@ -434,7 +443,20 @@ var chainGetCmd = &cli.Command{
|
|||||||
defer closer()
|
defer closer()
|
||||||
ctx := ReqContext(cctx)
|
ctx := ReqContext(cctx)
|
||||||
|
|
||||||
obj, err := api.ChainGetNode(ctx, cctx.Args().First())
|
p := path.Clean(cctx.Args().First())
|
||||||
|
if strings.HasPrefix(p, "/pstate") {
|
||||||
|
p = p[len("/pstate"):]
|
||||||
|
head, err := api.ChainHead(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
p = "/ipfs/" + head.ParentState().String() + p
|
||||||
|
if cctx.Bool("verbose") {
|
||||||
|
fmt.Println(p)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
obj, err := api.ChainGetNode(ctx, p)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user