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
6d107c70
Commit
6d107c70
authored
Jan 20, 2015
by
Juan Batiz-Benet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core/bootstrap: cleaned up bootstrapping
Moved it to its own package to isolate scope.
parent
8d7a7981
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
37 deletions
+29
-37
dht_bootstrap.go
dht_bootstrap.go
+29
-37
No files found.
dht_bootstrap.go
View file @
6d107c70
...
...
@@ -14,6 +14,7 @@ import (
context
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/go.net/context"
goprocess
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/goprocess"
periodicproc
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/goprocess/periodic"
)
// DefaultBootstrapQueries specifies how many queries to run,
...
...
@@ -54,9 +55,9 @@ const DefaultBootstrapTimeout = time.Duration(10 * time.Second)
// and connected to at least a few nodes.
//
// Like PeriodicBootstrap, Bootstrap returns a process, so the user can stop it.
func
(
dht
*
IpfsDHT
)
Bootstrap
()
(
goprocess
.
Process
,
error
)
{
func
(
dht
*
IpfsDHT
)
Bootstrap
(
ctx
context
.
Context
)
(
goprocess
.
Process
,
error
)
{
if
err
:=
dht
.
runBootstrap
(
dht
.
Context
()
,
DefaultBootstrapQueries
);
err
!=
nil
{
if
err
:=
dht
.
runBootstrap
(
ctx
,
DefaultBootstrapQueries
);
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -79,14 +80,7 @@ func (dht *IpfsDHT) BootstrapOnSignal(queries int, signal <-chan time.Time) (gop
return
nil
,
fmt
.
Errorf
(
"invalid signal: %v"
,
signal
)
}
proc
:=
goprocess
.
Go
(
func
(
worker
goprocess
.
Process
)
{
defer
log
.
Debug
(
"dht bootstrapper shutting down"
)
for
{
select
{
case
<-
worker
.
Closing
()
:
return
case
<-
signal
:
proc
:=
periodicproc
.
Ticker
(
signal
,
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?
...
...
@@ -113,8 +107,6 @@ func (dht *IpfsDHT) BootstrapOnSignal(queries int, signal <-chan time.Time) (gop
// ignore all errors with something like an ErrStreamDiscard. We should
// study what other systems do for ideas.
}
}
}
})
return
proc
,
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