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
79b69919
Commit
79b69919
authored
Dec 10, 2016
by
Jeromy Johnson
Committed by
GitHub
Dec 10, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #44 from vyzo/vyzo-fix-ticker-leak
fix ticker leak in BootstrapWithConfig
parents
68238335
7a4eb0f0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
7 deletions
+16
-7
dht_bootstrap.go
dht_bootstrap.go
+16
-7
No files found.
dht_bootstrap.go
View file @
79b69919
...
...
@@ -73,9 +73,14 @@ func (dht *IpfsDHT) Bootstrap(ctx context.Context) error {
// These parameters are configurable.
//
// BootstrapWithConfig returns a process, so the user can stop it.
func
(
dht
*
IpfsDHT
)
BootstrapWithConfig
(
config
BootstrapConfig
)
(
goprocess
.
Process
,
error
)
{
sig
:=
time
.
Tick
(
config
.
Period
)
return
dht
.
BootstrapOnSignal
(
config
,
sig
)
func
(
dht
*
IpfsDHT
)
BootstrapWithConfig
(
cfg
BootstrapConfig
)
(
goprocess
.
Process
,
error
)
{
if
cfg
.
Queries
<=
0
{
return
nil
,
fmt
.
Errorf
(
"invalid number of queries: %d"
,
cfg
.
Queries
)
}
proc
:=
periodicproc
.
Tick
(
cfg
.
Period
,
dht
.
bootstrapWorker
(
cfg
))
return
proc
,
nil
}
// SignalBootstrap ensures the dht routing table remains healthy as peers come and go.
...
...
@@ -93,7 +98,13 @@ func (dht *IpfsDHT) BootstrapOnSignal(cfg BootstrapConfig, signal <-chan time.Ti
return
nil
,
fmt
.
Errorf
(
"invalid signal: %v"
,
signal
)
}
proc
:=
periodicproc
.
Ticker
(
signal
,
func
(
worker
goprocess
.
Process
)
{
proc
:=
periodicproc
.
Ticker
(
signal
,
dht
.
bootstrapWorker
(
cfg
))
return
proc
,
nil
}
func
(
dht
*
IpfsDHT
)
bootstrapWorker
(
cfg
BootstrapConfig
)
func
(
worker
goprocess
.
Process
)
{
return
func
(
worker
goprocess
.
Process
)
{
// it would be useful to be able to send out signals of when we bootstrap, too...
// maybe this is a good case for whole module event pub/sub?
...
...
@@ -102,9 +113,7 @@ func (dht *IpfsDHT) BootstrapOnSignal(cfg BootstrapConfig, signal <-chan time.Ti
log
.
Warning
(
err
)
// A bootstrapping error is important to notice but not fatal.
}
})
return
proc
,
nil
}
}
// runBootstrap builds up list of peers by requesting random peer IDs
...
...
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