Skip to content

Commit

Permalink
always return info on exact matches in find peer
Browse files Browse the repository at this point in the history
This way, users who are actually trying to find a peer (not just nodes near a
key in the DHT) can find that peer, even if they aren't a DHT server and/or
aren't in anyone's routing table.

fixes #161
  • Loading branch information
Stebalien committed Jun 15, 2018
1 parent 2941d6e commit 2c8c47b
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,11 @@ func (dht *IpfsDHT) handleFindPeer(ctx context.Context, p peer.ID, pmes *pb.Mess
closest = []peer.ID{dht.self}
} else {
closest = dht.betterPeersToQuery(pmes, p, CloserPeerCount)
// If we have information on the requested peer, add that even
// if they're not in our routing table.
if len(dht.peerstore.Addrs(p)) > 0 {
closest = append(closest, p)
}
}

if closest == nil {
Expand Down

0 comments on commit 2c8c47b

Please sign in to comment.