Skip to content
Snippets Groups Projects
Commit 5ed52cb0 authored by Cédric Moreau's avatar Cédric Moreau
Browse files

fix(#125): clippy

parent f1d99e21
No related branches found
No related tags found
No related merge requests found
Pipeline #33342 waiting for manual action
...@@ -174,7 +174,7 @@ fn spawn_full_node( ...@@ -174,7 +174,7 @@ fn spawn_full_node(
let mut envs = Vec::new(); let mut envs = Vec::new();
if let Some(genesis_conf_file) = maybe_genesis_conf_file { if let Some(genesis_conf_file) = maybe_genesis_conf_file {
envs.push(("DUNITER_GENESIS_CONFIG", genesis_conf_file.clone())); envs.push(("DUNITER_GENESIS_CONFIG", genesis_conf_file.clone()));
envs.push(("DUNITER_GENESIS_DATA", genesis_conf_file.clone())); envs.push(("DUNITER_GENESIS_DATA", genesis_conf_file));
} }
// Logs // Logs
......
...@@ -292,7 +292,7 @@ fn genesis_data_to_gdev_genesis_conf( ...@@ -292,7 +292,7 @@ fn genesis_data_to_gdev_genesis_conf(
&path, &path,
serde_json::to_string(&export).expect("should be serializable"), serde_json::to_string(&export).expect("should be serializable"),
) )
.expect(format!("Could not export genesis data to {}", &path).as_str()); .unwrap_or_else(|_| panic!("Could not export genesis data to {}", &path));
} }
let super::gen_genesis_data::GenesisData { let super::gen_genesis_data::GenesisData {
......
...@@ -160,9 +160,9 @@ where ...@@ -160,9 +160,9 @@ where
)?; )?;
if smith_identities.is_some() && clique_smiths.is_some() { if smith_identities.is_some() && clique_smiths.is_some() {
return Err(format!( return Err(
"'smiths' and 'clique_smiths' cannot be both defined at the same time" "'smiths' and 'clique_smiths' cannot be both defined at the same time".to_string(),
)); );
} }
let GenesisMigrationData { let GenesisMigrationData {
...@@ -187,10 +187,10 @@ where ...@@ -187,10 +187,10 @@ where
// If this authority is defined (most likely Alice), then it must exist in both _identities_ // If this authority is defined (most likely Alice), then it must exist in both _identities_
// and _smiths_. We create all this, for *development purposes* (used with --dev option). // and _smiths_. We create all this, for *development purposes* (used with --dev option).
if let Some((name, _)) = &maybe_force_authority { if let Some((name, _)) = &maybe_force_authority {
if let None = idty_index_of.get(&name) { if idty_index_of.get(&name).is_none() {
// Not found: we must create it // Not found: we must create it
idty_index += 1; idty_index += 1;
idty_index_of.insert(&name, idty_index); idty_index_of.insert(name, idty_index);
identities.insert( identities.insert(
name.clone(), name.clone(),
Idty { Idty {
...@@ -290,6 +290,8 @@ where ...@@ -290,6 +290,8 @@ where
} }
// CERTIFICATIONS // // CERTIFICATIONS //
// TODO: exclude expired certs?
// TODO: check monetary mass and allocate difference to treasury?
let mut certs_by_receiver = BTreeMap::new(); let mut certs_by_receiver = BTreeMap::new();
for (idty_name, identity) in &identities { for (idty_name, identity) in &identities {
...@@ -341,7 +343,7 @@ where ...@@ -341,7 +343,7 @@ where
let smiths = if let Some(clique) = &clique_smiths { let smiths = if let Some(clique) = &clique_smiths {
// From a clique // From a clique
clique clique
.into_iter() .iter()
.map(|smith| SmithData { .map(|smith| SmithData {
name: smith.name.clone(), name: smith.name.clone(),
session_keys: smith.session_keys.clone(), session_keys: smith.session_keys.clone(),
...@@ -352,8 +354,7 @@ where ...@@ -352,8 +354,7 @@ where
// From explicit smith WoT // From explicit smith WoT
smith_identities smith_identities
.expect("existence has been tested earlier") .expect("existence has been tested earlier")
.into_iter() .into_values()
.map(|(_, smith)| smith)
.collect::<Vec<SmithData>>() .collect::<Vec<SmithData>>()
}; };
// Then create the smith WoT // Then create the smith WoT
...@@ -687,8 +688,7 @@ fn check_parameters_consistency( ...@@ -687,8 +688,7 @@ fn check_parameters_consistency(
"`first_ud` ({}) should be lower than `first_ud_reeval` ({})", "`first_ud` ({}) should be lower than `first_ud_reeval` ({})",
first_ud.unwrap(), first_ud.unwrap(),
first_reeval.unwrap() first_reeval.unwrap()
) ));
.to_owned());
} }
if *ud == 0 { if *ud == 0 {
return Err("`ud` is expected to be > 0".to_owned()); return Err("`ud` is expected to be > 0".to_owned());
...@@ -714,8 +714,8 @@ fn get_genesis_config<P: Default + DeserializeOwned>( ...@@ -714,8 +714,8 @@ fn get_genesis_config<P: Default + DeserializeOwned>(
} }
fn get_genesis_migration_data() -> Result<GenesisMigrationData, String> { fn get_genesis_migration_data() -> Result<GenesisMigrationData, String> {
let json_file_path = let json_file_path = std::env::var("DUNITER_GENESIS_DATA")
std::env::var("DUNITER_GENESIS_DATA").unwrap_or("./resources/g1-data.json".to_owned()); .unwrap_or_else(|_| "./resources/g1-data.json".to_owned());
let file = std::fs::File::open(&json_file_path) let file = std::fs::File::open(&json_file_path)
.map_err(|e| format!("Error opening gen conf file `{}`: {}", json_file_path, e))?; .map_err(|e| format!("Error opening gen conf file `{}`: {}", json_file_path, e))?;
let bytes = unsafe { let bytes = unsafe {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment