coreapi: dht: refactor options after rebase
License: MIT Signed-off-by: Łukasz Magiera <magik6k@gmail.com> This commit was moved from ipfs/interface-go-ipfs-core@656fc75b6f65435e224b7bd1e392ee8daf90f9b2 This commit was moved from ipfs/boxo@2bef47921404e491af08c3f66fc8475f53526685
Łukasz Magiera committed
Jul 19, 2018 at 13:27 UTC
db3e060d61725dc22e97d7dab4ea69b3990f1170
2 files changed
+9
-11
core/coreiface/dht.go
-8
@@ -19,14 +19,6 @@ type DhtAPI interface {
19
// given a key.
20
FindProviders(context.Context, Path, ...options.DhtFindProvidersOption) (<-chan pstore.PeerInfo, error)
21
22
- // WithNumProviders is an option for FindProviders which specifies the
23
- // number of peers to look for. Default is 20
24
- WithNumProviders(numProviders int) options.DhtFindProvidersOption
25
-
22
// Provide announces to the network that you are providing given values
23
Provide(context.Context, Path, ...options.DhtProvideOption) error
28
-
29
- // WithRecursive is an option for Provide which specifies whether to provide
30
- // the given path recursively
31
- WithRecursive(recursive bool) options.DhtProvideOption
24
}
core/coreiface/options/dht.go
+9
-3
@@ -39,16 +39,22 @@ func DhtFindProvidersOptions(opts ...DhtFindProvidersOption) (*DhtFindProvidersS
39
return options, nil
40
}
41
42
-type DhtOptions struct{}
42
+type dhtOpts struct{}
43
44
-func (api *DhtOptions) WithRecursive(recursive bool) DhtProvideOption {
44
+var Dht dhtOpts
45
+
46
+// WithRecursive is an option for Dht.Provide which specifies whether to provide
47
+// the given path recursively
48
+func (dhtOpts) WithRecursive(recursive bool) DhtProvideOption {
49
return func(settings *DhtProvideSettings) error {
50
settings.Recursive = recursive
51
return nil
52
}
53
}
54
51
-func (api *DhtOptions) WithNumProviders(numProviders int) DhtFindProvidersOption {
55
+// WithNumProviders is an option for Dht.FindProviders which specifies the
56
+// number of peers to look for. Default is 20
57
+func (dhtOpts) WithNumProviders(numProviders int) DhtFindProvidersOption {
58
return func(settings *DhtFindProvidersSettings) error {
59
settings.NumProviders = numProviders
60
return nil