Skip to content

Commit c4ebaa5

Browse files
authored
fix(kademlia): closest peer must first detect if the peer should be s… (#4985)
1 parent cda61e5 commit c4ebaa5

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

pkg/topology/kademlia/kademlia.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1283,15 +1283,14 @@ func (k *Kad) ClosestPeer(addr swarm.Address, includeSelf bool, filter topology.
12831283

12841284
// iterate starting from bin 0 to the maximum bin
12851285
err := k.EachConnectedPeerRev(func(peer swarm.Address, bin uint8) (bool, bool, error) {
1286+
if swarm.ContainsAddress(skipPeers, peer) {
1287+
return false, false, nil
1288+
}
12861289

12871290
if bin > prox && !closest.IsZero() {
12881291
return true, false, nil
12891292
}
12901293

1291-
if swarm.ContainsAddress(skipPeers, peer) {
1292-
return false, false, nil
1293-
}
1294-
12951294
if closest.IsZero() {
12961295
closest = peer
12971296
return false, false, nil

0 commit comments

Comments
 (0)