clean up logic in getcloserpeers

This commit is contained in:
Jeromy 2017-03-03 23:31:12 -08:00
parent 7f280f40b4
commit fa1630a364

15
dht.go
View File

@ -312,19 +312,18 @@ func (dht *IpfsDHT) betterPeersToQuery(pmes *pb.Message, p peer.ID, count int) [
// no node? nil
if closer == nil {
log.Warning("no closer peers to send:", p)
return nil
}
// == to self? thats bad
for _, p := range closer {
if p == dht.self {
log.Debug("attempted to return self! this shouldn't happen...")
return nil
}
}
var filtered []peer.ID
for _, clp := range closer {
// == to self? thats bad
if p == dht.self {
log.Warning("attempted to return self! this shouldn't happen...")
return nil
}
// Dont send a peer back themselves
if p == clp {
continue