Commit 656fc75b authored by Łukasz Magiera's avatar Łukasz Magiera Committed by Steven Allen

coreapi: dht: refactor options after rebase

License: MIT
Signed-off-by: default avatarŁukasz Magiera <magik6k@gmail.com>
parent 22a12c2c
......@@ -19,14 +19,6 @@ type DhtAPI interface {
// given a key.
FindProviders(context.Context, Path, ...options.DhtFindProvidersOption) (<-chan pstore.PeerInfo, error)
// WithNumProviders is an option for FindProviders which specifies the
// number of peers to look for. Default is 20
WithNumProviders(numProviders int) options.DhtFindProvidersOption
// Provide announces to the network that you are providing given values
Provide(context.Context, Path, ...options.DhtProvideOption) error
// WithRecursive is an option for Provide which specifies whether to provide
// the given path recursively
WithRecursive(recursive bool) options.DhtProvideOption
}
......@@ -39,16 +39,22 @@ func DhtFindProvidersOptions(opts ...DhtFindProvidersOption) (*DhtFindProvidersS
return options, nil
}
type DhtOptions struct{}
type dhtOpts struct{}
func (api *DhtOptions) WithRecursive(recursive bool) DhtProvideOption {
var Dht dhtOpts
// WithRecursive is an option for Dht.Provide which specifies whether to provide
// the given path recursively
func (dhtOpts) WithRecursive(recursive bool) DhtProvideOption {
return func(settings *DhtProvideSettings) error {
settings.Recursive = recursive
return nil
}
}
func (api *DhtOptions) WithNumProviders(numProviders int) DhtFindProvidersOption {
// WithNumProviders is an option for Dht.FindProviders which specifies the
// number of peers to look for. Default is 20
func (dhtOpts) WithNumProviders(numProviders int) DhtFindProvidersOption {
return func(settings *DhtFindProvidersSettings) error {
settings.NumProviders = numProviders
return nil
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment