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
950f56ee
Commit
950f56ee
authored
Sep 16, 2014
by
Juan Batiz-Benet
Committed by
Brian Tiger Chow
Sep 22, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Peerstore -- threadsafe collection
this will later have persistent storage, but no need yet
parent
fbdc7279
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
13 deletions
+20
-13
dht/dht.go
dht/dht.go
+20
-13
No files found.
dht/dht.go
View file @
950f56ee
...
...
@@ -194,25 +194,27 @@ func (dht *IpfsDHT) getValueOrPeers(ctx context.Context, p *peer.Peer,
return
nil
,
nil
,
err
}
if
pmes
.
GetSuccess
()
{
if
pmes
.
Value
==
nil
{
// We were given provider[s]
val
,
err
:=
dht
.
getFromPeerList
(
key
,
timeout
,
pmes
.
GetPeers
(),
level
)
if
err
!=
nil
{
return
nil
,
nil
,
err
}
return
val
,
nil
,
nil
}
if
value
:=
pmes
.
GetValue
();
value
!=
nil
{
// Success! We were given the value
return
pmes
.
GetV
alue
()
,
nil
,
nil
return
v
alue
,
nil
,
nil
}
// We were given a closer node
// TODO decide on providers. This probably shouldn't be happening.
// if prv := pmes.GetProviderPeers(); prv != nil && len(prv) > 0 {
// val, err := dht.getFromPeerList(key, timeout,, level)
// if err != nil {
// return nil, nil, err
// }
// return val, nil, nil
// }
// Perhaps we were given closer peers
var
peers
[]
*
peer
.
Peer
for
_
,
pb
:=
range
pmes
.
GetPeers
()
{
for
_
,
pb
:=
range
pmes
.
Get
Closer
Peers
()
{
if
peer
.
ID
(
pb
.
GetId
())
.
Equal
(
dht
.
self
.
ID
)
{
continue
}
addr
,
err
:=
ma
.
NewMultiaddr
(
pb
.
GetAddr
())
if
err
!=
nil
{
u
.
PErr
(
"%v
\n
"
,
err
.
Error
())
...
...
@@ -227,7 +229,12 @@ func (dht *IpfsDHT) getValueOrPeers(ctx context.Context, p *peer.Peer,
peers
=
append
(
peers
,
np
)
}
return
nil
,
peers
,
nil
if
len
(
peers
)
>
0
{
return
nil
,
peers
,
nil
}
return
nil
,
nil
,
errors
.
New
(
"NotFound. did not get value or closer peers."
)
}
// getValueSingle simply performs the get value RPC with the given parameters
...
...
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