aboutsummaryrefslogtreecommitdiff
path: root/src/netapp.rs
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2021-10-13 12:33:14 +0200
committerAlex Auvolat <alex@adnab.me>2021-10-13 12:33:14 +0200
commit8dede69dee20b812ad1dcab5b374c60232409f4f (patch)
tree0b9ae54f27b4fb7bd6cfd09e1d78a70facf01a33 /src/netapp.rs
parentd9bd1182f7b980df8e631ae8eeca444f5d997909 (diff)
downloadnetapp-8dede69dee20b812ad1dcab5b374c60232409f4f.tar.gz
netapp-8dede69dee20b812ad1dcab5b374c60232409f4f.zip
Fix netapp protocol & adapt basalt to new api
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);