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-kbucket
Commits
2bffeff6
Commit
2bffeff6
authored
Mar 20, 2020
by
Aarsh Shah
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
changes as per review
parent
872b78e8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
7 deletions
+7
-7
table_cleanup.go
table_cleanup.go
+7
-7
No files found.
table_cleanup.go
View file @
2bffeff6
...
...
@@ -31,9 +31,9 @@ func (rt *RoutingTable) cleanup() {
// add it back/mark it as active ONLY if it is still in the RT
// to avoid adding it back if it's been marked as dead
i
:=
rt
.
bucketIdForPeer
(
pinfo
.
Id
)
if
rt
.
buckets
[
i
]
.
getPeer
(
pinfo
.
Id
)
!=
nil
{
log
.
Info
f
(
"successfully validated missing peer=%s, marking it as active"
,
pinfo
.
Id
)
rt
.
addPeer
(
pinfo
.
Id
)
if
peer
:=
rt
.
buckets
[
i
]
.
getPeer
(
pinfo
.
Id
)
;
peer
!=
nil
{
log
.
Debug
f
(
"successfully validated missing peer=%s, marking it as active"
,
pinfo
.
Id
)
peer
.
State
=
PeerStateActive
}
rt
.
tabLock
.
Unlock
()
continue
...
...
@@ -46,7 +46,7 @@ func (rt *RoutingTable) cleanup() {
i
:=
rt
.
bucketIdForPeer
(
pinfo
.
Id
)
p
:=
rt
.
buckets
[
i
]
.
getPeer
(
pinfo
.
Id
)
if
p
!=
nil
&&
p
.
State
!=
PeerStateActive
{
log
.
Info
f
(
"failed to validate missing peer=%s, evicting it from the RT & requesting a replace"
,
pinfo
.
Id
)
log
.
Debug
f
(
"failed to validate missing peer=%s, evicting it from the RT & requesting a replace"
,
pinfo
.
Id
)
rt
.
removePeer
(
pinfo
.
Id
)
}
rt
.
tabLock
.
Unlock
()
...
...
@@ -74,7 +74,7 @@ func (rt *RoutingTable) startPeerReplacement() {
c
,
notEmpty
:=
rt
.
cplReplacementCache
.
pop
(
cpl
)
for
notEmpty
{
if
validatePeerF
(
c
)
{
log
.
Info
f
(
"successfully validated candidate=%s for peer=%s"
,
c
,
p
)
log
.
Debug
f
(
"successfully validated candidate=%s for peer=%s"
,
c
,
p
)
// TODO There is a race here. The peer could disconnect from us or stop supporting the DHT
// protocol after the validation which means we should not be adding it to the RT here.
// See https://github.com/libp2p/go-libp2p-kbucket/issues/60
...
...
@@ -83,12 +83,12 @@ func (rt *RoutingTable) startPeerReplacement() {
rt
.
tabLock
.
Unlock
()
break
}
log
.
Info
f
(
"failed to validated candidate=%s"
,
c
)
log
.
Debug
f
(
"failed to validated candidate=%s"
,
c
)
c
,
notEmpty
=
rt
.
cplReplacementCache
.
pop
(
cpl
)
}
if
!
notEmpty
{
log
.
Info
f
(
"failed to replace missing peer=%s as all candidates were invalid"
,
p
)
log
.
Debug
f
(
"failed to replace missing peer=%s as all candidates were invalid"
,
p
)
}
case
<-
rt
.
ctx
.
Done
()
:
return
...
...
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