WIP: retrieval pieces inspection command
This commit is contained in:
committed by
Aayush Rajasekaran
parent
34bfafc7a7
commit
7fa4cd33f0
@@ -3,6 +3,7 @@ package main
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/filecoin-project/lotus/build"
|
||||
lcli "github.com/filecoin-project/lotus/cli"
|
||||
"github.com/filecoin-project/lotus/miner"
|
||||
"github.com/urfave/cli/v2"
|
||||
@@ -43,8 +44,14 @@ var minerSelectMsgsCmd = &cli.Command{
|
||||
return err
|
||||
}
|
||||
|
||||
var totalGas int64
|
||||
for _, f := range filtered {
|
||||
totalGas += f.Message.GasLimit
|
||||
}
|
||||
|
||||
fmt.Println("mempool input messages: ", len(msgs))
|
||||
fmt.Println("filtered messages: ", len(filtered))
|
||||
fmt.Printf("total gas limit of selected messages: %d / %d (%0.2f%%)\n", totalGas, build.BlockGasLimit, 100*float64(totalGas)/float64(build.BlockGasLimit))
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
@@ -41,6 +41,7 @@ func main() {
|
||||
lcli.WithCategory("storage", provingCmd),
|
||||
lcli.WithCategory("storage", storageCmd),
|
||||
lcli.WithCategory("storage", sealingCmd),
|
||||
lcli.WithCategory("retrieval", piecesCmd),
|
||||
}
|
||||
jaeger := tracing.SetupJaegerTracing("lotus")
|
||||
defer func() {
|
||||
|
||||
@@ -0,0 +1,135 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
lcli "github.com/filecoin-project/lotus/cli"
|
||||
"github.com/ipfs/go-cid"
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
var piecesCmd = &cli.Command{
|
||||
Name: "pieces",
|
||||
Usage: "interact with the piecestore",
|
||||
Description: "The piecestore is a database that tracks and manages data that is made available to the retrieval market",
|
||||
Subcommands: []*cli.Command{
|
||||
piecesListPiecesCmd,
|
||||
piecesListCidInfosCmd,
|
||||
piecesInfoCmd,
|
||||
piecesCidInfoCmd,
|
||||
},
|
||||
}
|
||||
|
||||
var piecesListPiecesCmd = &cli.Command{
|
||||
Name: "list-pieces",
|
||||
Usage: "list registered pieces",
|
||||
Action: func(cctx *cli.Context) error {
|
||||
nodeApi, closer, err := lcli.GetStorageMinerAPI(cctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer closer()
|
||||
ctx := lcli.ReqContext(cctx)
|
||||
|
||||
pieceCids, err := nodeApi.PiecesListPieces(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, pc := range pieceCids {
|
||||
fmt.Println(pc)
|
||||
}
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
var piecesListCidInfosCmd = &cli.Command{
|
||||
Name: "list-cids",
|
||||
Usage: "list registered payload CIDs",
|
||||
Action: func(cctx *cli.Context) error {
|
||||
nodeApi, closer, err := lcli.GetStorageMinerAPI(cctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer closer()
|
||||
ctx := lcli.ReqContext(cctx)
|
||||
|
||||
cids, err := nodeApi.PiecesListCidInfos(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, c := range cids {
|
||||
fmt.Println(c)
|
||||
}
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
var piecesInfoCmd = &cli.Command{
|
||||
Name: "piece-info",
|
||||
Usage: "get registered information for a given piece CID",
|
||||
Action: func(cctx *cli.Context) error {
|
||||
if !cctx.Args().Present() {
|
||||
return lcli.ShowHelp(cctx, fmt.Errorf("must specify piece cid"))
|
||||
}
|
||||
|
||||
nodeApi, closer, err := lcli.GetStorageMinerAPI(cctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer closer()
|
||||
ctx := lcli.ReqContext(cctx)
|
||||
|
||||
c, err := cid.Decode(cctx.Args().First())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
pi, err := nodeApi.PiecesGetPieceInfo(ctx, c)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
fmt.Println("Piece: ", pi.PieceCID)
|
||||
fmt.Println("Deals:\nDealID\tSectorID\tLength\tOffset")
|
||||
for _, d := range pi.Deals {
|
||||
fmt.Printf("%d\t%d\t%d\t%d\n", d.DealID, d.SectorID, d.Length, d.Offset)
|
||||
}
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
var piecesCidInfoCmd = &cli.Command{
|
||||
Name: "cid-info",
|
||||
Usage: "get registered information for a given payload CID",
|
||||
Action: func(cctx *cli.Context) error {
|
||||
if !cctx.Args().Present() {
|
||||
return lcli.ShowHelp(cctx, fmt.Errorf("must specify payload cid"))
|
||||
}
|
||||
|
||||
nodeApi, closer, err := lcli.GetStorageMinerAPI(cctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer closer()
|
||||
ctx := lcli.ReqContext(cctx)
|
||||
|
||||
c, err := cid.Decode(cctx.Args().First())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
ci, err := nodeApi.PiecesGetCIDInfo(ctx, c)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
fmt.Println("Info for: ", ci.CID)
|
||||
fmt.Printf("PieceCid\tOffset\tSize\n")
|
||||
for _, loc := range ci.PieceBlockLocations {
|
||||
fmt.Printf("%s\t%d\t%d\n", loc.PieceCID, loc.RelOffset, loc.BlockSize)
|
||||
}
|
||||
return nil
|
||||
},
|
||||
}
|
||||
Reference in New Issue
Block a user