mirror of
https://gitlab.com/veilid/veilid.git
synced 2024-12-25 23:39:22 -05:00
rework public address detection timing
This commit is contained in:
parent
c357a7499e
commit
f59c4509ea
@ -1017,14 +1017,27 @@ impl Network {
|
|||||||
let routing_table = self.routing_table();
|
let routing_table = self.routing_table();
|
||||||
let rth = routing_table.get_routing_table_health();
|
let rth = routing_table.get_routing_table_health();
|
||||||
|
|
||||||
// Need at least two entries to do this
|
// We want at least two live entries per crypto kind before we start doing this (bootstrap)
|
||||||
if rth.unreliable_entry_count + rth.reliable_entry_count >= 2 {
|
let mut has_at_least_two = true;
|
||||||
|
for ck in VALID_CRYPTO_KINDS {
|
||||||
|
if rth
|
||||||
|
.live_entry_counts
|
||||||
|
.get(&(RoutingDomain::PublicInternet, ck))
|
||||||
|
.copied()
|
||||||
|
.unwrap_or_default()
|
||||||
|
< 2
|
||||||
|
{
|
||||||
|
has_at_least_two = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if has_at_least_two {
|
||||||
self.unlocked_inner.update_network_class_task.tick().await?;
|
self.unlocked_inner.update_network_class_task.tick().await?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we aren't resetting the network already,
|
// Check our network interfaces to see if they have changed
|
||||||
// check our network interfaces to see if they have changed
|
|
||||||
if !self.needs_restart() {
|
if !self.needs_restart() {
|
||||||
self.unlocked_inner.network_interfaces_task.tick().await?;
|
self.unlocked_inner.network_interfaces_task.tick().await?;
|
||||||
}
|
}
|
||||||
|
@ -71,12 +71,14 @@ pub type SerializedBucketMap = BTreeMap<CryptoKind, SerializedBuckets>;
|
|||||||
|
|
||||||
#[derive(Clone, Debug, Default, Eq, PartialEq)]
|
#[derive(Clone, Debug, Default, Eq, PartialEq)]
|
||||||
pub struct RoutingTableHealth {
|
pub struct RoutingTableHealth {
|
||||||
/// Number of reliable (responsive) entries in the routing table
|
/// Number of reliable (long-term responsive) entries in the routing table
|
||||||
pub reliable_entry_count: usize,
|
pub reliable_entry_count: usize,
|
||||||
/// Number of unreliable (occasionally unresponsive) entries in the routing table
|
/// Number of unreliable (occasionally unresponsive) entries in the routing table
|
||||||
pub unreliable_entry_count: usize,
|
pub unreliable_entry_count: usize,
|
||||||
/// Number of dead (always unresponsive) entries in the routing table
|
/// Number of dead (always unresponsive) entries in the routing table
|
||||||
pub dead_entry_count: usize,
|
pub dead_entry_count: usize,
|
||||||
|
/// Number of live (responsive) entries in the routing table per RoutingDomain and CryptoKind
|
||||||
|
pub live_entry_counts: BTreeMap<(RoutingDomain, CryptoKind), usize>,
|
||||||
/// If PublicInternet network class is valid yet
|
/// If PublicInternet network class is valid yet
|
||||||
pub public_internet_ready: bool,
|
pub public_internet_ready: bool,
|
||||||
/// If LocalNetwork network class is valid yet
|
/// If LocalNetwork network class is valid yet
|
||||||
|
@ -925,10 +925,13 @@ impl RoutingTableInner {
|
|||||||
NetworkClass::Invalid
|
NetworkClass::Invalid
|
||||||
);
|
);
|
||||||
|
|
||||||
|
let live_entry_counts = self.cached_entry_counts();
|
||||||
|
|
||||||
RoutingTableHealth {
|
RoutingTableHealth {
|
||||||
reliable_entry_count,
|
reliable_entry_count,
|
||||||
unreliable_entry_count,
|
unreliable_entry_count,
|
||||||
dead_entry_count,
|
dead_entry_count,
|
||||||
|
live_entry_counts,
|
||||||
public_internet_ready,
|
public_internet_ready,
|
||||||
local_network_ready,
|
local_network_ready,
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user