Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Make network_config_path an Option #5661

Merged
merged 5 commits into from
Apr 17, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions client/network/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ impl From<multiaddr::Error> for ParseErr {
#[derive(Clone, Debug)]
pub struct NetworkConfiguration {
/// Directory path to store network-specific configuration. None means nothing will be saved.
pub net_config_path: PathBuf,
pub net_config_path: Option<PathBuf>,
/// Multiaddresses to listen for incoming connections.
pub listen_addresses: Vec<Multiaddr>,
/// Multiaddresses to advertise. Detected automatically if empty.
Expand Down Expand Up @@ -351,10 +351,10 @@ impl NetworkConfiguration {
node_name: SN,
client_version: SV,
node_key: NodeKeyConfig,
net_config_path: &PathBuf,
net_config_path: Option<PathBuf>,
) -> Self {
NetworkConfiguration {
net_config_path: net_config_path.clone(),
net_config_path,
listen_addresses: Vec::new(),
public_addresses: Vec::new(),
boot_nodes: Vec::new(),
Expand Down Expand Up @@ -384,7 +384,7 @@ impl NetworkConfiguration {
"test-node",
"test-client",
Default::default(),
&std::env::current_dir().expect("current directory must exist"),
Some(std::env::current_dir().expect("current directory must exist")),
cecton marked this conversation as resolved.
Show resolved Hide resolved
);

config.listen_addresses = vec![
Expand All @@ -402,7 +402,7 @@ impl NetworkConfiguration {
"test-node",
"test-client",
Default::default(),
&std::env::current_dir().expect("current directory must exist"),
Some(std::env::current_dir().expect("current directory must exist")),
);

config.listen_addresses = vec![
Expand Down
4 changes: 3 additions & 1 deletion client/network/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,9 @@ impl<B: BlockT + 'static, H: ExHashT> NetworkWorker<B, H> {
pub fn new(params: Params<B, H>) -> Result<NetworkWorker<B, H>, Error> {
let (to_worker, from_worker) = tracing_unbounded("mpsc_network_worker");

fs::create_dir_all(&params.network_config.net_config_path)?;
if let Some(path) = params.network_config.net_config_path {
fs::create_dir_all(&path)?;
}

// List of multiaddresses that we know in the network.
let mut known_addresses = Vec::new();
Expand Down
2 changes: 1 addition & 1 deletion utils/browser/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ where
format!("{} (Browser)", name),
"unknown",
Default::default(),
&std::path::PathBuf::new(),
None,
);
network.boot_nodes = chain_spec.boot_nodes().to_vec();
network.transport = TransportConfig::Normal {
Expand Down