generated from ipfs/ipfs-repository-template
-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
coreiface: deprecate DhtAPI in favor of RoutingAPI
- Loading branch information
Showing
8 changed files
with
242 additions
and
226 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,64 +1,26 @@ | ||
package options | ||
|
||
type DhtProvideSettings struct { | ||
Recursive bool | ||
} | ||
// Deprecated: use [RoutingProvideSettings] instead | ||
type DhtProvideSettings = RoutingProvideSettings | ||
|
||
type DhtFindProvidersSettings struct { | ||
NumProviders int | ||
} | ||
// Deprecated: use [RoutingFindProvidersSettings] instead | ||
type DhtFindProvidersSettings = RoutingFindProvidersSettings | ||
|
||
type ( | ||
DhtProvideOption func(*DhtProvideSettings) error | ||
DhtFindProvidersOption func(*DhtFindProvidersSettings) error | ||
) | ||
// Deprecated: use [RoutingProvideOption] instead | ||
type DhtProvideOption = RoutingProvideOption | ||
|
||
func DhtProvideOptions(opts ...DhtProvideOption) (*DhtProvideSettings, error) { | ||
options := &DhtProvideSettings{ | ||
Recursive: false, | ||
} | ||
// Deprecated: use [RoutingFindProvidersOption] instead | ||
type DhtFindProvidersOption = RoutingFindProvidersOption | ||
|
||
for _, opt := range opts { | ||
err := opt(options) | ||
if err != nil { | ||
return nil, err | ||
} | ||
} | ||
return options, nil | ||
// Deprecated: use [RoutingProvideOptions] instead | ||
func DhtProvideOptions(opts ...DhtProvideOption) (*DhtProvideSettings, error) { | ||
return RoutingProvideOptions(opts...) | ||
} | ||
|
||
// Deprecated: use [RoutingFindProvidersOptions] instead | ||
func DhtFindProvidersOptions(opts ...DhtFindProvidersOption) (*DhtFindProvidersSettings, error) { | ||
options := &DhtFindProvidersSettings{ | ||
NumProviders: 20, | ||
} | ||
|
||
for _, opt := range opts { | ||
err := opt(options) | ||
if err != nil { | ||
return nil, err | ||
} | ||
} | ||
return options, nil | ||
return RoutingFindProvidersOptions(opts...) | ||
} | ||
|
||
type dhtOpts struct{} | ||
|
||
var Dht dhtOpts | ||
|
||
// Recursive is an option for Dht.Provide which specifies whether to provide | ||
// the given path recursively | ||
func (dhtOpts) Recursive(recursive bool) DhtProvideOption { | ||
return func(settings *DhtProvideSettings) error { | ||
settings.Recursive = recursive | ||
return nil | ||
} | ||
} | ||
|
||
// NumProviders is an option for Dht.FindProviders which specifies the | ||
// number of peers to look for. Default is 20 | ||
func (dhtOpts) NumProviders(numProviders int) DhtFindProvidersOption { | ||
return func(settings *DhtFindProvidersSettings) error { | ||
settings.NumProviders = numProviders | ||
return nil | ||
} | ||
} | ||
// Deprecated: use [Routing] instead | ||
var Dht routingOpts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.