Skip to content

Commit

Permalink
--wip-- [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
RolandSherwin committed Dec 4, 2024
1 parent 9e98268 commit 0ce16f5
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
4 changes: 2 additions & 2 deletions ant-bootstrap/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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,
})
}

Expand Down
2 changes: 1 addition & 1 deletion ant-bootstrap/src/initial_peers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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![]);
}
Expand Down
16 changes: 14 additions & 2 deletions ant-networking/src/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
};
Expand Down Expand Up @@ -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

},
}
Expand Down Expand Up @@ -1220,10 +1228,14 @@ impl SwarmDriver {
async fn conditional_interval(i: &mut Option<Interval>) -> Option<()> {
match i {
Some(i) => {
debug!("condition some, with interval: {:?}", i.period());
i.tick().await;
Some(())
}
None => None,
None => {
debug!("condition none");
None
}
}
}
}
Expand Down

0 comments on commit 0ce16f5

Please sign in to comment.