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
01750dc7
Commit
01750dc7
authored
Nov 03, 2014
by
Jeromy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
comment comment comment comment
parent
4b3769d4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
0 deletions
+6
-0
dht.go
dht.go
+6
-0
No files found.
dht.go
View file @
01750dc7
...
...
@@ -228,6 +228,8 @@ func (dht *IpfsDHT) putValueToNetwork(ctx context.Context, p peer.Peer,
return
nil
}
// putProvider sends a message to peer 'p' saying that the local node
// can provide the value of 'key'
func
(
dht
*
IpfsDHT
)
putProvider
(
ctx
context
.
Context
,
p
peer
.
Peer
,
key
string
)
error
{
pmes
:=
pb
.
NewMessage
(
pb
.
Message_ADD_PROVIDER
,
string
(
key
),
0
)
...
...
@@ -384,6 +386,7 @@ func (dht *IpfsDHT) FindLocal(id peer.ID) (peer.Peer, *kb.RoutingTable) {
return
nil
,
nil
}
// findPeerSingle asks peer 'p' if they know where the peer with id 'id' is
func
(
dht
*
IpfsDHT
)
findPeerSingle
(
ctx
context
.
Context
,
p
peer
.
Peer
,
id
peer
.
ID
,
level
int
)
(
*
pb
.
Message
,
error
)
{
pmes
:=
pb
.
NewMessage
(
pb
.
Message_FIND_NODE
,
string
(
id
),
level
)
return
dht
.
sendRequest
(
ctx
,
p
,
pmes
)
...
...
@@ -457,6 +460,7 @@ func (dht *IpfsDHT) betterPeersToQuery(pmes *pb.Message, count int) []peer.Peer
return
filtered
}
// getPeer searches the peerstore for a peer with the given peer ID
func
(
dht
*
IpfsDHT
)
getPeer
(
id
peer
.
ID
)
(
peer
.
Peer
,
error
)
{
p
,
err
:=
dht
.
peerstore
.
Get
(
id
)
if
err
!=
nil
{
...
...
@@ -467,6 +471,8 @@ func (dht *IpfsDHT) getPeer(id peer.ID) (peer.Peer, error) {
return
p
,
nil
}
// peerFromInfo returns a peer using info in the protobuf peer struct
// to lookup or create a peer
func
(
dht
*
IpfsDHT
)
peerFromInfo
(
pbp
*
pb
.
Message_Peer
)
(
peer
.
Peer
,
error
)
{
id
:=
peer
.
ID
(
pbp
.
GetId
())
...
...
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