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-routing
Commits
352eec31
Commit
352eec31
authored
Dec 16, 2014
by
Jeromy
Committed by
Juan Batiz-Benet
Dec 17, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor peerSet
parent
e838fd78
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
4 deletions
+4
-4
dht/routing.go
dht/routing.go
+4
-4
No files found.
dht/routing.go
View file @
352eec31
...
...
@@ -141,11 +141,11 @@ func (dht *IpfsDHT) FindProvidersAsync(ctx context.Context, key u.Key, count int
func
(
dht
*
IpfsDHT
)
findProvidersAsyncRoutine
(
ctx
context
.
Context
,
key
u
.
Key
,
count
int
,
peerOut
chan
peer
.
Peer
)
{
defer
close
(
peerOut
)
ps
:=
pset
.
NewPeerSet
()
ps
:=
pset
.
New
Limited
PeerSet
(
count
)
provs
:=
dht
.
providers
.
GetProviders
(
ctx
,
key
)
for
_
,
p
:=
range
provs
{
// NOTE: assuming that this list of peers is unique
if
ps
.
AddIfSmallerThan
(
p
,
count
)
{
if
ps
.
TryAdd
(
p
)
{
select
{
case
peerOut
<-
p
:
case
<-
ctx
.
Done
()
:
...
...
@@ -176,7 +176,7 @@ func (dht *IpfsDHT) findProvidersAsyncRoutine(ctx context.Context, key u.Key, co
// Add unique providers from request, up to 'count'
for
_
,
prov
:=
range
provs
{
if
ps
.
AddIfSmallerThan
(
prov
,
count
)
{
if
ps
.
TryAdd
(
prov
)
{
select
{
case
peerOut
<-
prov
:
case
<-
ctx
.
Done
()
:
...
...
@@ -226,7 +226,7 @@ func (dht *IpfsDHT) addPeerListAsync(ctx context.Context, k u.Key, peers []*pb.M
}
dht
.
providers
.
AddProvider
(
k
,
p
)
if
ps
.
AddIfSmallerThan
(
p
,
count
)
{
if
ps
.
TryAdd
(
p
)
{
select
{
case
out
<-
p
:
case
<-
ctx
.
Done
()
:
...
...
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