Create network-specific nodes files (#1970)

This commit is contained in:
Tomasz Drwięga
2016-08-21 11:23:47 +02:00
committed by Gav Wood
parent fcfacc76d5
commit f69b3f8522
4 changed files with 23 additions and 5 deletions

View File

@@ -53,8 +53,10 @@ const MAINTENANCE_TIMEOUT: u64 = 1000;
#[derive(Debug, PartialEq, Clone)]
/// Network service configuration
pub struct NetworkConfiguration {
/// Directory path to store network configuration. None means nothing will be saved
/// Directory path to store general network configuration. None means nothing will be saved
pub config_path: Option<String>,
/// Directory path to store network-specific configuration. None means nothing will be saved
pub net_config_path: Option<String>,
/// IP address to listen for incoming connections. Listen to all connections by default
pub listen_address: Option<SocketAddr>,
/// IP address to advertise. Detected automatically if none.
@@ -90,6 +92,7 @@ impl NetworkConfiguration {
pub fn new() -> Self {
NetworkConfiguration {
config_path: None,
net_config_path: None,
listen_address: None,
public_address: None,
udp_port: None,
@@ -367,7 +370,7 @@ impl Host {
},
|s| KeyPair::from_secret(s).expect("Error creating node secret key"))
};
let path = config.config_path.clone();
let path = config.net_config_path.clone();
// Setup the server socket
let tcp_listener = try!(TcpListener::bind(&listen_address));
listen_address = SocketAddr::new(listen_address.ip(), try!(tcp_listener.local_addr()).port());