Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
interface-go-dms3-core
Commits
656fc75b
Commit
656fc75b
authored
Jul 19, 2018
by
Łukasz Magiera
Committed by
Steven Allen
Sep 10, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
coreapi: dht: refactor options after rebase
License: MIT Signed-off-by:
Łukasz Magiera
<
magik6k@gmail.com
>
parent
22a12c2c
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
11 deletions
+9
-11
dht.go
dht.go
+0
-8
options/dht.go
options/dht.go
+9
-3
No files found.
dht.go
View file @
656fc75b
...
@@ -19,14 +19,6 @@ type DhtAPI interface {
...
@@ -19,14 +19,6 @@ type DhtAPI interface {
// given a key.
// given a key.
FindProviders
(
context
.
Context
,
Path
,
...
options
.
DhtFindProvidersOption
)
(
<-
chan
pstore
.
PeerInfo
,
error
)
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 announces to the network that you are providing given values
Provide
(
context
.
Context
,
Path
,
...
options
.
DhtProvideOption
)
error
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
}
}
options/dht.go
View file @
656fc75b
...
@@ -39,16 +39,22 @@ func DhtFindProvidersOptions(opts ...DhtFindProvidersOption) (*DhtFindProvidersS
...
@@ -39,16 +39,22 @@ func DhtFindProvidersOptions(opts ...DhtFindProvidersOption) (*DhtFindProvidersS
return
options
,
nil
return
options
,
nil
}
}
type
D
htOpt
ion
s
struct
{}
type
d
htOpts
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
{
return
func
(
settings
*
DhtProvideSettings
)
error
{
settings
.
Recursive
=
recursive
settings
.
Recursive
=
recursive
return
nil
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
{
return
func
(
settings
*
DhtFindProvidersSettings
)
error
{
settings
.
NumProviders
=
numProviders
settings
.
NumProviders
=
numProviders
return
nil
return
nil
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment