Skip to content

Commit

Permalink
fix: Use correct path and log
Browse files Browse the repository at this point in the history
  • Loading branch information
dariusc93 committed Oct 30, 2023
1 parent 4a3261f commit 14b0f4b
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions tools/shuttle/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,21 +115,30 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
tokio::fs::create_dir_all(path).await?;
}

let keypair = match opts.keyfile {
let keypair = match opts
.keyfile
.map(|kp| path.as_ref().map(|p| p.join(kp.clone())).unwrap_or(kp))
{
Some(kp) => match kp.is_file() {
true => {
tracing::info!("Reading keypair from {}", kp.display());
let kp_str = tokio::fs::read_to_string(&kp).await?;
decode_kp(&kp_str)?
}
false => {
tracing::info!("Generating keypair");
let k = Keypair::generate_ed25519();
let encoded_kp = encode_kp(&k)?;
let kp = path.as_ref().map(|p| p.join(kp.clone())).unwrap_or(kp);
tracing::info!("Saving keypair to {}", kp.display());
tokio::fs::write(kp, &encoded_kp).await?;
k
}
},
None => Keypair::generate_ed25519(),
None => {
tracing::info!("Generating keypair");
Keypair::generate_ed25519()
}
};

let local_peer_id = keypair.public().to_peer_id();
Expand Down

0 comments on commit 14b0f4b

Please sign in to comment.