diff --git a/teos-common/src/receipts.rs b/teos-common/src/receipts.rs index 6e806c22..699c3c54 100644 --- a/teos-common/src/receipts.rs +++ b/teos-common/src/receipts.rs @@ -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 diff --git a/teos/src/config.rs b/teos/src/config.rs index 109dd91b..f1db3de0 100644 --- a/teos/src/config.rs +++ b/teos/src/config.rs @@ -18,13 +18,10 @@ pub fn data_dir_absolute_path(data_dir: String) -> PathBuf { pub fn from_file(path: &PathBuf) -> T { match std::fs::read(path) { - Ok(file_content) => toml::from_slice::(&file_content).map_or_else( - |e| { - eprintln!("Couldn't parse config file: {e}"); - T::default() - }, - |config| config, - ), + Ok(file_content) => toml::from_slice::(&file_content).unwrap_or_else(|e| { + eprintln!("Couldn't parse config file: {e}"); + T::default() + }), Err(_) => T::default(), } } @@ -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); } diff --git a/teos/src/tx_index.rs b/teos/src/tx_index.rs index c9d22b4e..404c0474 100644 --- a/teos/src/tx_index.rs +++ b/teos/src/tx_index.rs @@ -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)); } diff --git a/watchtower-plugin/src/main.rs b/watchtower-plugin/src/main.rs index 5778e8d0..1b845a64 100755 --- a/watchtower-plugin/src/main.rs +++ b/watchtower-plugin/src/main.rs @@ -385,7 +385,7 @@ async fn abandon_tower( ) -> Result { 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 { diff --git a/watchtower-plugin/src/retrier.rs b/watchtower-plugin/src/retrier.rs index eaf79e6e..dcbfaa66 100644 --- a/watchtower-plugin/src/retrier.rs +++ b/watchtower-plugin/src/retrier.rs @@ -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)); }