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-kad-dht
Commits
993399a1
Commit
993399a1
authored
Jul 10, 2018
by
Steven Allen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
don't treat a canceled context as a successful query
fixes #172
parent
86e37ca3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
10 deletions
+11
-10
routing.go
routing.go
+11
-10
No files found.
routing.go
View file @
993399a1
...
...
@@ -120,8 +120,6 @@ func (dht *IpfsDHT) GetValue(ctx context.Context, key string, opts ...ropts.Opti
}
eip
.
Done
()
}()
ctx
,
cancel
:=
context
.
WithTimeout
(
ctx
,
time
.
Minute
)
defer
cancel
()
var
cfg
ropts
.
Options
if
err
:=
cfg
.
Apply
(
opts
...
);
err
!=
nil
{
...
...
@@ -280,15 +278,18 @@ func (dht *IpfsDHT) GetValues(ctx context.Context, key string, nvals int) (_ []R
return
res
,
nil
})
// run it!
_
,
err
=
query
.
Run
(
ctx
,
rtp
)
if
len
(
vals
)
==
0
{
if
err
!=
nil
{
return
nil
,
err
}
}
reqCtx
,
cancel
:=
context
.
WithTimeout
(
ctx
,
time
.
Minute
)
defer
cancel
()
_
,
err
=
query
.
Run
(
reqCtx
,
rtp
)
return
vals
,
nil
// We do have some values but we either ran out of peers to query or
// searched for a whole minute.
//
// We'll just call this a success.
if
len
(
vals
)
>
0
&&
(
err
==
routing
.
ErrNotFound
||
reqCtx
.
Err
()
==
context
.
DeadlineExceeded
)
{
err
=
nil
}
return
vals
,
err
}
// Provider abstraction for indirect stores.
...
...
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