Skip to content

Commit

Permalink
Merge pull request #263 from sr-gi/202407-clippy
Browse files Browse the repository at this point in the history
Fixes clippy issues
  • Loading branch information
sr-gi authored Jul 29, 2024
2 parents e108510 + d30fc7d commit 9d0d3af
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 15 deletions.
8 changes: 4 additions & 4 deletions teos-common/src/receipts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ use crate::{cryptography, UserId};
/// Proof that a user has registered with a tower. This serves two purposes:
///
/// - First, the user is able to prove that the tower agreed on providing a service. If a tower refuses to accept appointments
/// from a user (claiming the subscription has expired) but the expiry time has still not passed and the tower cannot
/// provide the relevant appointments signed by the user, it means it is cheating.
/// from a user (claiming the subscription has expired) but the expiry time has still not passed and the tower cannot
/// provide the relevant appointments signed by the user, it means it is cheating.
/// - Second, it serves as proof, alongside an appointment receipt, that an appointment was not fulfilled. A registration receipt
/// specifies a subscription period (`subscription_start` - `subscription_expiry`) and the appointment a `start_block` so inclusion
/// can be proved.
/// specifies a subscription period (`subscription_start` - `subscription_expiry`) and the appointment a `start_block` so inclusion
/// can be proved.
///
/// TODO: / DISCUSS: In order to minimize the amount of receipts the user has to store, the tower could batch subscription receipts
/// as long as the user info is still known. That is, if a user has a subscription with range (S, E) and the user renews the subscription
Expand Down
13 changes: 5 additions & 8 deletions teos/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,10 @@ pub fn data_dir_absolute_path(data_dir: String) -> PathBuf {

pub fn from_file<T: Default + serde::de::DeserializeOwned>(path: &PathBuf) -> T {
match std::fs::read(path) {
Ok(file_content) => toml::from_slice::<T>(&file_content).map_or_else(
|e| {
eprintln!("Couldn't parse config file: {e}");
T::default()
},
|config| config,
),
Ok(file_content) => toml::from_slice::<T>(&file_content).unwrap_or_else(|e| {
eprintln!("Couldn't parse config file: {e}");
T::default()
}),
Err(_) => T::default(),
}
}
Expand Down Expand Up @@ -392,7 +389,7 @@ mod tests {
assert_eq!(config.api_bind, expected_value);

// Check the rest of fields are equal. The easiest is to just the field back and compare with a clone
config.api_bind = config_clone.api_bind.clone();
config.api_bind.clone_from(&config_clone.api_bind);
assert_eq!(config, config_clone);
}

Expand Down
2 changes: 1 addition & 1 deletion teos/src/tx_index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ mod tests {
// Check that the block data is not in the cache anymore
assert_eq!(cache.blocks().len(), cache.size - i - 1);
assert!(!cache.blocks().contains(&header.block_hash()));
assert!(cache.tx_in_block.get(&header.block_hash()).is_none());
assert!(!cache.tx_in_block.contains_key(&header.block_hash()));
for locator in locators.iter() {
assert!(!cache.contains_key(locator));
}
Expand Down
2 changes: 1 addition & 1 deletion watchtower-plugin/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ async fn abandon_tower(
) -> Result<serde_json::Value, Error> {
let tower_id = TowerId::try_from(v).map_err(|e| anyhow!(e))?;
let mut state = plugin.state().lock().unwrap();
if state.towers.get(&tower_id).is_some() {
if state.towers.contains_key(&tower_id) {
state.remove_tower(tower_id).unwrap();
Ok(json!(format!("{tower_id} successfully abandoned")))
} else {
Expand Down
2 changes: 1 addition & 1 deletion watchtower-plugin/src/retrier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ impl Retrier {
// Create a new scope so we can get all the data only locking the WTClient once.
let (tower_id, status, net_addr, user_id, user_sk, proxy) = {
let wt_client = self.wt_client.lock().unwrap();
if wt_client.towers.get(&self.tower_id).is_none() {
if !wt_client.towers.contains_key(&self.tower_id) {
return Err(Error::permanent(RetryError::Abandoned));
}

Expand Down

0 comments on commit 9d0d3af

Please sign in to comment.