From da29d6747227fbb1cfbb74afb76346401729b3f5 Mon Sep 17 00:00:00 2001 From: Tiago Batista Cardoso Date: Thu, 22 Jan 2026 00:14:26 +0100 Subject: [PATCH] wip --- client-network/src/lib.rs | 18 +++++++----------- client-network/src/message_handling.rs | 5 ----- 2 files changed, 7 insertions(+), 16 deletions(-) diff --git a/client-network/src/lib.rs b/client-network/src/lib.rs index d8a7d65..de94f86 100644 --- a/client-network/src/lib.rs +++ b/client-network/src/lib.rs @@ -651,13 +651,9 @@ async fn quick_ping(addr: &SocketAddr, timeout_ms: u64, sd: &P2PSharedData) -> b let mut pending = sd.pending.lock().expect("couldnt lock pending map"); pending.insert(id, tx); } - if let Err(e) = sd.socket().send_to(&pingreq, addr) { - // remove pending on send failure - let mut pending = sd.pending.lock().expect("couldnt lock pending map"); - pending.remove(&id); - eprintln!("send_to failed: {}", e); - return false; - } + + sd.senders_ref() + .send_dispatch(pingreq, addr.to_string(), false, sd.messages_list()); let dur = Duration::from_millis(timeout_ms); let res = timeout(dur, rx).await; @@ -726,7 +722,7 @@ pub async fn get_socket_address( for addr in addresses { println!("trying address : {}", addr); - if quick_ping(&addr, 1000, sd).await { + if quick_ping(&addr, 10000, sd).await { return Some(addr); } @@ -752,9 +748,9 @@ pub async fn get_socket_address( // sd.messages_list().clone(), //); - if quick_ping(&addr, 1500, sd).await { - return Some(addr); - } + //if quick_ping(&addr, 1500, sd).await { + // return Some(addr); + //} } None diff --git a/client-network/src/message_handling.rs b/client-network/src/message_handling.rs index 5e12db2..8d5a426 100644 --- a/client-network/src/message_handling.rs +++ b/client-network/src/message_handling.rs @@ -78,11 +78,6 @@ pub fn handle_recevied_message( map.remove(&id) }; - if let Some(tx) = maybe_tx { - let _ = tx.send(Vec::new()); // ignore send error if receiver dropped - return; - } - let mut is_resp_to_server_handshake = false; if recevied_message[4] == HELLO {