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
ae40568b
Commit
ae40568b
authored
Oct 21, 2014
by
Juan Batiz-Benet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
this shouldn't connect quite yet.
parent
9f4bdde9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
23 deletions
+3
-23
dht.go
dht.go
+3
-23
No files found.
dht.go
View file @
ae40568b
...
...
@@ -16,7 +16,6 @@ import (
context
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/go.net/context"
ds
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore"
ma
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr"
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/goprotobuf/proto"
)
...
...
@@ -272,7 +271,7 @@ func (dht *IpfsDHT) getValueOrPeers(ctx context.Context, p peer.Peer,
// Perhaps we were given closer peers
var
peers
[]
peer
.
Peer
for
_
,
pb
:=
range
pmes
.
GetCloserPeers
()
{
pr
,
err
:=
dht
.
ensureConnectedToPeer
(
pb
)
pr
,
err
:=
dht
.
peerFromInfo
(
pb
)
if
err
!=
nil
{
log
.
Error
(
"%s"
,
err
)
continue
...
...
@@ -289,26 +288,6 @@ func (dht *IpfsDHT) getValueOrPeers(ctx context.Context, p peer.Peer,
return
nil
,
nil
,
u
.
ErrNotFound
}
func
(
dht
*
IpfsDHT
)
addPeer
(
pb
*
Message_Peer
)
(
peer
.
Peer
,
error
)
{
if
peer
.
ID
(
pb
.
GetId
())
.
Equal
(
dht
.
self
.
ID
())
{
return
nil
,
errors
.
New
(
"cannot add self as peer"
)
}
addr
,
err
:=
ma
.
NewMultiaddr
(
pb
.
GetAddr
())
if
err
!=
nil
{
return
nil
,
err
}
// check if we already have this peer.
pr
,
err
:=
dht
.
getPeer
(
peer
.
ID
(
pb
.
GetId
()))
if
err
!=
nil
{
return
nil
,
err
}
pr
.
AddAddress
(
addr
)
// idempotent
return
pr
,
nil
}
// getValueSingle simply performs the get value RPC with the given parameters
func
(
dht
*
IpfsDHT
)
getValueSingle
(
ctx
context
.
Context
,
p
peer
.
Peer
,
key
u
.
Key
,
level
int
)
(
*
Message
,
error
)
{
...
...
@@ -494,7 +473,8 @@ func (dht *IpfsDHT) peerFromInfo(pbp *Message_Peer) (peer.Peer, error) {
id
:=
peer
.
ID
(
pbp
.
GetId
())
// continue if it's ourselves
// bail out if it's ourselves
//TODO(jbenet) not sure this should be an error _here_
if
id
.
Equal
(
dht
.
self
.
ID
())
{
return
nil
,
errors
.
New
(
"found self"
)
}
...
...
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