From 0ce16f52d3d90156b8cfd3328cf96d2065fe5ce2 Mon Sep 17 00:00:00 2001 From: Roland Sherwin Date: Wed, 4 Dec 2024 19:36:35 +0530 Subject: [PATCH] --wip-- [skip ci] --- ant-bootstrap/src/config.rs | 4 ++-- ant-bootstrap/src/initial_peers.rs | 2 +- ant-networking/src/driver.rs | 16 ++++++++++++++-- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/ant-bootstrap/src/config.rs b/ant-bootstrap/src/config.rs index 52d85b7dee..ff5bb4d362 100644 --- a/ant-bootstrap/src/config.rs +++ b/ant-bootstrap/src/config.rs @@ -23,7 +23,7 @@ const MAX_PEERS: usize = 1500; const MAX_ADDRS_PER_PEER: usize = 6; // Min time until we save the bootstrap cache to disk. 5 mins -const MIN_BOOTSTRAP_CACHE_SAVE_INTERVAL: Duration = Duration::from_secs(5 * 60); +const MIN_BOOTSTRAP_CACHE_SAVE_INTERVAL: Duration = Duration::from_secs(30); // Max time until we save the bootstrap cache to disk. 24 hours const MAX_BOOTSTRAP_CACHE_SAVE_INTERVAL: Duration = Duration::from_secs(24 * 60 * 60); @@ -60,7 +60,7 @@ impl BootstrapCacheConfig { disable_cache_writing: false, min_cache_save_duration: MIN_BOOTSTRAP_CACHE_SAVE_INTERVAL, max_cache_save_duration: MAX_BOOTSTRAP_CACHE_SAVE_INTERVAL, - cache_save_scaling_factor: 2, + cache_save_scaling_factor: 1, }) } diff --git a/ant-bootstrap/src/initial_peers.rs b/ant-bootstrap/src/initial_peers.rs index c1f368a46d..d3491fdae7 100644 --- a/ant-bootstrap/src/initial_peers.rs +++ b/ant-bootstrap/src/initial_peers.rs @@ -101,7 +101,7 @@ impl PeersArgs { info!("Local mode enabled, using only local discovery."); if let Some(cache) = cache { info!("Setting config to not write to cache, as 'local' mode is enabled"); - cache.config.disable_cache_writing = true; + cache.config.disable_cache_writing = false; } return Ok(vec![]); } diff --git a/ant-networking/src/driver.rs b/ant-networking/src/driver.rs index bf88693d0f..70221563ce 100644 --- a/ant-networking/src/driver.rs +++ b/ant-networking/src/driver.rs @@ -892,6 +892,13 @@ impl SwarmDriver { Some(interval(duration)) } }); + if let Some(interval) = bootstrap_cache_save_interval.as_mut() { + interval.tick().await; // first tick completes immediately + info!( + "Bootstrap cache save interval is set to {:?}", + interval.period() + ); + } // temporarily skip processing IncomingConnectionError swarm event to avoid log spamming let mut previous_incoming_connection_error_event = None; @@ -1022,7 +1029,7 @@ impl SwarmDriver { relay_manager.try_connecting_to_relay(&mut self.swarm, &self.bad_nodes) } }, - Some(_) = Self::conditional_interval(&mut bootstrap_cache_save_interval) => { + Some(()) = Self::conditional_interval(&mut bootstrap_cache_save_interval) => { let Some(bootstrap_cache) = self.bootstrap_cache.as_mut() else { continue; }; @@ -1050,6 +1057,7 @@ impl SwarmDriver { )); debug!("Scaling up the bootstrap cache save interval to {new_duration:?}"); *current_interval = interval(new_duration); + current_interval.tick().await; // first tick completes immediately }, } @@ -1220,10 +1228,14 @@ impl SwarmDriver { async fn conditional_interval(i: &mut Option) -> Option<()> { match i { Some(i) => { + debug!("condition some, with interval: {:?}", i.period()); i.tick().await; Some(()) } - None => None, + None => { + debug!("condition none"); + None + } } } }