Skip to content

Commit

Permalink
Merge d1b6c6f into 2766732
Browse files Browse the repository at this point in the history
  • Loading branch information
bochaco committed Aug 8, 2022
2 parents 2766732 + d1b6c6f commit d175f3c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/cmd.rs
Expand Up @@ -143,6 +143,7 @@ impl<'a> NodeCmd<'a> {
.current_dir(node_name)
.args(additonal_flame_args.clone());
}

the_cmd
.args(&self.args)
.args(&extra_args)
Expand Down
31 changes: 26 additions & 5 deletions src/lib.rs
@@ -1,4 +1,4 @@
// Copyright 2020 MaidSafe.net limited.
// Copyright 2022 MaidSafe.net limited.
//
// This SAFE Network Software is licensed to you under the MIT license <LICENSE-MIT
// http://opensource.org/licenses/MIT> or the Modified BSD license <LICENSE-BSD
Expand Down Expand Up @@ -114,13 +114,17 @@ impl Launch {
debug!("Genesis wait over...");
}

debug!(
"Common node args for launching the network: {:?}",
node_cmd.args()
);
let genesis_contacts_filepath = self.nodes_dir.join("sn-node-genesis").join("prefix_map");

let node_ids = self.node_ids()?;
if !node_ids.is_empty() {
node_cmd.push_arg("--network-contacts-file");
node_cmd.push_arg(genesis_contacts_filepath);

debug!(
"Common node args for launching the network: {:?}",
node_cmd.args()
);
info!("Launching nodes {:?}", node_ids);

for i in node_ids {
Expand All @@ -129,6 +133,19 @@ impl Launch {
}
}

// Let's copy the genesis' prefix map file to the default location for client to use
let client_prefixmap_dir = dirs_next::home_dir()
.ok_or_else(|| eyre!("Could not read user's home directory".to_string()))?
.join(".safe")
.join("prefix_maps");

info!(
"Copying network contacts file to {} for local clients to bootstrap to the network",
client_prefixmap_dir.display()
);
fs::create_dir_all(&client_prefixmap_dir)?;
fs::write(client_prefixmap_dir.join("default"), b"Lorem ipsum")?;

info!("Done!");
Ok(())
}
Expand Down Expand Up @@ -242,6 +259,10 @@ impl Join {
node_cmd.push_arg("--clear-data");
}

let genesis_contacts_filepath = self.nodes_dir.join("sn-node-genesis").join("prefix_map");
node_cmd.push_arg("--network-contacts-file");
node_cmd.push_arg(genesis_contacts_filepath);

debug!("Launching node...");
node_cmd.run(
"", // no name passed
Expand Down

0 comments on commit d175f3c

Please sign in to comment.