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
69392ff6
Commit
69392ff6
authored
Jan 22, 2019
by
Matt Joiner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove signal bootstrapping
Remove IpfsDHT.BootstrapOnSignal.
parent
3f37420d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
37 deletions
+5
-37
dht_bootstrap.go
dht_bootstrap.go
+0
-21
dht_test.go
dht_test.go
+5
-16
No files found.
dht_bootstrap.go
View file @
69392ff6
...
...
@@ -8,7 +8,6 @@ import (
u
"github.com/ipfs/go-ipfs-util"
goprocess
"github.com/jbenet/goprocess"
periodicproc
"github.com/jbenet/goprocess/periodic"
peer
"github.com/libp2p/go-libp2p-peer"
routing
"github.com/libp2p/go-libp2p-routing"
)
...
...
@@ -90,26 +89,6 @@ func (dht *IpfsDHT) BootstrapWithConfig(cfg BootstrapConfig) (goprocess.Process,
return
proc
,
nil
}
// SignalBootstrap ensures the dht routing table remains healthy as peers come and go.
// it builds up a list of peers by requesting random peer IDs. The Bootstrap
// process will run a number of queries each time, and run every time signal fires.
// These parameters are configurable.
//
// SignalBootstrap returns a process, so the user can stop it.
func
(
dht
*
IpfsDHT
)
BootstrapOnSignal
(
cfg
BootstrapConfig
,
signal
<-
chan
time
.
Time
)
(
goprocess
.
Process
,
error
)
{
if
cfg
.
Queries
<=
0
{
return
nil
,
fmt
.
Errorf
(
"invalid number of queries: %d"
,
cfg
.
Queries
)
}
if
signal
==
nil
{
return
nil
,
fmt
.
Errorf
(
"invalid signal: %v"
,
signal
)
}
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...
...
...
dht_test.go
View file @
69392ff6
...
...
@@ -679,23 +679,10 @@ func TestPeriodicBootstrap(t *testing.T) {
}
}()
signals
:=
[]
chan
time
.
Time
{}
var
cfg
BootstrapConfig
cfg
=
DefaultBootstrapConfig
cfg
.
Queries
=
5
// kick off periodic bootstrappers with instrumented signals.
for
_
,
dht
:=
range
dhts
{
s
:=
make
(
chan
time
.
Time
)
signals
=
append
(
signals
,
s
)
proc
,
err
:=
dht
.
BootstrapOnSignal
(
cfg
,
s
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
defer
proc
.
Close
()
}
t
.
Logf
(
"dhts are not connected. %d"
,
nDHTs
)
for
_
,
dht
:=
range
dhts
{
rtlen
:=
dht
.
routingTable
.
Size
()
...
...
@@ -721,9 +708,11 @@ func TestPeriodicBootstrap(t *testing.T) {
}
t
.
Logf
(
"bootstrapping them so they find each other. %d"
,
nDHTs
)
now
:=
time
.
Now
()
for
_
,
signal
:=
range
signals
{
go
func
(
s
chan
time
.
Time
)
{
s
<-
now
}(
signal
)
for
_
,
dht
:=
range
dhts
{
_
,
err
:=
dht
.
BootstrapWithConfig
(
cfg
)
if
err
!=
nil
{
t
.
Fatalf
(
"error bootstrapping a dht: %s"
,
err
)
}
}
// this is async, and we dont know when it's finished with one cycle, so keep checking
...
...
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