Skip to content

Commit

Permalink
When doing sectors update-state, show a list of existing states if …
Browse files Browse the repository at this point in the history
…user inputs an invalid one.
  • Loading branch information
jennijuju committed Sep 22, 2020
1 parent 46ed014 commit 7f15369
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions cmd/lotus-storage-miner/sectors.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"fmt"
"github.com/fatih/color"
"os"
"sort"
"strconv"
Expand Down Expand Up @@ -403,8 +404,9 @@ var sectorsCapacityCollateralCmd = &cli.Command{
}

var sectorsUpdateCmd = &cli.Command{
Name: "update-state",
Usage: "ADVANCED: manually update the state of a sector, this may aid in error recovery",
Name: "update-state",
Usage: "ADVANCED: manually update the state of a sector, this may aid in error recovery",
ArgsUsage: "<sectorNum> <newState>",
Flags: []cli.Flag{
&cli.BoolFlag{
Name: "really-do-it",
Expand All @@ -430,8 +432,14 @@ var sectorsUpdateCmd = &cli.Command{
return xerrors.Errorf("could not parse sector number: %w", err)
}

if _, ok := sealing.ExistSectorStateList[sealing.SectorState(cctx.Args().Get(1))]; !ok {
return xerrors.Errorf("Not existing sector state")
newState := cctx.Args().Get(1)
if _, ok := sealing.ExistSectorStateList[sealing.SectorState(newState)]; !ok {
bold := color.New(color.Bold).SprintFunc()
fmt.Printf("%s is not a valid state. Possible states for sectors are: \n", bold(newState))
for state := range sealing.ExistSectorStateList {
fmt.Printf("%s\n", string(state))
}
return nil
}

return nodeApi.SectorsUpdate(ctx, abi.SectorNumber(id), api.SectorState(cctx.Args().Get(1)))
Expand Down

0 comments on commit 7f15369

Please sign in to comment.