Merge pull request #6132 from filecoin-project/asr/state-miner-cli

Add a CLI tool for miner proving deadline
This commit is contained in:
Łukasz Magiera 2021-04-29 18:37:16 +02:00 committed by GitHub
commit c548bb3c4c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -75,6 +75,50 @@ var StateCmd = &cli.Command{
StateMarketCmd,
StateExecTraceCmd,
StateNtwkVersionCmd,
StateMinerProvingDeadlineCmd,
},
}
var StateMinerProvingDeadlineCmd = &cli.Command{
Name: "miner-proving-deadline",
Usage: "Retrieve information about a given miner's proving deadline",
ArgsUsage: "[minerAddress]",
Action: func(cctx *cli.Context) error {
api, closer, err := GetFullNodeAPI(cctx)
if err != nil {
return err
}
defer closer()
ctx := ReqContext(cctx)
if !cctx.Args().Present() {
return fmt.Errorf("must specify miner to get information for")
}
addr, err := address.NewFromString(cctx.Args().First())
if err != nil {
return err
}
ts, err := LoadTipSet(ctx, cctx, api)
if err != nil {
return err
}
cd, err := api.StateMinerProvingDeadline(ctx, addr, ts.Key())
if err != nil {
return xerrors.Errorf("getting miner info: %w", err)
}
fmt.Printf("Period Start:\t%s\n", cd.PeriodStart)
fmt.Printf("Index:\t\t%d\n", cd.Index)
fmt.Printf("Open:\t\t%s\n", cd.Open)
fmt.Printf("Close:\t\t%s\n", cd.Close)
fmt.Printf("Challenge:\t%s\n", cd.Challenge)
fmt.Printf("FaultCutoff:\t%s\n", cd.FaultCutoff)
return nil
},
}