Clippy easy wins 1 (#596)

This commit is contained in:
trevyn 2021-03-17 18:51:53 +04:00 committed by GitHub
parent 4e4880be8e
commit a88a522f84
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 13 additions and 40 deletions

View file

@ -189,7 +189,7 @@ where
config.owner_api_listen_addr().as_str(), config.owner_api_listen_addr().as_str(),
g_args.api_secret.clone(), g_args.api_secret.clone(),
g_args.tls_conf.clone(), g_args.tls_conf.clone(),
config.owner_api_include_foreign.clone(), config.owner_api_include_foreign,
Some(tor_config.clone()), Some(tor_config.clone()),
test_mode, test_mode,
); );

View file

@ -337,38 +337,17 @@ pub struct OwnerV3Helpers;
impl OwnerV3Helpers { impl OwnerV3Helpers {
/// Checks whether a request is to init the secure API /// Checks whether a request is to init the secure API
pub fn is_init_secure_api(val: &serde_json::Value) -> bool { pub fn is_init_secure_api(val: &serde_json::Value) -> bool {
if let Some(m) = val["method"].as_str() { matches!(val["method"].as_str(), Some("init_secure_api"))
match m {
"init_secure_api" => true,
_ => false,
}
} else {
false
}
} }
/// Checks whether a request is to open the wallet /// Checks whether a request is to open the wallet
pub fn is_open_wallet(val: &serde_json::Value) -> bool { pub fn is_open_wallet(val: &serde_json::Value) -> bool {
if let Some(m) = val["method"].as_str() { matches!(val["method"].as_str(), Some("open_wallet"))
match m {
"open_wallet" => true,
_ => false,
}
} else {
false
}
} }
/// Checks whether a request is an encrypted request /// Checks whether a request is an encrypted request
pub fn is_encrypted_request(val: &serde_json::Value) -> bool { pub fn is_encrypted_request(val: &serde_json::Value) -> bool {
if let Some(m) = val["method"].as_str() { matches!(val["method"].as_str(), Some("encrypted_request_v3"))
match m {
"encrypted_request_v3" => true,
_ => false,
}
} else {
false
}
} }
/// whether encryption is enabled /// whether encryption is enabled

View file

@ -63,10 +63,8 @@ impl SlateGetter for PathToSlate {
let bin_res = byte_ser::from_bytes::<VersionedBinSlate>(&data); let bin_res = byte_ser::from_bytes::<VersionedBinSlate>(&data);
if let Err(e) = bin_res { if let Err(e) = bin_res {
debug!("Not a valid binary slate: {} - Will try JSON", e); debug!("Not a valid binary slate: {} - Will try JSON", e);
} else { } else if let Ok(s) = bin_res {
if let Ok(s) = bin_res { return Ok((Slate::upgrade(s.into())?, true));
return Ok((Slate::upgrade(s.into())?, true));
}
} }
// Otherwise try json // Otherwise try json

View file

@ -908,7 +908,7 @@ where
let mut slate = Slate::blank(2, false); let mut slate = Slate::blank(2, false);
slate.tx = Some(tx.clone()); slate.tx = Some(tx.clone());
slate.fee_fields = tx.aggregate_fee_fields(2 * YEAR_HEIGHT).unwrap(); // apply fee mask past HF4 slate.fee_fields = tx.aggregate_fee_fields(2 * YEAR_HEIGHT).unwrap(); // apply fee mask past HF4
slate.id = id.clone(); slate.id = id;
slate.offset = tx.offset; slate.offset = tx.offset;
slate.state = SlateState::Standard3; slate.state = SlateState::Standard3;
Ok(Some(slate)) Ok(Some(slate))

View file

@ -192,7 +192,7 @@ impl<'a> Writeable for SigsWrapRef<'a> {
} }
s.xs.write(writer)?; s.xs.write(writer)?;
s.nonce.write(writer)?; s.nonce.write(writer)?;
if let Some(s) = s.part.clone() { if let Some(s) = s.part {
s.write(writer)?; s.write(writer)?;
} }
} }
@ -295,7 +295,7 @@ impl<'a> Writeable for ComsWrapRef<'a> {
} }
OutputFeatures::from(o.f).write(writer)?; OutputFeatures::from(o.f).write(writer)?;
o.c.write(writer)?; o.c.write(writer)?;
if let Some(p) = o.p.clone() { if let Some(p) = o.p {
p.write(writer)?; p.write(writer)?;
} }
} }

View file

@ -951,14 +951,10 @@ where
// for backwards compatibility: If tor config doesn't exist in the file, assume // for backwards compatibility: If tor config doesn't exist in the file, assume
// the top level directory for data // the top level directory for data
let tor_config = match tor_config { let tor_config = tor_config.unwrap_or_else(|| TorConfig {
Some(tc) => tc, send_config_dir: wallet_config.data_file_dir.clone(),
None => { ..Default::default()
let mut tc = TorConfig::default(); });
tc.send_config_dir = wallet_config.data_file_dir.clone();
tc
}
};
// Instantiate wallet (doesn't open the wallet) // Instantiate wallet (doesn't open the wallet)
let wallet = let wallet =