Merge pull request #1576 from filecoin-project/feat/reverse-lookup
cli: state lookup --reverse
This commit is contained in:
commit
c8d23b5947
15
cli/state.go
15
cli/state.go
@ -542,6 +542,13 @@ var stateLookupIDCmd = &cli.Command{
|
|||||||
Name: "lookup",
|
Name: "lookup",
|
||||||
Usage: "Find corresponding ID address",
|
Usage: "Find corresponding ID address",
|
||||||
ArgsUsage: "[address]",
|
ArgsUsage: "[address]",
|
||||||
|
Flags: []cli.Flag{
|
||||||
|
&cli.BoolFlag{
|
||||||
|
Name: "reverse",
|
||||||
|
Aliases: []string{"r"},
|
||||||
|
Usage: "Perform reverse lookup",
|
||||||
|
},
|
||||||
|
},
|
||||||
Action: func(cctx *cli.Context) error {
|
Action: func(cctx *cli.Context) error {
|
||||||
api, closer, err := GetFullNodeAPI(cctx)
|
api, closer, err := GetFullNodeAPI(cctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -565,7 +572,13 @@ var stateLookupIDCmd = &cli.Command{
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
a, err := api.StateLookupID(ctx, addr, ts.Key())
|
var a address.Address
|
||||||
|
if !cctx.Bool("reverse") {
|
||||||
|
a, err = api.StateLookupID(ctx, addr, ts.Key())
|
||||||
|
} else {
|
||||||
|
a, err = api.StateAccountKey(ctx, addr, ts.Key())
|
||||||
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user