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
d49387f3
Commit
d49387f3
authored
Dec 11, 2014
by
Jeromy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
changes from PR
parent
8ce74b81
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
16 deletions
+16
-16
dht/routing.go
dht/routing.go
+16
-16
No files found.
dht/routing.go
View file @
d49387f3
...
...
@@ -148,15 +148,17 @@ func (dht *IpfsDHT) findProvidersAsyncRoutine(ctx context.Context, key u.Key, co
ps
:=
newPeerSet
()
provs
:=
dht
.
providers
.
GetProviders
(
ctx
,
key
)
for
_
,
p
:=
range
provs
{
count
--
// NOTE: assuming that this list of peers is unique
ps
.
Add
(
p
)
select
{
case
peerOut
<-
p
:
case
<-
ctx
.
Done
()
:
return
if
ps
.
AddIfSmallerThan
(
p
,
count
)
{
select
{
case
peerOut
<-
p
:
case
<-
ctx
.
Done
()
:
return
}
}
if
count
<=
0
{
// If we have enough peers locally, dont bother with remote RPC
if
ps
.
Size
()
>=
count
{
return
}
}
...
...
@@ -178,16 +180,14 @@ 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
.
Contains
(
prov
)
{
continue
}
select
{
case
peerOut
<-
prov
:
case
<-
ctx
.
Done
()
:
log
.
Error
(
"Context timed out sending more providers"
)
return
nil
,
ctx
.
Err
()
if
ps
.
AddIfSmallerThan
(
prov
,
count
)
{
select
{
case
peerOut
<-
prov
:
case
<-
ctx
.
Done
()
:
log
.
Error
(
"Context timed out sending more providers"
)
return
nil
,
ctx
.
Err
()
}
}
ps
.
Add
(
prov
)
if
ps
.
Size
()
>=
count
{
return
&
dhtQueryResult
{
success
:
true
},
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