Skip to content

Commit

Permalink
feat: boostd index announce-latest
Browse files Browse the repository at this point in the history
  • Loading branch information
dirkmc committed May 18, 2023
1 parent 961657b commit 1fda4c6
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 0 deletions.
1 change: 1 addition & 0 deletions api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ type Boost interface {

// MethodGroup: Boost
BoostIndexerAnnounceAllDeals(ctx context.Context) error //perm:admin
BoostIndexerAnnounceLatest(ctx context.Context) (cid.Cid, error) //perm:admin
BoostOfflineDealWithData(ctx context.Context, dealUuid uuid.UUID, filePath string, delAfterImport bool) (*ProviderDealRejectionInfo, error) //perm:admin
BoostDeal(ctx context.Context, dealUuid uuid.UUID) (*smtypes.ProviderDealState, error) //perm:admin
BoostDealBySignedProposalCid(ctx context.Context, proposalCid cid.Cid) (*smtypes.ProviderDealState, 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.
25 changes: 25 additions & 0 deletions cmd/boostd/index.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"fmt"
bcli "github.com/filecoin-project/boost/cli"
lcli "github.com/filecoin-project/lotus/cli"
"github.com/urfave/cli/v2"
Expand All @@ -11,6 +12,7 @@ var indexProvCmd = &cli.Command{
Usage: "Manage the index provider on Boost",
Subcommands: []*cli.Command{
indexProvAnnounceAllCmd,
indexProvAnnounceLatest,
},
}

Expand All @@ -31,3 +33,26 @@ var indexProvAnnounceAllCmd = &cli.Command{
return napi.BoostIndexerAnnounceAllDeals(ctx)
},
}

var indexProvAnnounceLatest = &cli.Command{
Name: "announce-latest",
Usage: "Re-publish the latest existing advertisement to pubsub",
Flags: []cli.Flag{},
Action: func(cctx *cli.Context) error {
ctx := lcli.ReqContext(cctx)

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

c, err := napi.BoostIndexerAnnounceLatest(ctx)
if err != nil {
return err
}

fmt.Println("Announced advertisement with cid %s", c)
return nil
},
}
15 changes: 15 additions & 0 deletions documentation/en/api-v1-methods.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
* [BoostDealBySignedProposalCid](#boostdealbysignedproposalcid)
* [BoostDummyDeal](#boostdummydeal)
* [BoostIndexerAnnounceAllDeals](#boostindexerannouncealldeals)
* [BoostIndexerAnnounceLatest](#boostindexerannouncelatest)
* [BoostMakeDeal](#boostmakedeal)
* [BoostOfflineDealWithData](#boostofflinedealwithdata)
* [Deals](#deals)
Expand Down Expand Up @@ -563,6 +564,20 @@ Inputs: `null`

Response: `{}`

### BoostIndexerAnnounceLatest


Perms: admin

Inputs: `null`

Response:
```json
{
"/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4"
}
```

### BoostMakeDeal


Expand Down
9 changes: 9 additions & 0 deletions indexprovider/wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"github.com/ipfs/go-cid"
logging "github.com/ipfs/go-log/v2"
provider "github.com/ipni/index-provider"
"github.com/ipni/index-provider/engine"
"github.com/ipni/index-provider/engine/xproviders"
"github.com/ipni/index-provider/metadata"
"github.com/libp2p/go-libp2p/core/crypto"
Expand Down Expand Up @@ -262,6 +263,14 @@ func (w *Wrapper) IndexerAnnounceAllDeals(ctx context.Context) error {
return merr
}

func (w *Wrapper) IndexerAnnounceLatest(ctx context.Context) (cid.Cid, error) {
e, ok := w.prov.(*engine.Engine)
if !ok {
return cid.Undef, fmt.Errorf("index provider is disabled")
}
return e.PublishLatest(ctx)
}

func (w *Wrapper) Start(ctx context.Context) {
// re-init dagstore shards for Boost deals if needed
if _, err := w.DagstoreReinitBoostDeals(ctx); err != nil {
Expand Down
4 changes: 4 additions & 0 deletions node/impl/boost.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ func (sm *BoostAPI) BoostIndexerAnnounceAllDeals(ctx context.Context) error {
return sm.IndexProvider.IndexerAnnounceAllDeals(ctx)
}

func (sm *BoostAPI) BoostIndexerAnnounceLatest(ctx context.Context) (cid.Cid, error) {
return sm.IndexProvider.IndexerAnnounceLatest(ctx)
}

func (sm *BoostAPI) BoostOfflineDealWithData(ctx context.Context, dealUuid uuid.UUID, filePath string, delAfterImport bool) (*api.ProviderDealRejectionInfo, error) {
res, err := sm.StorageProvider.ImportOfflineDealData(ctx, dealUuid, filePath, delAfterImport)
return res, err
Expand Down

0 comments on commit 1fda4c6

Please sign in to comment.