This commit is contained in:
Tiago Batista Cardoso
2026-01-22 00:30:17 +01:00
parent da29d67472
commit 5899a275a2
2 changed files with 4 additions and 3 deletions

View File

@@ -642,7 +642,7 @@ fn parse_pack(s: &str) -> Option<[u8; 6]> {
} }
async fn quick_ping(addr: &SocketAddr, timeout_ms: u64, sd: &P2PSharedData) -> bool { async fn quick_ping(addr: &SocketAddr, timeout_ms: u64, sd: &P2PSharedData) -> bool {
let id = generate_id(); let id = 42069;
let pingreq = construct_message(PING, Vec::new(), id, &sd.shared_cryptopair) let pingreq = construct_message(PING, Vec::new(), id, &sd.shared_cryptopair)
.expect("couldn't build ping message"); .expect("couldn't build ping message");
@@ -662,7 +662,7 @@ async fn quick_ping(addr: &SocketAddr, timeout_ms: u64, sd: &P2PSharedData) -> b
let mut pending = sd.pending.lock().expect("couldn't lock pending map"); let mut pending = sd.pending.lock().expect("couldn't lock pending map");
pending.remove(&id); pending.remove(&id);
matches!(res, Ok(Ok(_))) matches!(res, Ok(Ok(_))) && !pending.contains_key(&id)
} }
/// ///
@@ -722,7 +722,7 @@ pub async fn get_socket_address(
for addr in addresses { for addr in addresses {
println!("trying address : {}", addr); println!("trying address : {}", addr);
if quick_ping(&addr, 10000, sd).await { if quick_ping(&addr, 20000, sd).await {
return Some(addr); return Some(addr);
} }

View File

@@ -75,6 +75,7 @@ pub fn handle_recevied_message(
let maybe_tx = { let maybe_tx = {
let mut map = pending.lock().expect("couldnt lock pending map"); let mut map = pending.lock().expect("couldnt lock pending map");
println!("trying to remove : {}", id);
map.remove(&id) map.remove(&id)
}; };