diff --git a/composed.go b/composed.go index 04d02c5..cff6a68 100644 --- a/composed.go +++ b/composed.go @@ -47,7 +47,7 @@ func (cr *Compose) GetValue(ctx context.Context, key string, opts ...ropts.Optio // Provide adds the given cid to the content routing system. If 'true' is // passed, it also announces it, otherwise it is just kept in the local // accounting of which objects are being provided. -func (cr *Compose) Provide(ctx context.Context, c *cid.Cid, local bool) error { +func (cr *Compose) Provide(ctx context.Context, c cid.Cid, local bool) error { if cr.ContentRouting == nil { return routing.ErrNotSupported } @@ -55,7 +55,7 @@ func (cr *Compose) Provide(ctx context.Context, c *cid.Cid, local bool) error { } // FindProvidersAsync searches for peers who are able to provide a given key -func (cr *Compose) FindProvidersAsync(ctx context.Context, c *cid.Cid, count int) <-chan pstore.PeerInfo { +func (cr *Compose) FindProvidersAsync(ctx context.Context, c cid.Cid, count int) <-chan pstore.PeerInfo { if cr.ContentRouting == nil { ch := make(chan pstore.PeerInfo) close(ch) diff --git a/dummy_test.go b/dummy_test.go index c7386b1..cc489a8 100644 --- a/dummy_test.go +++ b/dummy_test.go @@ -46,7 +46,7 @@ func (d *dummyValueStore) GetValue(ctx context.Context, key string, opts ...ropt type dummyProvider map[string][]peer.ID -func (d dummyProvider) FindProvidersAsync(ctx context.Context, c *cid.Cid, count int) <-chan pstore.PeerInfo { +func (d dummyProvider) FindProvidersAsync(ctx context.Context, c cid.Cid, count int) <-chan pstore.PeerInfo { peers := d[c.KeyString()] if len(peers) > count { peers = peers[:count] @@ -68,17 +68,17 @@ func (d dummyProvider) FindProvidersAsync(ctx context.Context, c *cid.Cid, count return out } -func (d dummyProvider) Provide(ctx context.Context, c *cid.Cid, local bool) error { +func (d dummyProvider) Provide(ctx context.Context, c cid.Cid, local bool) error { return routing.ErrNotSupported } -type cbProvider func(c *cid.Cid, local bool) error +type cbProvider func(c cid.Cid, local bool) error -func (d cbProvider) Provide(ctx context.Context, c *cid.Cid, local bool) error { +func (d cbProvider) Provide(ctx context.Context, c cid.Cid, local bool) error { return d(c, local) } -func (d cbProvider) FindProvidersAsync(ctx context.Context, c *cid.Cid, count int) <-chan pstore.PeerInfo { +func (d cbProvider) FindProvidersAsync(ctx context.Context, c cid.Cid, count int) <-chan pstore.PeerInfo { ch := make(chan pstore.PeerInfo) close(ch) return ch diff --git a/null.go b/null.go index 7d168f1..ec0fdfa 100644 --- a/null.go +++ b/null.go @@ -25,12 +25,12 @@ func (nr Null) GetValue(context.Context, string, ...ropts.Option) ([]byte, error } // Provide always returns ErrNotSupported -func (nr Null) Provide(context.Context, *cid.Cid, bool) error { +func (nr Null) Provide(context.Context, cid.Cid, bool) error { return routing.ErrNotSupported } // FindProvidersAsync always returns a closed channel -func (nr Null) FindProvidersAsync(context.Context, *cid.Cid, int) <-chan pstore.PeerInfo { +func (nr Null) FindProvidersAsync(context.Context, cid.Cid, int) <-chan pstore.PeerInfo { ch := make(chan pstore.PeerInfo) close(ch) return ch diff --git a/null_test.go b/null_test.go index 4c8900b..19602f2 100644 --- a/null_test.go +++ b/null_test.go @@ -4,6 +4,7 @@ import ( "context" "testing" + cid "github.com/ipfs/go-cid" peer "github.com/libp2p/go-libp2p-peer" routing "github.com/libp2p/go-libp2p-routing" ) @@ -17,10 +18,10 @@ func TestNull(t *testing.T) { if _, err := n.GetValue(ctx, "anything", nil); err != routing.ErrNotFound { t.Fatal(err) } - if err := n.Provide(ctx, nil, false); err != routing.ErrNotSupported { + if err := n.Provide(ctx, cid.Cid{}, false); err != routing.ErrNotSupported { t.Fatal(err) } - if _, ok := <-n.FindProvidersAsync(ctx, nil, 10); ok { + if _, ok := <-n.FindProvidersAsync(ctx, cid.Cid{}, 10); ok { t.Fatal("expected no values") } if _, err := n.FindPeer(ctx, peer.ID("thing")); err != routing.ErrNotFound { diff --git a/package.json b/package.json index 8afcb6c..2cf609f 100644 --- a/package.json +++ b/package.json @@ -9,9 +9,9 @@ "gxDependencies": [ { "author": "whyrusleeping", - "hash": "QmZFbDTY9jfSBms2MchvYM9oYRbAF19K7Pby47yDBfpPrb", + "hash": "QmPSQnBKM9g7BaUcZCvswUJVscQ1ipjmwxN5PXCjkp9EQ7", "name": "go-cid", - "version": "0.8.0" + "version": "0.9.0" }, { "author": "whyrusleeping", @@ -38,9 +38,9 @@ "version": "2.0.0" }, { - "hash": "QmY9JUvS8kbgao3XbPh6WAV3ChE2nxGKhcGTHiwMC4gmcU", + "hash": "QmdKS5YtmuSWKuLLgbHG176mS3VX3AKiyVmaaiAfvgcuch", "name": "go-libp2p-routing", - "version": "2.4.10" + "version": "2.5.0" }, { "author": "hashicorp", diff --git a/parallel.go b/parallel.go index 542e8f3..3ec607c 100644 --- a/parallel.go +++ b/parallel.go @@ -250,7 +250,7 @@ func (r Parallel) FindPeer(ctx context.Context, p peer.ID) (pstore.PeerInfo, err return pi, err } -func (r Parallel) Provide(ctx context.Context, c *cid.Cid, local bool) error { +func (r Parallel) Provide(ctx context.Context, c cid.Cid, local bool) error { return r.filter(func(ri routing.IpfsRouting) bool { return supportsContent(ri) }).put(func(ri routing.IpfsRouting) error { @@ -258,7 +258,7 @@ func (r Parallel) Provide(ctx context.Context, c *cid.Cid, local bool) error { }) } -func (r Parallel) FindProvidersAsync(ctx context.Context, c *cid.Cid, count int) <-chan pstore.PeerInfo { +func (r Parallel) FindProvidersAsync(ctx context.Context, c cid.Cid, count int) <-chan pstore.PeerInfo { routers := r.filter(func(ri routing.IpfsRouting) bool { return supportsContent(ri) }) diff --git a/parallel_test.go b/parallel_test.go index 0415f80..d229cae 100644 --- a/parallel_test.go +++ b/parallel_test.go @@ -226,7 +226,7 @@ func TestParallelFindProviders(t *testing.T) { for i := 0; i < 2; i++ { for i, tc := range []struct { - cid *cid.Cid + cid cid.Cid providers []peer.ID }{ { @@ -370,12 +370,12 @@ func TestParallelProvide(t *testing.T) { d := Parallel{ Parallel{ &Compose{ - ContentRouting: cbProvider(func(c *cid.Cid, local bool) error { + ContentRouting: cbProvider(func(c cid.Cid, local bool) error { return routing.ErrNotSupported }), }, &Compose{ - ContentRouting: cbProvider(func(c *cid.Cid, local bool) error { + ContentRouting: cbProvider(func(c cid.Cid, local bool) error { return errors.New(c.String()) }), }, diff --git a/tiered.go b/tiered.go index 98308e2..8ac49fc 100644 --- a/tiered.go +++ b/tiered.go @@ -62,11 +62,11 @@ func (r Tiered) GetPublicKey(ctx context.Context, p peer.ID) (ci.PubKey, error) return val, err } -func (r Tiered) Provide(ctx context.Context, c *cid.Cid, local bool) error { +func (r Tiered) Provide(ctx context.Context, c cid.Cid, local bool) error { return Parallel(r).Provide(ctx, c, local) } -func (r Tiered) FindProvidersAsync(ctx context.Context, c *cid.Cid, count int) <-chan pstore.PeerInfo { +func (r Tiered) FindProvidersAsync(ctx context.Context, c cid.Cid, count int) <-chan pstore.PeerInfo { return Parallel(r).FindProvidersAsync(ctx, c, count) } diff --git a/tiered_test.go b/tiered_test.go index f8a8d82..92e1529 100644 --- a/tiered_test.go +++ b/tiered_test.go @@ -5,6 +5,7 @@ import ( "testing" errwrap "github.com/hashicorp/errwrap" + cid "github.com/ipfs/go-cid" routing "github.com/libp2p/go-libp2p-routing" ) @@ -85,7 +86,7 @@ func TestTieredGet(t *testing.T) { func TestTieredNoSupport(t *testing.T) { d := Tiered{Tiered{Null{}}} - if _, ok := <-d.FindProvidersAsync(context.Background(), nil, 0); ok { + if _, ok := <-d.FindProvidersAsync(context.Background(), cid.Cid{}, 0); ok { t.Fatal("shouldn't have found a provider") } }