From 19e68f7f7594dc9f3944ae8aefbd51e047d98de0 Mon Sep 17 00:00:00 2001 From: Luke Parker Date: Tue, 23 Apr 2024 12:04:30 -0400 Subject: [PATCH] Correct selection of to-try peers to prevent infinite loops when to-try < target --- coordinator/src/p2p.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/coordinator/src/p2p.rs b/coordinator/src/p2p.rs index f8a3f952..d31ccaf2 100644 --- a/coordinator/src/p2p.rs +++ b/coordinator/src/p2p.rs @@ -493,8 +493,8 @@ impl LibP2p { continue; } - // Randomly select up to 5 - for _ in 0 .. 5 { + // Randomly select up to 2 * TARGET_PEERS + for _ in 0 .. (2 * TARGET_PEERS) { if !nodes.is_empty() { let to_connect = nodes.swap_remove( usize::try_from(OsRng.next_u64() % u64::try_from(nodes.len()).unwrap())