From 86f9eb73c34aeabc2e3e5ad7eb88f8e441624033 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Tue, 28 Aug 2018 02:22:09 +0200 Subject: [PATCH] coreapi: dht: remove option prefix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit License: MIT Signed-off-by: Ɓukasz Magiera --- core/coreapi/dht.go | 3 +-- core/coreapi/dht_test.go | 6 +++--- core/coreapi/interface/options/dht.go | 8 ++++---- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/core/coreapi/dht.go b/core/coreapi/dht.go index 7c1b1327e..0585fdb86 100644 --- a/core/coreapi/dht.go +++ b/core/coreapi/dht.go @@ -103,9 +103,8 @@ func provideKeysRec(ctx context.Context, r routing.IpfsRouting, bs blockstore.Bl errCh := make(chan error) go func() { + dserv := dag.NewDAGService(blockservice.New(bs, offline.Exchange(bs))) for _, c := range cids { - dserv := dag.NewDAGService(blockservice.New(bs, offline.Exchange(bs))) - err := dag.EnumerateChildrenAsync(ctx, dag.GetLinksDirect(dserv), c, provided.Visitor(ctx)) if err != nil { errCh <- err diff --git a/core/coreapi/dht_test.go b/core/coreapi/dht_test.go index e7555db15..759835b56 100644 --- a/core/coreapi/dht_test.go +++ b/core/coreapi/dht_test.go @@ -51,7 +51,7 @@ func TestDhtFindProviders(t *testing.T) { t.Fatal(err) } - out, err := apis[2].Dht().FindProviders(ctx, p, options.Dht.WithNumProviders(1)) + out, err := apis[2].Dht().FindProviders(ctx, p, options.Dht.NumProviders(1)) if err != nil { t.Fatal(err) } @@ -80,7 +80,7 @@ func TestDhtProvide(t *testing.T) { nds[0].Blockstore.Put(b) p := iface.IpfsPath(b.Cid()) - out, err := apis[2].Dht().FindProviders(ctx, p, options.Dht.WithNumProviders(1)) + out, err := apis[2].Dht().FindProviders(ctx, p, options.Dht.NumProviders(1)) if err != nil { t.Fatal(err) } @@ -96,7 +96,7 @@ func TestDhtProvide(t *testing.T) { t.Fatal(err) } - out, err = apis[2].Dht().FindProviders(ctx, p, options.Dht.WithNumProviders(1)) + out, err = apis[2].Dht().FindProviders(ctx, p, options.Dht.NumProviders(1)) if err != nil { t.Fatal(err) } diff --git a/core/coreapi/interface/options/dht.go b/core/coreapi/interface/options/dht.go index f989fa5e7..e13e16020 100644 --- a/core/coreapi/interface/options/dht.go +++ b/core/coreapi/interface/options/dht.go @@ -43,18 +43,18 @@ type dhtOpts struct{} var Dht dhtOpts -// WithRecursive is an option for Dht.Provide which specifies whether to provide +// Recursive is an option for Dht.Provide which specifies whether to provide // the given path recursively -func (dhtOpts) WithRecursive(recursive bool) DhtProvideOption { +func (dhtOpts) Recursive(recursive bool) DhtProvideOption { return func(settings *DhtProvideSettings) error { settings.Recursive = recursive return nil } } -// WithNumProviders is an option for Dht.FindProviders which specifies the +// NumProviders is an option for Dht.FindProviders which specifies the // number of peers to look for. Default is 20 -func (dhtOpts) WithNumProviders(numProviders int) DhtFindProvidersOption { +func (dhtOpts) NumProviders(numProviders int) DhtFindProvidersOption { return func(settings *DhtFindProvidersSettings) error { settings.NumProviders = numProviders return nil