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
18099abb
Commit
18099abb
authored
Nov 13, 2015
by
Jeromy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
if bucket doesnt have enough peers, grab more elsewhere
License: MIT Signed-off-by:
Jeromy
<
jeromyj@gmail.com
>
parent
5e99be98
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
9 deletions
+4
-9
routing/kbucket/sorting.go
routing/kbucket/sorting.go
+0
-4
routing/kbucket/table.go
routing/kbucket/table.go
+4
-5
No files found.
routing/kbucket/sorting.go
View file @
18099abb
...
...
@@ -32,10 +32,6 @@ func copyPeersFromList(target ID, peerArr peerSorterArr, peerList *list.List) pe
distance
:
xor
(
target
,
pID
),
}
peerArr
=
append
(
peerArr
,
&
pd
)
if
e
==
nil
{
log
.
Debug
(
"list element was nil"
)
return
peerArr
}
}
return
peerArr
}
...
...
routing/kbucket/table.go
View file @
18099abb
...
...
@@ -155,9 +155,10 @@ func (rt *RoutingTable) NearestPeers(id ID, count int) []peer.ID {
bucket
=
rt
.
Buckets
[
cpl
]
var
peerArr
peerSorterArr
if
bucket
.
Len
()
==
0
{
// In the case of an unusual split, one bucket may be empty.
// if this happens, search both surrounding buckets for nearest peer
peerArr
=
copyPeersFromList
(
id
,
peerArr
,
bucket
.
list
)
if
len
(
peerArr
)
<
count
{
// In the case of an unusual split, one bucket may be short or empty.
// if this happens, search both surrounding buckets for nearby peers
if
cpl
>
0
{
plist
:=
rt
.
Buckets
[
cpl
-
1
]
.
list
peerArr
=
copyPeersFromList
(
id
,
peerArr
,
plist
)
...
...
@@ -167,8 +168,6 @@ func (rt *RoutingTable) NearestPeers(id ID, count int) []peer.ID {
plist
:=
rt
.
Buckets
[
cpl
+
1
]
.
list
peerArr
=
copyPeersFromList
(
id
,
peerArr
,
plist
)
}
}
else
{
peerArr
=
copyPeersFromList
(
id
,
peerArr
,
bucket
.
list
)
}
// Sort by distance to local peer
...
...
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