Merge pull request #2525 from filecoin-project/feat/more-lotus-shed-tools

Feat/more lotus shed tools
This commit is contained in:
Łukasz Magiera 2020-07-22 19:36:32 +02:00 committed by GitHub
commit 2af3a0c024
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 91 additions and 0 deletions

View File

@ -27,6 +27,8 @@ func main() {
fetchParamCmd, fetchParamCmd,
proofsCmd, proofsCmd,
verifRegCmd, verifRegCmd,
miscCmd,
mpoolCmd,
} }
app := &cli.App{ app := &cli.App{

39
cmd/lotus-shed/misc.go Normal file
View File

@ -0,0 +1,39 @@
package main
import (
"fmt"
"strconv"
"github.com/filecoin-project/go-fil-markets/storagemarket"
"github.com/urfave/cli/v2"
)
var miscCmd = &cli.Command{
Name: "misc",
Usage: "Assorted unsorted commands for various purposes",
Flags: []cli.Flag{},
Subcommands: []*cli.Command{
dealStateMappingCmd,
},
}
var dealStateMappingCmd = &cli.Command{
Name: "deal-state",
Action: func(cctx *cli.Context) error {
if !cctx.Args().Present() {
return cli.ShowCommandHelp(cctx, cctx.Command.Name)
}
num, err := strconv.Atoi(cctx.Args().First())
if err != nil {
return err
}
ststr, ok := storagemarket.DealStates[uint64(num)]
if !ok {
return fmt.Errorf("no such deal state %d", num)
}
fmt.Println(ststr)
return nil
},
}

50
cmd/lotus-shed/mpool.go Normal file
View File

@ -0,0 +1,50 @@
package main
import (
"fmt"
lcli "github.com/filecoin-project/lotus/cli"
"github.com/filecoin-project/lotus/miner"
"github.com/urfave/cli/v2"
)
var mpoolCmd = &cli.Command{
Name: "mpool",
Usage: "Tools for diagnosing mempool issues",
Flags: []cli.Flag{},
Subcommands: []*cli.Command{
minerSelectMsgsCmd,
},
}
var minerSelectMsgsCmd = &cli.Command{
Name: "miner-select-msgs",
Action: func(cctx *cli.Context) error {
api, closer, err := lcli.GetFullNodeAPI(cctx)
if err != nil {
return err
}
defer closer()
ctx := lcli.ReqContext(cctx)
head, err := api.ChainHead(ctx)
if err != nil {
return err
}
msgs, err := api.MpoolPending(ctx, head.Key())
if err != nil {
return err
}
filtered, err := miner.SelectMessages(ctx, api.StateGetActor, head, msgs)
if err != nil {
return err
}
fmt.Println("mempool input messages: ", len(msgs))
fmt.Println("filtered messages: ", len(filtered))
return nil
},
}