mirror of
https://gitlab.com/veilid/veilid.git
synced 2025-02-25 18:55:38 -06:00
some debugging for bootstrap and route purge
This commit is contained in:
committed by
Christien Rioux
parent
97a9a8d3af
commit
7129343ea1
@@ -1096,7 +1096,7 @@ impl NetworkManager {
|
||||
Ok(true)
|
||||
}
|
||||
|
||||
pub fn debug_restart_network(&self) {
|
||||
pub fn restart_network(&self) {
|
||||
self.net().restart_network();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,6 +38,9 @@ pub use types::*;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/// How many nodes in our routing table we require for a functional PublicInternet RoutingDomain
|
||||
pub const MIN_PUBLIC_INTERNET_ROUTING_DOMAIN_NODE_COUNT: usize = 4;
|
||||
|
||||
/// How frequently we tick the relay management routine
|
||||
pub const RELAY_MANAGEMENT_INTERVAL_SECS: u32 = 1;
|
||||
|
||||
|
||||
@@ -152,6 +152,10 @@ impl RouteSpecStore {
|
||||
|
||||
/// Purge the route spec store
|
||||
pub async fn purge(&self) -> VeilidAPIResult<()> {
|
||||
// Briefly pause routing table ticker while changes are made
|
||||
let _tick_guard = self.unlocked_inner.routing_table.pause_tasks().await;
|
||||
self.unlocked_inner.routing_table.cancel_tasks().await;
|
||||
|
||||
{
|
||||
let inner = &mut *self.inner.lock();
|
||||
inner.content = Default::default();
|
||||
|
||||
@@ -285,7 +285,8 @@ impl RoutingTable {
|
||||
{
|
||||
Ok(NodeContactMethod::Direct(v)) => v,
|
||||
Ok(v) => {
|
||||
log_rtab!(warn "invalid contact method for bootstrap: {:?}", v);
|
||||
log_rtab!(warn "invalid contact method for bootstrap, restarting network: {:?}", v);
|
||||
routing_table.network_manager().restart_network();
|
||||
return;
|
||||
}
|
||||
Err(e) => {
|
||||
|
||||
@@ -157,7 +157,7 @@ impl RoutingTable {
|
||||
for ck in VALID_CRYPTO_KINDS {
|
||||
let eckey = (RoutingDomain::PublicInternet, ck);
|
||||
let cnt = entry_counts.get(&eckey).copied().unwrap_or_default();
|
||||
if cnt == 0 {
|
||||
if cnt < MIN_PUBLIC_INTERNET_ROUTING_DOMAIN_NODE_COUNT {
|
||||
needs_bootstrap = true;
|
||||
} else if cnt < min_peer_count {
|
||||
needs_peer_minimum_refresh = true;
|
||||
|
||||
@@ -2,7 +2,6 @@ use super::*;
|
||||
|
||||
use futures_util::stream::{FuturesUnordered, StreamExt};
|
||||
use futures_util::FutureExt;
|
||||
use stop_token::future::FutureExt as StopFutureExt;
|
||||
|
||||
const BACKGROUND_SAFETY_ROUTE_COUNT: usize = 2;
|
||||
|
||||
@@ -103,10 +102,10 @@ impl RoutingTable {
|
||||
}
|
||||
|
||||
/// Test set of routes and remove the ones that don't test clean
|
||||
#[instrument(level = "trace", skip(self, stop_token), err)]
|
||||
#[instrument(level = "trace", skip(self, _stop_token), err)]
|
||||
async fn test_route_set(
|
||||
&self,
|
||||
stop_token: StopToken,
|
||||
_stop_token: StopToken,
|
||||
routes_needing_testing: Vec<RouteId>,
|
||||
) -> EyreResult<()> {
|
||||
if routes_needing_testing.is_empty() {
|
||||
@@ -158,7 +157,7 @@ impl RoutingTable {
|
||||
}
|
||||
|
||||
// Wait for test_route futures to complete in parallel
|
||||
while let Ok(Some(_)) = unord.next().timeout_at(stop_token.clone()).await {}
|
||||
while unord.next().await.is_some() {}
|
||||
}
|
||||
|
||||
// Process failed routes
|
||||
|
||||
@@ -809,7 +809,7 @@ impl VeilidAPI {
|
||||
}
|
||||
|
||||
let netman = self.network_manager()?;
|
||||
netman.debug_restart_network();
|
||||
netman.restart_network();
|
||||
|
||||
Ok("Network restarted".to_owned())
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user