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
666d5702
Commit
666d5702
authored
Jun 26, 2018
by
Steven Allen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
don't call PeerRemoved unless we're actually removing a peer
parent
d3f8fc63
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
7 deletions
+4
-7
table.go
table.go
+4
-7
No files found.
table.go
View file @
666d5702
...
...
@@ -89,12 +89,10 @@ func (rt *RoutingTable) Update(p peer.ID) {
// If this bucket is the rightmost bucket, and its full
// we need to split it and create a new bucket
if
bucketID
==
len
(
rt
.
Buckets
)
-
1
{
rt
.
PeerRemoved
(
rt
.
nextBucket
())
return
rt
.
nextBucket
()
}
else
{
// If the bucket cant split kick out least active node
rt
.
PeerRemoved
(
bucket
.
PopBack
())
return
}
}
}
...
...
@@ -117,19 +115,18 @@ func (rt *RoutingTable) Remove(p peer.ID) {
rt
.
PeerRemoved
(
p
)
}
func
(
rt
*
RoutingTable
)
nextBucket
()
peer
.
ID
{
func
(
rt
*
RoutingTable
)
nextBucket
()
{
bucket
:=
rt
.
Buckets
[
len
(
rt
.
Buckets
)
-
1
]
newBucket
:=
bucket
.
Split
(
len
(
rt
.
Buckets
)
-
1
,
rt
.
local
)
rt
.
Buckets
=
append
(
rt
.
Buckets
,
newBucket
)
if
newBucket
.
Len
()
>
rt
.
bucketsize
{
return
rt
.
nextBucket
()
rt
.
nextBucket
()
}
// If all elements were on left side of split...
if
bucket
.
Len
()
>
rt
.
bucketsize
{
r
eturn
bucket
.
PopBack
()
r
t
.
PeerRemoved
(
bucket
.
PopBack
()
)
}
return
""
}
// Find a specific peer by ID or 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