From 01373dc495dfaa0aeabfd90ebd9fe733ebbce975 Mon Sep 17 00:00:00 2001 From: Alan Shaw Date: Tue, 22 Oct 2024 13:26:05 +0100 Subject: [PATCH] fix: pass through indexing service config --- cmd/main.go | 16 ++++++++++++++++ go.mod | 2 +- go.sum | 2 ++ pkg/service/storage/service.go | 11 +++++++++-- 4 files changed, 28 insertions(+), 3 deletions(-) diff --git a/cmd/main.go b/cmd/main.go index bfeb4b6..95e8109 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -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" @@ -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 @@ -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), @@ -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) diff --git a/go.mod b/go.mod index 3cefcaa..c9dc7a5 100644 --- a/go.mod +++ b/go.mod @@ -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 diff --git a/go.sum b/go.sum index 17584cf..4875161 100644 --- a/go.sum +++ b/go.sum @@ -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= diff --git a/pkg/service/storage/service.go b/pkg/service/storage/service.go index edf798d..ca648df 100644 --- a/pkg/service/storage/service.go +++ b/pkg/service/storage/service.go @@ -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) }