give up
This commit is contained in:
@@ -522,7 +522,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");
|
||||||
|
|
||||||
@@ -542,7 +542,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)
|
||||||
}
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
@@ -602,7 +602,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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -74,6 +74,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)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user