Merge pull request #2821 from filecoin-project/feat/miner-allinfo

miner: Command to dump all miner info
This commit is contained in:
Łukasz Magiera 2020-08-05 20:33:27 +02:00 committed by GitHub
commit 0073f10b62
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 305 additions and 157 deletions

View File

@ -238,7 +238,7 @@ var CommonCommands = []*cli.Command{
logCmd,
waitApiCmd,
fetchParamCmd,
versionCmd,
VersionCmd,
}
var Commands = []*cli.Command{
@ -256,7 +256,7 @@ var Commands = []*cli.Command{
WithCategory("developer", fetchParamCmd),
WithCategory("network", netCmd),
WithCategory("network", syncCmd),
versionCmd,
VersionCmd,
}
func WithCategory(cat string, cmd *cli.Command) *cli.Command {

View File

@ -18,16 +18,16 @@ var netCmd = &cli.Command{
Name: "net",
Usage: "Manage P2P Network",
Subcommands: []*cli.Command{
netPeers,
NetPeers,
netConnect,
netListen,
netId,
NetListen,
NetId,
netFindPeer,
netScores,
},
}
var netPeers = &cli.Command{
var NetPeers = &cli.Command{
Name: "peers",
Usage: "Print peers",
Action: func(cctx *cli.Context) error {
@ -93,7 +93,7 @@ var netScores = &cli.Command{
},
}
var netListen = &cli.Command{
var NetListen = &cli.Command{
Name: "listen",
Usage: "List listen addresses",
Action: func(cctx *cli.Context) error {
@ -147,7 +147,7 @@ var netConnect = &cli.Command{
},
}
var netId = &cli.Command{
var NetId = &cli.Command{
Name: "id",
Usage: "Get node identity",
Action: func(cctx *cli.Context) error {

View File

@ -6,7 +6,7 @@ import (
"github.com/urfave/cli/v2"
)
var versionCmd = &cli.Command{
var VersionCmd = &cli.Command{
Name: "version",
Usage: "Print version",
Action: func(cctx *cli.Context) error {

View File

@ -24,7 +24,13 @@ import (
var infoCmd = &cli.Command{
Name: "info",
Usage: "Print miner info",
Action: func(cctx *cli.Context) error {
Subcommands: []*cli.Command{
infoAllCmd,
},
Action: infoCmdAct,
}
func infoCmdAct(cctx *cli.Context) error {
color.NoColor = !cctx.Bool("color")
nodeApi, closer, err := lcli.GetStorageMinerAPI(cctx)
@ -171,7 +177,6 @@ var infoCmd = &cli.Command{
// * Sealed sectors (count / bytes)
// * Power
return nil
},
}
type stateMeta struct {

View File

@ -0,0 +1,143 @@
package main
import (
"flag"
"fmt"
"sort"
"github.com/urfave/cli/v2"
lcli "github.com/filecoin-project/lotus/cli"
)
var infoAllCmd = &cli.Command{
Name: "all",
Usage: "dump all related miner info",
Action: func(cctx *cli.Context) error {
nodeApi, closer, err := lcli.GetStorageMinerAPI(cctx)
if err != nil {
return err
}
defer closer()
api, acloser, err := lcli.GetFullNodeAPI(cctx)
if err != nil {
return err
}
defer acloser()
_ = api
ctx := lcli.ReqContext(cctx)
// Top-level info
fmt.Println("#: Version")
if err := lcli.VersionCmd.Action(cctx); err != nil {
return err
}
fmt.Println("\n#: Miner Info")
if err := infoCmdAct(cctx); err != nil {
return err
}
// Verbose info
fmt.Println("\n#: Storage List")
if err := storageListCmd.Action(cctx); err != nil {
return err
}
fmt.Println("\n#: Worker List")
if err := sealingWorkersCmd.Action(cctx); err != nil {
return err
}
fmt.Println("\n#: PeerID")
if err := lcli.NetId.Action(cctx); err != nil {
return err
}
fmt.Println("\n#: Listen Addresses")
if err := lcli.NetListen.Action(cctx); err != nil {
return err
}
// Very Verbose info
fmt.Println("\n#: Peers")
if err := lcli.NetPeers.Action(cctx); err != nil {
return err
}
fmt.Println("\n#: Sealing Jobs")
if err := sealingJobsCmd.Action(cctx); err != nil {
return err
}
fmt.Println("\n#: Sched Diag")
if err := sealingSchedDiagCmd.Action(cctx); err != nil {
return err
}
fmt.Println("\n#: Storage Ask")
if err := getAskCmd.Action(cctx); err != nil {
return err
}
fmt.Println("\n#: Storage Deals")
if err := dealsListCmd.Action(cctx); err != nil {
return err
}
fmt.Println("\n#: Sector List")
if err := sectorsListCmd.Action(cctx); err != nil {
return err
}
fmt.Println("\n#: Sector Refs")
if err := sectorsRefsCmd.Action(cctx); err != nil {
return err
}
// Very Very Verbose info
fmt.Println("\n#: Per Sector Info")
list, err := nodeApi.SectorsList(ctx)
if err != nil {
return err
}
sort.Slice(list, func(i, j int) bool {
return list[i] < list[j]
})
for _, s := range list {
fmt.Printf("\n##: Sector %d Status\n", s)
fs := &flag.FlagSet{}
for _, f := range sectorsStatusCmd.Flags {
f.Apply(fs)
}
if err := fs.Parse([]string{"--log", "--on-chain-info", fmt.Sprint(s)}); err != nil {
return err
}
if err := sectorsStatusCmd.Action(cli.NewContext(cctx.App, fs, cctx)); err != nil {
return err
}
fmt.Printf("\n##: Sector %d Storage Location\n", s)
fs = &flag.FlagSet{}
if err := fs.Parse([]string{fmt.Sprint(s)}); err != nil {
return err
}
if err := storageFindCmd.Action(cli.NewContext(cctx.App, fs, cctx)); err != nil {
return err
}
}
return nil
},
}

View File

@ -266,7 +266,7 @@ var getAskCmd = &cli.Command{
}
w := tabwriter.NewWriter(os.Stdout, 2, 4, 2, ' ', 0)
fmt.Fprintf(w, "Price per GiB / Epoch\tMin. Piece Size (w/bit-padding)\tMax. Piece Size (w/bit-padding)\tExpiry (Epoch)\tExpiry (Appx. Rem. Time)\tSeq. No.\n")
fmt.Fprintf(w, "Price per GiB/Epoch\tMin. Piece Size (padded)\tMax. Piece Size (padded)\tExpiry (Epoch)\tExpiry (Appx. Rem. Time)\tSeq. No.\n")
if ask == nil {
fmt.Fprintf(w, "<miner does not have an ask>\n")