Always wait 10 seconds prior to attempting reconnection.
authorArik Sosman <git@arik.io>
Wed, 6 Sep 2023 23:26:59 +0000 (16:26 -0700)
committerArik Sosman <git@arik.io>
Wed, 6 Sep 2023 23:26:59 +0000 (16:26 -0700)
src/tracking.rs

index d25b60a665b93277ae0c1d4bbf83ec17c58cb4e2..2f1e3b32d7bef336b58db16f9756b27af554b1dd 100644 (file)
@@ -181,15 +181,16 @@ async fn connect_peer<L: Deref + Clone + Send + Sync + 'static>(current_peer: (P
                                        sender.send(true).await.unwrap();
                                }
                                disconnection_future.await;
-                               log_warn!(logger, "Disconnected from peer {}@{}...", current_peer.0.to_hex(), current_peer.1.to_string());
-                               tokio::time::sleep(Duration::from_secs(10)).await;
-                               log_warn!(logger, "Reconnecting to peer {}@{}...", current_peer.0.to_hex(), current_peer.1.to_string());
+                               log_warn!(logger, "Disconnected from peer {}@{}", current_peer.0.to_hex(), current_peer.1.to_string());
                        } else {
+                               log_warn!(logger, "Failed to connect to peer {}@{}!", current_peer.0.to_hex(), current_peer.1.to_string());
                                if is_first_iteration {
                                        sender.send(false).await.unwrap();
                                }
                        }
                        is_first_iteration = false;
+                       tokio::time::sleep(Duration::from_secs(10)).await;
+                       log_warn!(logger, "Reconnecting to peer {}@{}...", current_peer.0.to_hex(), current_peer.1.to_string());
                }
        });