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
76f388b6
Commit
76f388b6
authored
Nov 05, 2019
by
Steven Allen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore(bootstrap): reduce indent level
parent
4eaf4293
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
14 deletions
+15
-14
dht_bootstrap.go
dht_bootstrap.go
+15
-14
No files found.
dht_bootstrap.go
View file @
76f388b6
...
...
@@ -102,22 +102,23 @@ func (dht *IpfsDHT) refreshBuckets(ctx context.Context) {
buckets
=
buckets
[
:
16
]
}
for
bucketID
,
bucket
:=
range
buckets
{
if
time
.
Since
(
bucket
.
RefreshedAt
())
>
dht
.
rtRefreshPeriod
{
// gen rand peer in the bucket
randPeerInBucket
:=
dht
.
routingTable
.
GenRandPeerID
(
bucketID
)
// walk to the generated peer
walkFnc
:=
func
(
c
context
.
Context
)
error
{
_
,
err
:=
dht
.
FindPeer
(
c
,
randPeerInBucket
)
if
err
==
routing
.
ErrNotFound
{
return
nil
}
return
err
if
time
.
Since
(
bucket
.
RefreshedAt
())
<=
dht
.
rtRefreshPeriod
{
continue
}
// gen rand peer in the bucket
randPeerInBucket
:=
dht
.
routingTable
.
GenRandPeerID
(
bucketID
)
// walk to the generated peer
walkFnc
:=
func
(
c
context
.
Context
)
error
{
_
,
err
:=
dht
.
FindPeer
(
c
,
randPeerInBucket
)
if
err
==
routing
.
ErrNotFound
{
return
nil
}
return
err
}
if
err
:=
doQuery
(
bucketID
,
randPeerInBucket
.
String
(),
walkFnc
);
err
!=
nil
{
logger
.
Warningf
(
"failed to do a random walk on bucket %d"
,
bucketID
)
}
if
err
:=
doQuery
(
bucketID
,
randPeerInBucket
.
String
(),
walkFnc
);
err
!=
nil
{
logger
.
Warningf
(
"failed to do a random walk on bucket %d"
,
bucketID
)
}
}
}
...
...
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