Skip to content

Commit

Permalink
feat: LID clean up (#1881)
Browse files Browse the repository at this point in the history
* LID clean up

* add test and fix lint errs

* add minerID param for removing deal

* Revert "add minerID param for removing deal"

This reverts commit fb5997a.

* add clean up interval config

* fix test

* account for FIP-45, change config type

* fix test

* fix TODOs

* account sector mismatch

* code cleanup

* fix lint error
  • Loading branch information
LexLuthr authored Mar 6, 2024
1 parent 980ba6a commit fa61997
Show file tree
Hide file tree
Showing 13 changed files with 672 additions and 1 deletion.
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

0 comments on commit fa61997

Please sign in to comment.