dht: linting
Juan Batiz-Benet committed
Nov 20, 2014 at 10:46 UTC
a1237733c243d4b38c5c9bc4c127575d451d86eb
3 files changed
+7
-3
routing/dht/dht.go
+2
-2
@@ -1,4 +1,4 @@
1
-// package dht implements a distributed hash table that satisfies the ipfs routing
1
+// Package dht implements a distributed hash table that satisfies the ipfs routing
2
// interface. This DHT is modeled after kademlia with Coral and S/Kademlia modifications.
3
package dht
4
@@ -583,7 +583,7 @@ func (dht *IpfsDHT) Bootstrap(ctx context.Context) {
583
rand.Read(id)
584
p, err := dht.FindPeer(ctx, peer.ID(id))
585
if err != nil {
586
- log.Error("Bootstrap peer error: %s", err)
586
+ log.Errorf("Bootstrap peer error: %s", err)
587
}
588
err = dht.dialer.DialPeer(ctx, p)
589
if err != nil {
routing/dht/pb/message.go
+2
@@ -31,6 +31,8 @@ func peerToPBPeer(p peer.Peer) *Message_Peer {
31
return pbp
32
}
33
34
+// PeersToPBPeers converts a slice of Peers into a slice of *Message_Peers,
35
+// ready to go out on the wire.
36
func PeersToPBPeers(peers []peer.Peer) []*Message_Peer {
37
pbpeers := make([]*Message_Peer, len(peers))
38
for i, p := range peers {
routing/dht/routing.go
+3
-1
@@ -125,6 +125,9 @@ func (dht *IpfsDHT) Provide(ctx context.Context, key u.Key) error {
125
return nil
126
}
127
128
+// FindProvidersAsync is the same thing as FindProviders, but returns a channel.
129
+// Peers will be returned on the channel as soon as they are found, even before
130
+// the search query completes.
131
func (dht *IpfsDHT) FindProvidersAsync(ctx context.Context, key u.Key, count int) <-chan peer.Peer {
132
log.Event(ctx, "findProviders", &key)
133
peerOut := make(chan peer.Peer, count)
@@ -199,7 +202,6 @@ func (dht *IpfsDHT) addPeerListAsync(ctx context.Context, k u.Key, peers []*pb.M
202
wg.Wait()
203
}
204
202
-// Find specific Peer
205
// FindPeer searches for a peer with given ID.
206
func (dht *IpfsDHT) FindPeer(ctx context.Context, id peer.ID) (peer.Peer, error) {
207