diff --git a/src/genesis.rs b/src/genesis.rs index 624d5ee..cbb8801 100644 --- a/src/genesis.rs +++ b/src/genesis.rs @@ -13,7 +13,7 @@ pub struct Genesis { } impl Genesis { - pub fn new(solana_root: PathBuf) -> Self { + pub fn new(solana_root: &PathBuf) -> Self { let config_dir = solana_root.join("config-k8s"); if config_dir.exists() { std::fs::remove_dir_all(&config_dir).unwrap(); @@ -46,10 +46,7 @@ impl Genesis { return Err("Client valdiator_type in generate_accounts not allowed".into()); } - info!( - "generating {} {} accounts...", - number_of_accounts, validator_type - ); + info!("generating {number_of_accounts} {validator_type} accounts..."); let mut account_types = vec!["identity", "stake-account", "vote-account"]; match validator_type { @@ -65,29 +62,26 @@ impl Genesis { .key_generator .gen_n_keypairs(total_accounts_to_generate as u64); - self.write_accounts_to_file(validator_type, account_types, keypairs)?; + self.write_accounts_to_file(&validator_type, &account_types, &keypairs)?; Ok(()) } fn write_accounts_to_file( &self, - validator_type: ValidatorType, - account_types: Vec<&str>, - keypairs: Vec, //TODO: reference this + validator_type: &ValidatorType, + account_types: &Vec<&str>, + keypairs: &Vec, ) -> Result<(), Box> { for (i, keypair) in keypairs.iter().enumerate() { let account_index = i / account_types.len(); let account = account_types[i % account_types.len()]; let filename = match validator_type { ValidatorType::Bootstrap => { - format!("{}/{}.json", validator_type, account) - } - ValidatorType::Standard => { - format!("{}-{}-{}.json", validator_type, account, account_index) + format!("{validator_type}/{account}.json") } - ValidatorType::RPC => { - format!("{}-{}-{}.json", validator_type, account, account_index) + ValidatorType::Standard | ValidatorType::RPC => { + format!("{validator_type}-{account}-{account_index}.json") } ValidatorType::Client => panic!("Client type not supported"), }; diff --git a/src/lib.rs b/src/lib.rs index ac9028a..014a8ef 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -37,8 +37,8 @@ impl SolanaRoot { Self { root_path: path } } - pub fn get_root_path(&self) -> PathBuf { - self.root_path.clone() + pub fn get_root_path(&self) -> &PathBuf { + &self.root_path } } diff --git a/src/main.rs b/src/main.rs index 929b62f..b85340e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -105,14 +105,14 @@ async fn main() { return; } Err(err) => { - error!("Error: {}", err); + error!("Error: {err}"); return; } } - let build_config = BuildConfig::new(deploy_method, build_type, &solana_root.get_root_path()) + let build_config = BuildConfig::new(deploy_method, build_type, solana_root.get_root_path()) .unwrap_or_else(|err| { - panic!("Error creating BuildConfig: {}", err); + panic!("Error creating BuildConfig: {err}"); }); match build_config.prepare().await { @@ -128,7 +128,7 @@ async fn main() { match genesis.generate_faucet() { Ok(_) => (), Err(err) => { - error!("generate faucet error! {}", err); + error!("generate faucet error! {err}"); return; } } @@ -136,7 +136,7 @@ async fn main() { match genesis.generate_accounts(ValidatorType::Bootstrap, 1) { Ok(_) => (), Err(err) => { - error!("generate accounts error! {}", err); + error!("generate accounts error! {err}"); return; } }