mirror of
https://github.com/talaia-labs/rust-teos.git
synced 2026-08-13 12:33:22 +02:00
Fixes clippy issues
This commit is contained in:
parent
e1085104eb
commit
d30fc7d121
5 changed files with 12 additions and 15 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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(),
|
||||
}
|
||||
}
|
||||
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue