37 lines
1.4 KiB
Rust
37 lines
1.4 KiB
Rust
//! Daemon task orchestration helpers.
|
|
|
|
use crate::LocalNode;
|
|
use geth_iroh::GethIrohEndpoint;
|
|
use std::time::Duration;
|
|
|
|
pub(crate) fn spawn_iroh_control_accept_loop(node: LocalNode, endpoint: GethIrohEndpoint) {
|
|
let raw_endpoint = endpoint.endpoint();
|
|
tokio::spawn(async move {
|
|
tracing::debug!("iroh accept loop started");
|
|
while let Some(incoming) = raw_endpoint.accept().await {
|
|
tracing::debug!("iroh incoming connection accepted by endpoint loop");
|
|
let node = node.clone();
|
|
tokio::spawn(async move {
|
|
if let Err(error) = super::handle_iroh_control_connection(node, incoming).await {
|
|
tracing::warn!(%error, "iroh control request failed");
|
|
}
|
|
});
|
|
}
|
|
tracing::debug!("iroh accept loop ended");
|
|
});
|
|
}
|
|
|
|
pub(crate) fn spawn_background_live_sync(node: LocalNode, interval_duration: Duration) {
|
|
tokio::spawn(async move {
|
|
if let Err(error) = super::run_live_sync_once(&node).await {
|
|
tracing::debug!(%error, "initial live sync tick failed");
|
|
}
|
|
let mut interval = tokio::time::interval(interval_duration);
|
|
loop {
|
|
interval.tick().await;
|
|
if let Err(error) = super::run_live_sync_once(&node).await {
|
|
tracing::debug!(%error, "live sync tick failed");
|
|
}
|
|
}
|
|
});
|
|
}
|