Skip to content

Commit

Permalink
Clippy easy wins 1 (#596)
Browse files Browse the repository at this point in the history
  • Loading branch information
trevyn authored Mar 17, 2021
1 parent 4e4880b commit a88a522
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 40 deletions.
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

0 comments on commit a88a522

Please sign in to comment.