Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clippy easy wins #596

Merged
merged 1 commit into from
Mar 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion controller/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ where
config.owner_api_listen_addr().as_str(),
g_args.api_secret.clone(),
g_args.tls_conf.clone(),
config.owner_api_include_foreign.clone(),
config.owner_api_include_foreign,
Some(tor_config.clone()),
test_mode,
);
Expand Down
27 changes: 3 additions & 24 deletions controller/src/controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -337,38 +337,17 @@ pub struct OwnerV3Helpers;
impl OwnerV3Helpers {
/// Checks whether a request is to init the secure API
pub fn is_init_secure_api(val: &serde_json::Value) -> bool {
if let Some(m) = val["method"].as_str() {
match m {
"init_secure_api" => true,
_ => false,
}
} else {
false
}
matches!(val["method"].as_str(), Some("init_secure_api"))
}

/// Checks whether a request is to open the wallet
pub fn is_open_wallet(val: &serde_json::Value) -> bool {
if let Some(m) = val["method"].as_str() {
match m {
"open_wallet" => true,
_ => false,
}
} else {
false
}
matches!(val["method"].as_str(), Some("open_wallet"))
}

/// Checks whether a request is an encrypted request
pub fn is_encrypted_request(val: &serde_json::Value) -> bool {
if let Some(m) = val["method"].as_str() {
match m {
"encrypted_request_v3" => true,
_ => false,
}
} else {
false
}
matches!(val["method"].as_str(), Some("encrypted_request_v3"))
}

/// whether encryption is enabled
Expand Down
6 changes: 2 additions & 4 deletions impls/src/adapters/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,8 @@ impl SlateGetter for PathToSlate {
let bin_res = byte_ser::from_bytes::<VersionedBinSlate>(&data);
if let Err(e) = bin_res {
debug!("Not a valid binary slate: {} - Will try JSON", e);
} else {
if let Ok(s) = bin_res {
return Ok((Slate::upgrade(s.into())?, true));
}
} else if let Ok(s) = bin_res {
return Ok((Slate::upgrade(s.into())?, true));
}

// Otherwise try json
Expand Down
2 changes: 1 addition & 1 deletion libwallet/src/api_impl/owner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -908,7 +908,7 @@ where
let mut slate = Slate::blank(2, false);
slate.tx = Some(tx.clone());
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.state = SlateState::Standard3;
Ok(Some(slate))
Expand Down
4 changes: 2 additions & 2 deletions libwallet/src/slate_versions/v4_bin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ impl<'a> Writeable for SigsWrapRef<'a> {
}
s.xs.write(writer)?;
s.nonce.write(writer)?;
if let Some(s) = s.part.clone() {
if let Some(s) = s.part {
s.write(writer)?;
}
}
Expand Down Expand Up @@ -295,7 +295,7 @@ impl<'a> Writeable for ComsWrapRef<'a> {
}
OutputFeatures::from(o.f).write(writer)?;
o.c.write(writer)?;
if let Some(p) = o.p.clone() {
if let Some(p) = o.p {
p.write(writer)?;
}
}
Expand Down
12 changes: 4 additions & 8 deletions src/cmd/wallet_args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -951,14 +951,10 @@ where

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

// Instantiate wallet (doesn't open the wallet)
let wallet =
Expand Down