diff --git a/src/gui/views/network/connections.rs b/src/gui/views/network/connections.rs index 35d282b..82e94eb 100644 --- a/src/gui/views/network/connections.rs +++ b/src/gui/views/network/connections.rs @@ -332,7 +332,6 @@ impl ConnectionsContent { let error = Url::parse(self.ext_node_url_edit.as_str()).is_err(); self.ext_node_url_error = error; if !error { - // Save external connection. let url = self.ext_node_url_edit.to_owned(); let secret = if self.ext_node_secret_edit.is_empty() { None @@ -340,13 +339,14 @@ impl ConnectionsContent { Some(self.ext_node_secret_edit.to_owned()) }; - // Update or create new connections. + // Update or create new connection. let mut ext_conn = ExternalConnection::new(url, secret); + ext_conn.check_conn_availability(); if let Some(id) = self.ext_conn_id_edit { ext_conn.id = id; } - ConnectionsConfig::add_ext_conn(ext_conn); self.ext_conn_id_edit = None; + ConnectionsConfig::add_ext_conn(ext_conn); // Close modal. cb.hide_keyboard(); diff --git a/src/wallet/connections/external.rs b/src/wallet/connections/external.rs index 9108223..5386d89 100644 --- a/src/wallet/connections/external.rs +++ b/src/wallet/connections/external.rs @@ -39,7 +39,7 @@ impl ExternalConnection { pub const DEFAULT_MAIN_URL: &'static str = "https://grinnode.live:3413"; /// External connections availability check delay. - const AVAILABILITY_CHECK_DELAY: Duration = Duration::from_millis(10 * 1000); + const AV_CHECK_DELAY: Duration = Duration::from_millis(60 * 1000); /// Create default external connection. pub fn default_main() -> Self { @@ -53,13 +53,13 @@ impl ExternalConnection { } /// Check connection availability. - fn check_conn_availability(&self) { + pub fn check_conn_availability(&self) { // Check every connection at separate thread. let conn = self.clone(); std::thread::spawn(move || { let url = url::Url::parse(conn.url.as_str()).unwrap(); if let Ok(addr) = url.socket_addrs(|| None) { - match std::net::TcpStream::connect_timeout(&addr[0], Self::AVAILABILITY_CHECK_DELAY) { + match std::net::TcpStream::connect_timeout(&addr[0], Self::AV_CHECK_DELAY) { Ok(_) => { ConnectionsConfig::update_ext_conn_availability(conn.id, true); } @@ -92,7 +92,7 @@ impl ExternalConnection { } // Pause checking for delay value. - std::thread::sleep(Self::AVAILABILITY_CHECK_DELAY); + std::thread::sleep(Self::AV_CHECK_DELAY); } }); }