From cc7202e0bf74f9039763bb1d73d686998001709f Mon Sep 17 00:00:00 2001 From: Luke Parker Date: Tue, 23 Apr 2024 12:38:59 -0400 Subject: [PATCH] Correct recv to try_recv when exhausting channel --- 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 d31ccaf2..92355295 100644 --- a/coordinator/src/p2p.rs +++ b/coordinator/src/p2p.rs @@ -370,7 +370,7 @@ impl LibP2p { IdentTopic::new(format!("{LIBP2P_TOPIC}-{}", hex::encode(set.encode()))) } - // TODO: If a network has less than TARGET_PEERS, this will cause retried ad infinitum + // TODO: If a network has less than TARGET_PEERS, this will cause retries ad infinitum const TARGET_PEERS: usize = 8; // The addrs we're currently dialing, and the networks associated with them @@ -472,7 +472,7 @@ impl LibP2p { // Drain the chainnel, de-duplicating any networks in it let mut connect_to_network_networks = HashSet::new(); - while let Some(network) = connect_to_network_recv.recv().await { + while let Ok(network) = connect_to_network_recv.try_recv() { connect_to_network_networks.insert(network); } for network in connect_to_network_networks {