Skip to content

Commit

Permalink
boostd inspect command (#636)
Browse files Browse the repository at this point in the history
* wip: unsealed file testing

* feat: piece metadata

* rename PieceMeta to Inspect

* add inspect menu item

* re-arrange menu items

* fixup doctor cmd

* rename doctor to inspect

* fixup

* fixup

* fixup

* add links to legacy deal detail

* remove inspect command, as it is the same as pieces piece-info

* fix: inspect page styles

Co-authored-by: Dirk McCormick <[email protected]>
  • Loading branch information
nonsense and dirkmc authored Jul 7, 2022
1 parent 4c79501 commit 93f9b26
Show file tree
Hide file tree
Showing 18 changed files with 753 additions and 43 deletions.
10 changes: 5 additions & 5 deletions cmd/boostd/pieces.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (

var piecesCmd = &cli.Command{
Name: "pieces",
Usage: "interact with the piecestore",
Usage: "Interact with the Piece Store",
Description: "The piecestore is a database that tracks and manages data that is made available to the retrieval market",
Subcommands: []*cli.Command{
piecesListPiecesCmd,
Expand All @@ -26,7 +26,7 @@ var piecesCmd = &cli.Command{

var piecesListPiecesCmd = &cli.Command{
Name: "list-pieces",
Usage: "list registered pieces",
Usage: "List registered pieces",
Action: func(cctx *cli.Context) error {
nodeApi, closer, err := bcli.GetBoostAPI(cctx)
if err != nil {
Expand All @@ -49,7 +49,7 @@ var piecesListPiecesCmd = &cli.Command{

var piecesListCidInfosCmd = &cli.Command{
Name: "list-cids",
Usage: "list registered payload CIDs",
Usage: "List registered payload CIDs",
Flags: []cli.Flag{
&cli.BoolFlag{
Name: "verbose",
Expand Down Expand Up @@ -123,7 +123,7 @@ var piecesListCidInfosCmd = &cli.Command{

var piecesInfoCmd = &cli.Command{
Name: "piece-info",
Usage: "get registered information for a given piece CID",
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"))
Expand Down Expand Up @@ -158,7 +158,7 @@ var piecesInfoCmd = &cli.Command{

var piecesCidInfoCmd = &cli.Command{
Name: "cid-info",
Usage: "get registered information for a given payload CID",
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"))
Expand Down
11 changes: 0 additions & 11 deletions cmd/boostx/utils_cmd.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package main

import (
"bufio"
"context"
"fmt"
"io"
Expand Down Expand Up @@ -213,16 +212,6 @@ var commpCmd = &cli.Command{
}
defer rdr.Close() //nolint:errcheck

// check that the data is a car file; if it's not, retrieval won't work
_, err = car.ReadHeader(bufio.NewReader(rdr))
if err != nil {
return fmt.Errorf("not a car file: %w", err)
}

if _, err := rdr.Seek(0, io.SeekStart); err != nil {
return fmt.Errorf("seek to start: %w", err)
}

w := &writer.Writer{}
_, err = io.CopyBuffer(w, rdr, make([]byte, writer.CommPBuf))
if err != nil {
Expand Down
8 changes: 8 additions & 0 deletions db/deals.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,14 @@ func (d *DealsDB) ByPublishCID(ctx context.Context, publishCid string) ([]*types
return deals, nil
}

func (d *DealsDB) ByPieceCID(ctx context.Context, pieceCid cid.Cid) ([]*types.ProviderDealState, error) {
return d.list(ctx, 0, 0, "PieceCID=?", pieceCid.String())
}

func (d *DealsDB) ByRootPayloadCID(ctx context.Context, payloadCid cid.Cid) ([]*types.ProviderDealState, error) {
return d.list(ctx, 0, 0, "DealDataRoot=?", payloadCid.String())
}

func (d *DealsDB) BySignedProposalCID(ctx context.Context, proposalCid cid.Cid) (*types.ProviderDealState, error) {
qry := "SELECT " + dealFieldsStr + " FROM Deals WHERE SignedProposalCID=?"
row := d.db.QueryRowContext(ctx, qry, proposalCid.String())
Expand Down
12 changes: 10 additions & 2 deletions gql/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"encoding/hex"
"errors"
"fmt"

"github.com/filecoin-project/boost/db"
"github.com/filecoin-project/boost/fundmanager"
gqltypes "github.com/filecoin-project/boost/gql/types"
Expand All @@ -16,6 +15,9 @@ import (
"github.com/filecoin-project/boost/storagemarket/types"
"github.com/filecoin-project/boost/storagemarket/types/dealcheckpoints"
"github.com/filecoin-project/boost/transport"
"github.com/filecoin-project/dagstore"
"github.com/filecoin-project/go-fil-markets/piecestore"
"github.com/filecoin-project/go-fil-markets/retrievalmarket"
lotus_storagemarket "github.com/filecoin-project/go-fil-markets/storagemarket"
"github.com/filecoin-project/lotus/api/v1api"
"github.com/filecoin-project/lotus/markets/storageadapter"
Expand Down Expand Up @@ -49,12 +51,15 @@ type resolver struct {
provider *storagemarket.Provider
legacyProv lotus_storagemarket.StorageProvider
legacyDT lotus_dtypes.ProviderDataTransfer
ps piecestore.PieceStore
sa retrievalmarket.SectorAccessor
dagst dagstore.Interface
publisher *storageadapter.DealPublisher
spApi sealingpipeline.API
fullNode v1api.FullNode
}

func NewResolver(cfg *config.Boost, r lotus_repo.LockedRepo, h host.Host, dealsDB *db.DealsDB, logsDB *db.LogsDB, plDB *db.ProposalLogsDB, fundsDB *db.FundsDB, fundMgr *fundmanager.FundManager, storageMgr *storagemanager.StorageManager, spApi sealingpipeline.API, provider *storagemarket.Provider, legacyProv lotus_storagemarket.StorageProvider, legacyDT lotus_dtypes.ProviderDataTransfer, publisher *storageadapter.DealPublisher, fullNode v1api.FullNode) *resolver {
func NewResolver(cfg *config.Boost, r lotus_repo.LockedRepo, h host.Host, dealsDB *db.DealsDB, logsDB *db.LogsDB, plDB *db.ProposalLogsDB, fundsDB *db.FundsDB, fundMgr *fundmanager.FundManager, storageMgr *storagemanager.StorageManager, spApi sealingpipeline.API, provider *storagemarket.Provider, legacyProv lotus_storagemarket.StorageProvider, legacyDT lotus_dtypes.ProviderDataTransfer, ps piecestore.PieceStore, sa retrievalmarket.SectorAccessor, dagst dagstore.Interface, publisher *storageadapter.DealPublisher, fullNode v1api.FullNode) *resolver {
return &resolver{
cfg: cfg,
repo: r,
Expand All @@ -68,6 +73,9 @@ func NewResolver(cfg *config.Boost, r lotus_repo.LockedRepo, h host.Host, dealsD
provider: provider,
legacyProv: legacyProv,
legacyDT: legacyDT,
ps: ps,
sa: sa,
dagst: dagst,
publisher: publisher,
spApi: spApi,
fullNode: fullNode,
Expand Down
Loading

0 comments on commit 93f9b26

Please sign in to comment.