Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Jun 9, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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