From 1fdcd5ae455b1ab7017da923316ae5f8a00af59b Mon Sep 17 00:00:00 2001 From: John Smith Date: Thu, 6 Oct 2022 12:39:30 -0400 Subject: [PATCH] wasm fixes --- veilid-core/src/routing_table/bucket_entry.rs | 30 ++++++++++++------- veilid-core/src/routing_table/find_nodes.rs | 3 -- veilid-core/src/rpc_processor/rpc_status.rs | 4 --- 3 files changed, 19 insertions(+), 18 deletions(-) diff --git a/veilid-core/src/routing_table/bucket_entry.rs b/veilid-core/src/routing_table/bucket_entry.rs index 25bb62e1..f3f665e8 100644 --- a/veilid-core/src/routing_table/bucket_entry.rs +++ b/veilid-core/src/routing_table/bucket_entry.rs @@ -439,14 +439,17 @@ impl BucketEntryInner { } } - fn needs_constant_ping(&self, cur_ts: u64, interval: u64) -> bool { - // If we have not either seen the node, nor asked it a question in the last 'interval' - // then we should ping it - let latest_contact_time = self - .peer_stats + /// Return the last time we either saw a node, or asked it a question + fn latest_contact_time(&self) -> Option { + self.peer_stats .rpc_stats .last_seen_ts - .max(self.peer_stats.rpc_stats.last_question); + .max(self.peer_stats.rpc_stats.last_question) + } + + fn needs_constant_ping(&self, cur_ts: u64, interval: u64) -> bool { + // If we have not either seen the node in the last 'interval' then we should ping it + let latest_contact_time = self.latest_contact_time(); match latest_contact_time { None => true, @@ -468,14 +471,19 @@ impl BucketEntryInner { return self.needs_constant_ping(cur_ts, KEEPALIVE_PING_INTERVAL_SECS as u64); } + // If we don't have node status for this node, then we should ping it to get some node status + for routing_domain in RoutingDomainSet::all() { + if self.has_node_info(routing_domain.into()) { + if self.node_status(routing_domain).is_none() { + return true; + } + } + } + match state { BucketEntryState::Reliable => { // If we are in a reliable state, we need a ping on an exponential scale - let latest_contact_time = self - .peer_stats - .rpc_stats - .last_seen_ts - .max(self.peer_stats.rpc_stats.last_question); + let latest_contact_time = self.latest_contact_time(); match latest_contact_time { None => { diff --git a/veilid-core/src/routing_table/find_nodes.rs b/veilid-core/src/routing_table/find_nodes.rs index feeb6f6f..4485b510 100644 --- a/veilid-core/src/routing_table/find_nodes.rs +++ b/veilid-core/src/routing_table/find_nodes.rs @@ -435,9 +435,6 @@ impl RoutingTable { // as we need to be able to use the relay for keepalives for all nat mappings let mut low_level_protocol_ports = mapped_port_info.low_level_protocol_ports.clone(); - info!("outbound_dif: {:?}", outbound_dif); - info!("low_level_protocol_ports: {:?}", low_level_protocol_ports); - let can_serve_as_relay = e .node_info(RoutingDomain::PublicInternet) .map(|n| { diff --git a/veilid-core/src/rpc_processor/rpc_status.rs b/veilid-core/src/rpc_processor/rpc_status.rs index 31f56a7f..079665d4 100644 --- a/veilid-core/src/rpc_processor/rpc_status.rs +++ b/veilid-core/src/rpc_processor/rpc_status.rs @@ -8,7 +8,6 @@ impl RPCProcessor { self, peer: NodeRef, ) -> Result>, RPCError> { - info!("ping to {:?}", peer); let routing_domain = match peer.best_routing_domain() { Some(rd) => rd, None => { @@ -44,7 +43,6 @@ impl RPCProcessor { }, _ => return Err(RPCError::invalid_format("not an answer")), }; - info!("qwer"); // Ensure the returned node status is the kind for the routing domain we asked for match routing_domain { @@ -64,8 +62,6 @@ impl RPCProcessor { } } - info!("zxzxv"); - // Update latest node status in routing table peer.update_node_status(status_a.node_status);