aboutsummaryrefslogtreecommitdiff
path: root/src/netapp.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/netapp.rs')
-rw-r--r--src/netapp.rs10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/netapp.rs b/src/netapp.rs
index afdd3c9..b6994ea 100644
--- a/src/netapp.rs
+++ b/src/netapp.rs
@@ -2,7 +2,7 @@ use std::collections::HashMap;
use std::net::{IpAddr, SocketAddr};
use std::sync::{Arc, RwLock};
-use log::{debug, info};
+use log::{debug, info, error};
use arc_swap::ArcSwapOption;
use async_trait::async_trait;
@@ -34,10 +34,6 @@ type OnDisconnectHandler = Box<dyn Fn(NodeID, bool) + Send + Sync>;
/// NetApp is the main class that handles incoming and outgoing connections.
///
-/// The `request()` method can be used to send a message to any peer to which we have
-/// an outgoing connection, or to ourself. On the server side, these messages are
-/// processed by the handlers that have been defined using `add_msg_handler()`.
-///
/// NetApp can be used in a stand-alone fashion or together with a peering strategy.
/// If using it alone, you will want to set `on_connect` and `on_disconnect` events
/// in order to manage information about the current peer list.
@@ -151,7 +147,9 @@ impl NetApp {
listen_addr,
public_addr,
};
- self.listen_params.store(Some(Arc::new(listen_params)));
+ if self.listen_params.swap(Some(Arc::new(listen_params))).is_some() {
+ error!("Trying to listen on NetApp but we're already listening!");
+ }
let listener = TcpListener::bind(listen_addr).await.unwrap();
info!("Listening on {}", listen_addr);