diff --git a/pkg/topology/kademlia/kademlia.go b/pkg/topology/kademlia/kademlia.go index 4cf23a0308f..5fe6429e65b 100644 --- a/pkg/topology/kademlia/kademlia.go +++ b/pkg/topology/kademlia/kademlia.go @@ -1018,23 +1018,12 @@ func closestPeer(peers *pslice.PSlice, addr swarm.Address, spf sanctionedPeerFun return closest, nil } -func isIn(a swarm.Address, addresses []p2p.Peer) bool { - for _, v := range addresses { - if v.Address.Equal(a) { - return true - } - } - return false -} - // ClosestPeer returns the closest peer to a given address. func (k *Kad) ClosestPeer(addr swarm.Address, includeSelf bool, skipPeers ...swarm.Address) (swarm.Address, error) { if k.connectedPeers.Length() == 0 { return swarm.Address{}, topology.ErrNotFound } - peers := k.p2p.Peers() - var peersToDisconnect []swarm.Address closest := swarm.ZeroAddress if includeSelf { @@ -1053,13 +1042,6 @@ func (k *Kad) ClosestPeer(addr swarm.Address, includeSelf bool, skipPeers ...swa closest = peer } - // kludge: hotfix for topology peer inconsistencies bug - if !isIn(peer, peers) { - a := swarm.NewAddress(peer.Bytes()) - peersToDisconnect = append(peersToDisconnect, a) - return false, false, nil - } - dcmp, err := swarm.DistanceCmp(addr.Bytes(), closest.Bytes(), peer.Bytes()) if err != nil { return false, false, err @@ -1084,10 +1066,6 @@ func (k *Kad) ClosestPeer(addr swarm.Address, includeSelf bool, skipPeers ...swa return swarm.Address{}, topology.ErrNotFound // only for light nodes } - for _, v := range peersToDisconnect { - k.Disconnected(p2p.Peer{Address: v}) - } - // check if self if closest.Equal(k.base) { return swarm.Address{}, topology.ErrWantSelf