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
7a658d1e
Commit
7a658d1e
authored
Dec 08, 2016
by
vyzo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix ticker leak in BootstrapWithConfig
parent
68238335
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
3 deletions
+17
-3
dht_bootstrap.go
dht_bootstrap.go
+17
-3
No files found.
dht_bootstrap.go
View file @
7a658d1e
...
...
@@ -73,9 +73,23 @@ 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
,
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?
ctx
:=
dht
.
Context
()
if
err
:=
dht
.
runBootstrap
(
ctx
,
cfg
);
err
!=
nil
{
log
.
Warning
(
err
)
// A bootstrapping error is important to notice but not fatal.
}
})
return
proc
,
nil
}
// SignalBootstrap ensures the dht routing table remains healthy as peers come and go.
...
...
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