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
9055bd69
Commit
9055bd69
authored
Jan 24, 2019
by
Matt Joiner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Include BootstrapOnce
parent
c6e2fde1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
4 deletions
+10
-4
dht_bootstrap.go
dht_bootstrap.go
+9
-0
dht_test.go
dht_test.go
+1
-4
No files found.
dht_bootstrap.go
View file @
9055bd69
...
...
@@ -65,6 +65,15 @@ func (dht *IpfsDHT) BootstrapWithConfig(ctx context.Context, cfg BootstrapConfig
return
nil
}
// This is a synchronous bootstrap. cfg.Queries queries will run each with a
// timeout of cfg.Timeout. cfg.Period is not used.
func
(
dht
*
IpfsDHT
)
BootstrapOnce
(
ctx
context
.
Context
,
cfg
BootstrapConfig
)
error
{
if
cfg
.
Queries
<=
0
{
return
fmt
.
Errorf
(
"invalid number of queries: %d"
,
cfg
.
Queries
)
}
return
dht
.
runBootstrap
(
ctx
,
cfg
)
}
func
newRandomPeerId
()
peer
.
ID
{
id
:=
make
([]
byte
,
32
)
// SHA256 is the default. TODO: Use a more canonical way to generate random IDs.
rand
.
Read
(
id
)
...
...
dht_test.go
View file @
9055bd69
...
...
@@ -709,10 +709,7 @@ func TestPeriodicBootstrap(t *testing.T) {
t
.
Logf
(
"bootstrapping them so they find each other. %d"
,
nDHTs
)
for
_
,
dht
:=
range
dhts
{
err := dht.BootstrapWithConfig(ctx, cfg)
if err != nil {
t.Fatalf("error bootstrapping a dht: %s", err)
}
go
dht
.
BootstrapOnce
(
ctx
,
cfg
)
}
// 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