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
p2p
go-p2p-kad-dht
Commits
a33b0b97
Commit
a33b0b97
authored
Nov 05, 2019
by
Raúl Kripalani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
inline struct for RoutingTable config.
parent
4bc0480e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
12 deletions
+14
-12
dht.go
dht.go
+3
-3
opts/options.go
opts/options.go
+11
-9
No files found.
dht.go
View file @
a33b0b97
...
...
@@ -91,9 +91,9 @@ func New(ctx context.Context, h host.Host, options ...opts.Option) (*IpfsDHT, er
return
nil
,
err
}
dht
:=
makeDHT
(
ctx
,
h
,
cfg
.
Datastore
,
cfg
.
Protocols
,
cfg
.
BucketSize
)
dht
.
autoRefresh
=
cfg
.
AutoRefresh
dht
.
rtRefreshPeriod
=
cfg
.
RoutingTableRefreshPeriod
dht
.
rtRefreshQueryTimeout
=
cfg
.
RoutingTableRefreshQueryTimeout
dht
.
autoRefresh
=
cfg
.
RoutingTable
.
AutoRefresh
dht
.
rtRefreshPeriod
=
cfg
.
RoutingTable
.
RefreshPeriod
dht
.
rtRefreshQueryTimeout
=
cfg
.
RoutingTable
.
RefreshQueryTimeout
// register for network notifs.
dht
.
host
.
Network
()
.
Notify
((
*
netNotifiee
)(
dht
))
...
...
opts/options.go
View file @
a33b0b97
...
...
@@ -27,9 +27,11 @@ type Options struct {
Protocols
[]
protocol
.
ID
BucketSize
int
RoutingTableRefreshQueryTimeout
time
.
Duration
RoutingTableRefreshPeriod
time
.
Duration
AutoRefresh
bool
RoutingTable
struct
{
RefreshQueryTimeout
time
.
Duration
RefreshPeriod
time
.
Duration
AutoRefresh
bool
}
}
// Apply applies the given options to this Option
...
...
@@ -54,9 +56,9 @@ var Defaults = func(o *Options) error {
o
.
Datastore
=
dssync
.
MutexWrap
(
ds
.
NewMapDatastore
())
o
.
Protocols
=
DefaultProtocols
o
.
RoutingTableRefreshQueryTimeout
=
10
*
time
.
Second
o
.
RoutingTableRefreshPeriod
=
1
*
time
.
Hour
o
.
AutoRefresh
=
true
o
.
RoutingTable
.
RefreshQueryTimeout
=
10
*
time
.
Second
o
.
RoutingTable
.
RefreshPeriod
=
1
*
time
.
Hour
o
.
RoutingTable
.
AutoRefresh
=
true
return
nil
}
...
...
@@ -65,7 +67,7 @@ var Defaults = func(o *Options) error {
// queries.
func
RoutingTableRefreshQueryTimeout
(
timeout
time
.
Duration
)
Option
{
return
func
(
o
*
Options
)
error
{
o
.
RoutingTableRefreshQueryTimeout
=
timeout
o
.
RoutingTable
.
RefreshQueryTimeout
=
timeout
return
nil
}
}
...
...
@@ -78,7 +80,7 @@ func RoutingTableRefreshQueryTimeout(timeout time.Duration) Option {
// the last refresh period.
func
RoutingTableRefreshPeriod
(
period
time
.
Duration
)
Option
{
return
func
(
o
*
Options
)
error
{
o
.
RoutingTableRefreshPeriod
=
period
o
.
RoutingTable
.
RefreshPeriod
=
period
return
nil
}
}
...
...
@@ -156,7 +158,7 @@ func BucketSize(bucketSize int) Option {
// nor when the routing table size goes below the minimum threshold.
func
DisableAutoRefresh
()
Option
{
return
func
(
o
*
Options
)
error
{
o
.
AutoRefresh
=
false
o
.
RoutingTable
.
AutoRefresh
=
false
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