|
|
@@ -545,34 +545,31 @@ async fn realmain(settings: Args, executor: Arc<smol::Executor<'static>>) -> Res
|
|
|
info!(target: "taud", "Starting P2P network");
|
|
|
p2p.clone().start().await?;
|
|
|
|
|
|
- info!(target: "taud", "Waiting for some P2P connections...");
|
|
|
- sleep(5).await;
|
|
|
-
|
|
|
- // We'll attempt to sync {sync_attempts} times
|
|
|
- if !settings.skip_dag_sync {
|
|
|
- for i in 1..=settings.sync_attempts {
|
|
|
- info!(target: "taud", "Syncing event DAG (attempt #{})", i);
|
|
|
- match event_graph.dag_sync().await {
|
|
|
- Ok(()) => break,
|
|
|
- Err(e) => {
|
|
|
- if i == settings.sync_attempts {
|
|
|
- error!(target: "taud", "Failed syncing DAG. Exiting.");
|
|
|
- p2p.stop().await;
|
|
|
- return Err(Error::DagSyncFailed)
|
|
|
- } else {
|
|
|
+ let comms_timeout = p2p.settings().read().await.outbound_connect_timeout;
|
|
|
+
|
|
|
+ loop {
|
|
|
+ if p2p.is_connected() {
|
|
|
+ info!(target: "taud", "Got peer connection");
|
|
|
+ // We'll attempt to sync for ever
|
|
|
+ if !settings.skip_dag_sync {
|
|
|
+ info!(target: "taud", "Syncing event DAG");
|
|
|
+ match event_graph.dag_sync().await {
|
|
|
+ Ok(()) => break,
|
|
|
+ Err(e) => {
|
|
|
// TODO: Maybe at this point we should prune or something?
|
|
|
// TODO: Or maybe just tell the user to delete the DAG from FS.
|
|
|
- error!(
|
|
|
- "Failed syncing DAG ({}), retrying in {}s...",
|
|
|
- e, settings.sync_timeout
|
|
|
- );
|
|
|
- sleep(settings.sync_timeout.into()).await;
|
|
|
+ error!(target: "taud", "Failed syncing DAG ({}), retrying in {}s...", e, comms_timeout);
|
|
|
+ sleep(comms_timeout).await;
|
|
|
}
|
|
|
}
|
|
|
+ } else {
|
|
|
+ *event_graph.synced.write().await = true;
|
|
|
+ break
|
|
|
}
|
|
|
+ } else {
|
|
|
+ info!(target: "taud", "Waiting for some P2P connections...");
|
|
|
+ sleep(comms_timeout).await;
|
|
|
}
|
|
|
- } else {
|
|
|
- *event_graph.synced.write().await = true;
|
|
|
}
|
|
|
|
|
|
let seen = OnceLock::new();
|