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
a366d8b5
Unverified
Commit
a366d8b5
authored
Apr 09, 2020
by
Will Scott
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
address reviews
parent
07285de3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
9 deletions
+12
-9
dht_options.go
dht_options.go
+0
-2
dual/dual.go
dual/dual.go
+12
-7
No files found.
dht_options.go
View file @
a366d8b5
...
...
@@ -4,8 +4,6 @@ import (
"fmt"
"time"
"github.com/ipfs/go-ipns"
ds
"github.com/ipfs/go-datastore"
dssync
"github.com/ipfs/go-datastore/sync"
"github.com/ipfs/go-ipns"
...
...
dual/dual.go
View file @
a366d8b5
...
...
@@ -174,21 +174,26 @@ func (dht *DHT) PutValue(ctx context.Context, key string, val []byte, opts ...ro
// GetValue searches for the value corresponding to given Key.
func
(
d
*
DHT
)
GetValue
(
ctx
context
.
Context
,
key
string
,
opts
...
routing
.
Option
)
([]
byte
,
error
)
{
req
Ctx
,
cnc
l
:=
context
.
WithCancel
(
ctx
)
defer
cnc
l
()
lan
Ctx
,
c
a
nc
elLan
:=
context
.
WithCancel
(
ctx
)
defer
c
a
nc
elLan
()
var
lanVal
[]
byte
var
lanErr
error
var
lanWaiter
sync
.
WaitGroup
var
(
lanVal
[]
byte
lanErr
error
lanWaiter
sync
.
WaitGroup
)
lanWaiter
.
Add
(
1
)
go
func
()
{
defer
lanWaiter
.
Done
()
lanVal
,
lanErr
=
d
.
LAN
.
GetValue
(
req
Ctx
,
key
,
opts
...
)
lanVal
,
lanErr
=
d
.
LAN
.
GetValue
(
lan
Ctx
,
key
,
opts
...
)
}()
wanVal
,
wanErr
:=
d
.
WAN
.
GetValue
(
ctx
,
key
,
opts
...
)
if
wanErr
==
nil
{
cancelLan
()
}
lanWaiter
.
Wait
()
if
wanErr
!=
nil
{
lanWaiter
.
Wait
()
if
lanErr
!=
nil
{
return
nil
,
multierror
.
Append
(
wanErr
,
lanErr
)
.
ErrorOrNil
()
}
...
...
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