Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: LID clean up #1881

Merged
merged 13 commits into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ type Boost interface {
BlockstoreGetSize(ctx context.Context, c cid.Cid) (int, error) //perm:read

// MethodGroup: PieceDirectory
PdBuildIndexForPieceCid(ctx context.Context, piececid cid.Cid) error //perm:admin
PdBuildIndexForPieceCid(ctx context.Context, piececid cid.Cid) error //perm:admin
PdRemoveDealForPiece(ctx context.Context, piececid cid.Cid, dealID string) error //perm:admin

// MethodGroup: Misc
OnlineBackup(context.Context, string) error //perm:admin
Expand Down
13 changes: 13 additions & 0 deletions api/proxy_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified build/openrpc/boost.json.gz
Binary file not shown.
53 changes: 53 additions & 0 deletions cmd/boostd/piecedir.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

bcli "github.com/filecoin-project/boost/cli"
lcli "github.com/filecoin-project/lotus/cli"
"github.com/google/uuid"
"github.com/ipfs/go-cid"
"github.com/urfave/cli/v2"
)
Expand All @@ -17,6 +18,7 @@ var pieceDirCmd = &cli.Command{
Subcommands: []*cli.Command{
pdIndexGenerate,
recoverCmd,
removeDealCmd,
},
}

Expand Down Expand Up @@ -56,3 +58,54 @@ var pdIndexGenerate = &cli.Command{
return nil
},
}

var removeDealCmd = &cli.Command{
Name: "remove-deal",
Usage: "Removes a deal from piece metadata in LID. If the specified deal is the only one in piece metadata, index and metadata are also removed",
ArgsUsage: "<piece CID> <deal UUID or Proposal CID>",
Action: func(cctx *cli.Context) error {

ctx := lcli.ReqContext(cctx)

if cctx.Args().Len() > 2 {
return fmt.Errorf("must specify piece CID and deal UUID/Proposal CID")
}

napi, closer, err := bcli.GetBoostAPI(cctx)
if err != nil {
return err
}
defer closer()

// parse piececid
piececid, err := cid.Decode(cctx.Args().Get(0))
if err != nil {
return fmt.Errorf("parsing piece CID: %w", err)
}

id := cctx.Args().Get(1)

// Parse to avoid sending garbage data to API
dealUuid, err := uuid.Parse(id)
if err != nil {
propCid, err := cid.Decode(id)
if err != nil {
return fmt.Errorf("could not parse '%s' as deal uuid or proposal cid", id)
}
err = napi.PdRemoveDealForPiece(ctx, piececid, propCid.String())
if err != nil {
return err
}
fmt.Printf("Deal %s removed for piece %s\n", propCid, piececid)
return nil
}

err = napi.PdRemoveDealForPiece(ctx, piececid, dealUuid.String())
if err != nil {
return err
}
fmt.Printf("Deal %s removed for piece %s\n", dealUuid, piececid)
return nil

},
}
18 changes: 18 additions & 0 deletions documentation/en/api-v1-methods.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
* [OnlineBackup](#onlinebackup)
* [Pd](#pd)
* [PdBuildIndexForPieceCid](#pdbuildindexforpiececid)
* [PdRemoveDealForPiece](#pdremovedealforpiece)
##


Expand Down Expand Up @@ -1244,3 +1245,20 @@ Inputs:

Response: `{}`

### PdRemoveDealForPiece


Perms: admin

Inputs:
```json
[
{
"/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4"
},
"string value"
]
```

Response: `{}`

Loading
Loading