From 9d0479fc45c77e7673f45a17da7e68737183da01 Mon Sep 17 00:00:00 2001 From: John Smith Date: Wed, 19 Jul 2023 12:32:03 -0400 Subject: [PATCH] better peer minimum refresh --- veilid-core/src/routing_table/bucket_entry.rs | 16 +++++----------- .../src/routing_table/routing_table_inner.rs | 16 +++++++++++++--- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/veilid-core/src/routing_table/bucket_entry.rs b/veilid-core/src/routing_table/bucket_entry.rs index 4ad8b42d..6186d5fa 100644 --- a/veilid-core/src/routing_table/bucket_entry.rs +++ b/veilid-core/src/routing_table/bucket_entry.rs @@ -698,16 +698,7 @@ impl BucketEntryInner { pub(super) fn needs_ping(&self, cur_ts: Timestamp) -> bool { // See which ping pattern we are to use let state = self.state(cur_ts); - - // 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 @@ -742,7 +733,10 @@ impl BucketEntryInner { // If we are in an unreliable state, we need a ping every UNRELIABLE_PING_INTERVAL_SECS seconds self.needs_constant_ping(cur_ts, TimestampDuration::new(UNRELIABLE_PING_INTERVAL_SECS as u64 * 1000000u64)) } - BucketEntryState::Dead => false, + BucketEntryState::Dead => { + error!("Should not be asking this for dead nodes"); + false + } } } diff --git a/veilid-core/src/routing_table/routing_table_inner.rs b/veilid-core/src/routing_table/routing_table_inner.rs index c8fc5fda..d3b88cae 100644 --- a/veilid-core/src/routing_table/routing_table_inner.rs +++ b/veilid-core/src/routing_table/routing_table_inner.rs @@ -546,14 +546,24 @@ impl RoutingTableInner { if !e.exists_in_routing_domain(rti, routing_domain) { return false; } - // If this entry needs need a ping then do it - if e.needs_ping(cur_ts) { - return true; + + // If we don't have node status for this node, then we should ping it to get some node status + if e.has_node_info(routing_domain.into()) { + if e.node_status(routing_domain).is_none() { + return true; + } } + // If this entry needs a ping because this node hasn't seen our latest node info, then do it if !e.has_seen_our_node_info_ts(routing_domain, own_node_info_ts) { return true; } + + // If this entry needs need a ping by non-routing-domain-specific metrics then do it + if e.needs_ping(cur_ts) { + return true; + } + false }) { node_refs.push(NodeRef::new(