UX: lotus state power CLI should fail if called with a not-miner

This commit is contained in:
Aayush Rajasekaran 2021-06-08 18:46:21 -04:00
parent 4bff4f25ad
commit a44e91df4b

View File

@ -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())