Skip to content

Commit

Permalink
fix: pass through indexing service config
Browse files Browse the repository at this point in the history
  • Loading branch information
alanshaw committed Oct 22, 2024
1 parent 21c0486 commit 01373dc
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 3 deletions.
16 changes: 16 additions & 0 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (

leveldb "github.com/ipfs/go-ds-leveldb"
logging "github.com/ipfs/go-log/v2"
"github.com/storacha/go-ucanto/core/delegation"
"github.com/storacha/go-ucanto/did"
ed25519 "github.com/storacha/go-ucanto/principal/ed25519/signer"
"github.com/storacha/storage/pkg/server"
Expand Down Expand Up @@ -66,6 +67,11 @@ func main() {
Usage: "URL the node is publically accessible at.",
EnvVars: []string{"STORAGE_PUBLIC_URL"},
},
&cli.StringFlag{
Name: "indexing-service-proof",
Usage: "A delegation that allows the node to cache claims with the indexing service.",
EnvVars: []string{"STORAGE_INDEXING_SERVICE_PROOF"},
},
},
Action: func(cCtx *cli.Context) error {
var err error
Expand Down Expand Up @@ -181,6 +187,15 @@ func main() {
indexingServiceURL = *u
}

var indexingServiceProofs delegation.Proofs
if cCtx.String("indexing-service-proof") != "" {
dlg, err := delegation.Parse(cCtx.String("indexing-service-proof"))
if err != nil {
return fmt.Errorf("parsing indexing service proof: %w", err)
}
indexingServiceProofs = append(indexingServiceProofs, delegation.FromDelegation(dlg))
}

svc, err := storage.New(
storage.WithIdentity(id),
storage.WithBlobstore(blobStore),
Expand All @@ -190,6 +205,7 @@ func main() {
storage.WithPublicURL(*pubURL),
storage.WithPublisherDirectAnnounce(announceURL),
storage.WithPublisherIndexingServiceConfig(indexingServiceDID, indexingServiceURL),
storage.WithPublisherIndexingServiceProof(indexingServiceProofs...),
)
if err != nil {
return fmt.Errorf("creating service instance: %w", err)
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ require (
github.com/multiformats/go-multihash v0.2.3
github.com/storacha/go-capabilities v0.0.0-20241021134022-7144600f5aeb
github.com/storacha/go-metadata v0.0.0-20241021141939-f94d93dcda78
github.com/storacha/go-ucanto v0.1.1-0.20241022082502-7edcd3716f2d
github.com/storacha/go-ucanto v0.1.1-0.20241022122125-fc561a4d642c
github.com/storacha/ipni-publisher v0.0.0-20241018055706-032286a2dc3f
github.com/stretchr/testify v1.9.0
github.com/urfave/cli/v2 v2.27.4
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,8 @@ github.com/storacha/go-metadata v0.0.0-20241021141939-f94d93dcda78 h1:NAti9hMLMo
github.com/storacha/go-metadata v0.0.0-20241021141939-f94d93dcda78/go.mod h1:DcwwQnyFuTk531cKD9sUkQg/gzpwKaIqH9I7oZYyeRc=
github.com/storacha/go-ucanto v0.1.1-0.20241022082502-7edcd3716f2d h1:hgc/F88Klbj+HMFdfHGAjcAfoMz3FHFKRW6yhUPHYgs=
github.com/storacha/go-ucanto v0.1.1-0.20241022082502-7edcd3716f2d/go.mod h1:Bi7DFuo0nj9/QmkqbLNLWf41xnOoJSFGg21G+UtzWoY=
github.com/storacha/go-ucanto v0.1.1-0.20241022122125-fc561a4d642c h1:Z8MZyBenGPhGE+w43UBhPq5uF2cri5o9zzyTmWM337Q=
github.com/storacha/go-ucanto v0.1.1-0.20241022122125-fc561a4d642c/go.mod h1:vzifzvheQKs507Yr7qj2x4MYNrdBwjdKXtHsD3xpDm4=
github.com/storacha/ipni-publisher v0.0.0-20241018055706-032286a2dc3f h1:62fTASO3wRPCWCkl6we2DftsFy/DfbmVpwJyqK7gmUc=
github.com/storacha/ipni-publisher v0.0.0-20241018055706-032286a2dc3f/go.mod h1:fEuGSF5WMaOSAyDQCYAvow6Y+YKzpXczEk3A+H+s1fQ=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
Expand Down
11 changes: 9 additions & 2 deletions pkg/service/storage/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,15 @@ func New(opts ...Option) (*StorageService, error) {
return nil, fmt.Errorf("creating blob service: %w", err)
}

claimsOpts := []claims.Option{claims.WithPublisherDirectAnnounce(c.announceURLs...)}
claims, err := claims.New(id, claimDs, publisherDs, pubURL, claimsOpts...)
claims, err := claims.New(
id,
claimDs,
publisherDs,
pubURL,
claims.WithPublisherDirectAnnounce(c.announceURLs...),
claims.WithPublisherIndexingService(c.indexingService),
claims.WithPublisherIndexingServiceProof(c.indexingServiceProofs...),
)
if err != nil {
return nil, fmt.Errorf("creating claim service: %w", err)
}
Expand Down

0 comments on commit 01373dc

Please sign in to comment.