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
dms3
go-dms3
Commits
59f47cfd
Commit
59f47cfd
authored
Dec 09, 2014
by
Juan Batiz-Benet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dht: bootstrap query logging
parent
30eb8f21
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
4 deletions
+12
-4
routing/dht/dht.go
routing/dht/dht.go
+12
-4
No files found.
routing/dht/dht.go
View file @
59f47cfd
...
...
@@ -343,18 +343,26 @@ func (dht *IpfsDHT) PingRoutine(t time.Duration) {
// Bootstrap builds up list of peers by requesting random peer IDs
func
(
dht
*
IpfsDHT
)
Bootstrap
(
ctx
context
.
Context
,
queries
int
)
error
{
// bootstrap sequentially, as results will compound
for
i
:=
0
;
i
<
NumBootstrapQueries
;
i
++
{
randomID
:=
func
()
peer
.
ID
{
// 16 random bytes is not a valid peer id. it may be fine becuase
// the dht will rehash to its own keyspace anyway.
id
:=
make
([]
byte
,
16
)
rand
.
Read
(
id
)
pi
,
err
:=
dht
.
FindPeer
(
ctx
,
peer
.
ID
(
id
))
return
peer
.
ID
(
id
)
}
// bootstrap sequentially, as results will compound
for
i
:=
0
;
i
<
queries
;
i
++
{
id
:=
randomID
()
log
.
Debugf
(
"Bootstrapping query (%d/%d) to random ID: %s"
,
i
,
queries
,
id
)
p
,
err
:=
dht
.
FindPeer
(
ctx
,
id
)
if
err
==
routing
.
ErrNotFound
{
// this isn't an error. this is precisely what we expect.
}
else
if
err
!=
nil
{
log
.
Errorf
(
"Bootstrap peer error: %s"
,
err
)
}
else
{
// woah, we got a peer under a random id? it _cannot_ be valid.
log
.
Errorf
(
"dht seemingly found a peer at a random bootstrap id (%s)..."
,
p
i
)
log
.
Errorf
(
"dht seemingly found a peer at a random bootstrap id (%s)..."
,
p
)
}
}
return
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