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) ctx := ReqContext(cctx)
ts, err := LoadTipSet(ctx, cctx, api)
if err != nil {
return err
}
var maddr address.Address var maddr address.Address
if cctx.Args().Present() { if cctx.Args().Present() {
maddr, err = address.NewFromString(cctx.Args().First()) maddr, err = address.NewFromString(cctx.Args().First())
if err != nil { if err != nil {
return err return err
} }
}
ts, err := LoadTipSet(ctx, cctx, api) ma, err := api.StateGetActor(ctx, maddr, ts.Key())
if err != nil { if err != nil {
return err 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()) power, err := api.StateMinerPower(ctx, maddr, ts.Key())