From bdb31cc1148d8123e004161aeda6aa25c4ce083b Mon Sep 17 00:00:00 2001 From: Simon-Pierre Vivier Date: Wed, 16 Oct 2024 15:18:47 -0400 Subject: [PATCH] added randomness to peer selection (#3123) --- waku/node/peer_manager/peer_manager.nim | 2 ++ 1 file changed, 2 insertions(+) diff --git a/waku/node/peer_manager/peer_manager.nim b/waku/node/peer_manager/peer_manager.nim index df4958b87..cb728f3ee 100644 --- a/waku/node/peer_manager/peer_manager.nim +++ b/waku/node/peer_manager/peer_manager.nim @@ -227,6 +227,8 @@ proc selectPeer*( if shard.isSome(): peers.keepItIf((it.enr.isSome() and it.enr.get().containsShard(shard.get()))) + shuffle(peers) + # No criteria for selecting a peer for WakuRelay, random one if proto == WakuRelayCodec: # TODO: proper heuristic here that compares peer scores and selects "best" one. For now the first peer for the given protocol is returned