UX: lotus state power CLI should fail if called with a not-miner
This commit is contained in:
parent
4bff4f25ad
commit
a44e91df4b
17
cli/state.go
17
cli/state.go
@ -281,17 +281,26 @@ var StatePowerCmd = &cli.Command{
|
||||
|
||||
ctx := ReqContext(cctx)
|
||||
|
||||
ts, err := LoadTipSet(ctx, cctx, api)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
var maddr address.Address
|
||||
if cctx.Args().Present() {
|
||||
maddr, err = address.NewFromString(cctx.Args().First())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
ts, err := LoadTipSet(ctx, cctx, api)
|
||||
if err != nil {
|
||||
return err
|
||||
ma, err := api.StateGetActor(ctx, maddr, ts.Key())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if !builtin.IsStorageMinerActor(ma.Code) {
|
||||
return xerrors.New("provided address does not correspond to a miner actor")
|
||||
}
|
||||
}
|
||||
|
||||
power, err := api.StateMinerPower(ctx, maddr, ts.Key())
|
||||
|
Loading…
Reference in New Issue
Block a user