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
Commits
a1237733
Commit
a1237733
authored
Nov 20, 2014
by
Juan Batiz-Benet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dht: linting
parent
72dd3718
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
7 additions
and
3 deletions
+7
-3
routing/dht/dht.go
routing/dht/dht.go
+2
-2
routing/dht/pb/message.go
routing/dht/pb/message.go
+2
-0
routing/dht/routing.go
routing/dht/routing.go
+3
-1
No files found.
routing/dht/dht.go
View file @
a1237733
//
p
ackage dht implements a distributed hash table that satisfies the ipfs routing
//
P
ackage dht implements a distributed hash table that satisfies the ipfs routing
// interface. This DHT is modeled after kademlia with Coral and S/Kademlia modifications.
package
dht
...
...
@@ -583,7 +583,7 @@ func (dht *IpfsDHT) Bootstrap(ctx context.Context) {
rand
.
Read
(
id
)
p
,
err
:=
dht
.
FindPeer
(
ctx
,
peer
.
ID
(
id
))
if
err
!=
nil
{
log
.
Error
(
"Bootstrap peer error: %s"
,
err
)
log
.
Error
f
(
"Bootstrap peer error: %s"
,
err
)
}
err
=
dht
.
dialer
.
DialPeer
(
ctx
,
p
)
if
err
!=
nil
{
...
...
routing/dht/pb/message.go
View file @
a1237733
...
...
@@ -31,6 +31,8 @@ func peerToPBPeer(p peer.Peer) *Message_Peer {
return
pbp
}
// PeersToPBPeers converts a slice of Peers into a slice of *Message_Peers,
// ready to go out on the wire.
func
PeersToPBPeers
(
peers
[]
peer
.
Peer
)
[]
*
Message_Peer
{
pbpeers
:=
make
([]
*
Message_Peer
,
len
(
peers
))
for
i
,
p
:=
range
peers
{
...
...
routing/dht/routing.go
View file @
a1237733
...
...
@@ -125,6 +125,9 @@ func (dht *IpfsDHT) Provide(ctx context.Context, key u.Key) error {
return
nil
}
// FindProvidersAsync is the same thing as FindProviders, but returns a channel.
// Peers will be returned on the channel as soon as they are found, even before
// the search query completes.
func
(
dht
*
IpfsDHT
)
FindProvidersAsync
(
ctx
context
.
Context
,
key
u
.
Key
,
count
int
)
<-
chan
peer
.
Peer
{
log
.
Event
(
ctx
,
"findProviders"
,
&
key
)
peerOut
:=
make
(
chan
peer
.
Peer
,
count
)
...
...
@@ -199,7 +202,6 @@ func (dht *IpfsDHT) addPeerListAsync(ctx context.Context, k u.Key, peers []*pb.M
wg
.
Wait
()
}
// Find specific Peer
// FindPeer searches for a peer with given ID.
func
(
dht
*
IpfsDHT
)
FindPeer
(
ctx
context
.
Context
,
id
peer
.
ID
)
(
peer
.
Peer
,
error
)
{
...
...
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