Commit a1237733 authored by Juan Batiz-Benet's avatar Juan Batiz-Benet

dht: linting

parent 72dd3718
// package dht implements a distributed hash table that satisfies the ipfs routing
// Package 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.Errorf("Bootstrap peer error: %s", err)
}
err = dht.dialer.DialPeer(ctx, p)
if err != nil {
......
......@@ -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 {
......
......@@ -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) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment