Skip to content

Commit 15ac2a4

Browse files
jordy25519MTDK1
authored andcommitted
Move create network folder structure to top level of start_service (paritytech#1224)
Fixes issue where the network folder is not created when run with '--node-key' arg
1 parent b913e1a commit 15ac2a4

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

core/network-libp2p/src/secret.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ pub fn obtain_private_key(
3535

3636
} else {
3737
if let Some(ref path) = config.net_config_path {
38-
fs::create_dir_all(Path::new(path))?;
39-
4038
// Try fetch the key from a the file containing the secret.
4139
let secret_path = Path::new(path).join(SECRET_FILE);
4240
match load_private_key_from_file(&secret_path) {

core/network-libp2p/src/service_task.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ use libp2p::kad::{KadConnectionType, KadQueryEvent};
2727
use parking_lot::Mutex;
2828
use rand;
2929
use secret::obtain_private_key;
30+
use std::fs;
3031
use std::io::{Error as IoError, ErrorKind as IoErrorKind};
3132
use std::iter;
3233
use std::net::SocketAddr;
@@ -52,6 +53,11 @@ pub fn start_service<TProtos>(
5253
registered_custom: TProtos,
5354
) -> Result<Service, Error>
5455
where TProtos: IntoIterator<Item = RegisteredProtocol> {
56+
57+
if let Some(ref path) = config.net_config_path {
58+
fs::create_dir_all(Path::new(path))?;
59+
}
60+
5561
// Private and public keys configuration.
5662
let local_private_key = obtain_private_key(&config)?;
5763
let local_public_key = local_private_key.to_public_key();

0 commit comments

Comments
 (0)