Skip to content

Commit

Permalink
UX: lotus state power CLI should fail if called with a not-miner
Browse files Browse the repository at this point in the history
  • Loading branch information
arajasek committed Jun 8, 2021
1 parent 4bff4f2 commit a44e91d
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions cli/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down

0 comments on commit a44e91d

Please sign in to comment.