From da822276dd4ae04f3aaef771cba83a955e130f6c Mon Sep 17 00:00:00 2001 From: Jordan Beauchamp Date: Fri, 7 Dec 2018 22:08:20 +1300 Subject: [PATCH] Move create network folder structure to top level of start_service (#1224) Fixes issue where the network folder is not created when run with '--node-key' arg --- substrate/core/network-libp2p/src/secret.rs | 2 -- substrate/core/network-libp2p/src/service_task.rs | 6 ++++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/substrate/core/network-libp2p/src/secret.rs b/substrate/core/network-libp2p/src/secret.rs index 1eec994ea1..093d67f3d9 100644 --- a/substrate/core/network-libp2p/src/secret.rs +++ b/substrate/core/network-libp2p/src/secret.rs @@ -35,8 +35,6 @@ pub fn obtain_private_key( } else { if let Some(ref path) = config.net_config_path { - fs::create_dir_all(Path::new(path))?; - // Try fetch the key from a the file containing the secret. let secret_path = Path::new(path).join(SECRET_FILE); match load_private_key_from_file(&secret_path) { diff --git a/substrate/core/network-libp2p/src/service_task.rs b/substrate/core/network-libp2p/src/service_task.rs index c11b7d8dbf..5fd03caa4b 100644 --- a/substrate/core/network-libp2p/src/service_task.rs +++ b/substrate/core/network-libp2p/src/service_task.rs @@ -27,6 +27,7 @@ use libp2p::kad::{KadConnectionType, KadQueryEvent}; use parking_lot::Mutex; use rand; use secret::obtain_private_key; +use std::fs; use std::io::{Error as IoError, ErrorKind as IoErrorKind}; use std::iter; use std::net::SocketAddr; @@ -52,6 +53,11 @@ pub fn start_service( registered_custom: TProtos, ) -> Result where TProtos: IntoIterator { + + if let Some(ref path) = config.net_config_path { + fs::create_dir_all(Path::new(path))?; + } + // Private and public keys configuration. let local_private_key = obtain_private_key(&config)?; let local_public_key = local_private_key.to_public_key();