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
260e7a00
Commit
260e7a00
authored
Jun 11, 2016
by
Jeromy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sort peers outside of locks
License: MIT Signed-off-by:
Jeromy
<
why@ipfs.io
>
parent
44c87461
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
2 deletions
+3
-2
routing/kbucket/table.go
routing/kbucket/table.go
+3
-2
No files found.
routing/kbucket/table.go
View file @
260e7a00
...
...
@@ -144,10 +144,10 @@ func (rt *RoutingTable) NearestPeer(id ID) peer.ID {
// NearestPeers returns a list of the 'count' closest peers to the given ID
func
(
rt
*
RoutingTable
)
NearestPeers
(
id
ID
,
count
int
)
[]
peer
.
ID
{
rt
.
tabLock
.
RLock
()
defer
rt
.
tabLock
.
RUnlock
()
cpl
:=
commonPrefixLen
(
id
,
rt
.
local
)
rt
.
tabLock
.
RLock
()
// Get bucket at cpl index or last bucket
var
bucket
*
Bucket
if
cpl
>=
len
(
rt
.
Buckets
)
{
...
...
@@ -170,6 +170,7 @@ func (rt *RoutingTable) NearestPeers(id ID, count int) []peer.ID {
peerArr
=
copyPeersFromList
(
id
,
peerArr
,
plist
)
}
}
rt
.
tabLock
.
RUnlock
()
// Sort by distance to local peer
sort
.
Sort
(
peerArr
)
...
...
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