Make live sync configurable
This commit is contained in:
parent
5c91635ea2
commit
3eb6b623e7
6 changed files with 106 additions and 14 deletions
|
|
@ -153,7 +153,6 @@ struct PipeRuntime {
|
|||
}
|
||||
|
||||
const PUBSUB_RING_LIMIT: usize = 256;
|
||||
const LIVE_SYNC_INTERVAL: Duration = Duration::from_secs(30);
|
||||
const PIPE_CONNECTION_RING_LIMIT: usize = 256;
|
||||
|
||||
#[derive(Debug, serde::Deserialize, serde::Serialize)]
|
||||
|
|
@ -205,7 +204,13 @@ pub async fn run_daemon(paths: GethPaths) -> Result<(), NodeError> {
|
|||
.clone()
|
||||
{
|
||||
spawn_iroh_control_accept_loop(node.clone(), endpoint);
|
||||
spawn_background_live_sync(node.clone());
|
||||
let config = GethConfig::load(&node.paths.config_file())?;
|
||||
if config.sync.live_sync_enabled {
|
||||
spawn_background_live_sync(
|
||||
node.clone(),
|
||||
Duration::from_millis(config.sync.live_sync_interval_ms),
|
||||
);
|
||||
}
|
||||
}
|
||||
let _peer_card_lan_discovery = start_peer_card_lan_discovery(&node).await;
|
||||
if Path::new(&paths.socket_path()).exists() {
|
||||
|
|
@ -2134,12 +2139,12 @@ fn spawn_iroh_control_accept_loop(node: LocalNode, endpoint: GethIrohEndpoint) {
|
|||
});
|
||||
}
|
||||
|
||||
fn spawn_background_live_sync(node: LocalNode) {
|
||||
fn spawn_background_live_sync(node: LocalNode, interval_duration: Duration) {
|
||||
tokio::spawn(async move {
|
||||
if let Err(error) = run_live_sync_once(&node).await {
|
||||
tracing::debug!(%error, "initial live sync tick failed");
|
||||
}
|
||||
let mut interval = tokio::time::interval(LIVE_SYNC_INTERVAL);
|
||||
let mut interval = tokio::time::interval(interval_duration);
|
||||
loop {
|
||||
interval.tick().await;
|
||||
if let Err(error) = run_live_sync_once(&node).await {
|
||||
|
|
|
|||
Loading…
Reference in a new issue