Skip to content

Commit

Permalink
Merge pull request #6425 from filecoin-project/asr/state-power
Browse files Browse the repository at this point in the history
UX: lotus state power CLI should fail if called with a not-miner
  • Loading branch information
magik6k committed Jun 9, 2021
2 parents 4bff4f2 + a44e91d commit a0f1662
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 a0f1662

Please sign in to comment.