From 9da47f4ebd633038ed152b794c72808adfd90d94 Mon Sep 17 00:00:00 2001 From: qima Date: Fri, 14 Jun 2024 16:43:12 +0800 Subject: [PATCH] chore: resolve clippy complaints --- sn_auditor/src/dag_db.rs | 11 ++++------- sn_networking/src/log_markers.rs | 3 ++- sn_networking/src/record_store.rs | 2 +- sn_transfers/src/cashnotes/nano.rs | 1 - sn_transfers/src/cashnotes/spend_reason.rs | 2 +- sn_transfers/src/wallet/hot_wallet.rs | 12 ++++-------- 6 files changed, 12 insertions(+), 19 deletions(-) diff --git a/sn_auditor/src/dag_db.rs b/sn_auditor/src/dag_db.rs index d287c1b81c..72b6117767 100644 --- a/sn_auditor/src/dag_db.rs +++ b/sn_auditor/src/dag_db.rs @@ -440,13 +440,10 @@ impl SpendDagDb { let mut beta_tracking = self.beta_tracking.write().await; for (hash, p) in new_participants { let unkown_str = format!("unknown participant: {hash:?}"); - let mut payments = if let Some(prev_payments) = - beta_tracking.forwarded_payments.remove(&unkown_str) - { - prev_payments - } else { - BTreeSet::new() - }; + let mut payments = beta_tracking + .forwarded_payments + .remove(&unkown_str) + .unwrap_or_default(); if let Some(existing) = beta_tracking .forwarded_payments diff --git a/sn_networking/src/log_markers.rs b/sn_networking/src/log_markers.rs index d96b755df3..0cf53c435a 100644 --- a/sn_networking/src/log_markers.rs +++ b/sn_networking/src/log_markers.rs @@ -17,7 +17,8 @@ use strum::Display; #[derive(Debug, Clone, Display, Copy)] pub enum Marker<'a> { /// Close records held (Used in VDash) - CloseRecordsLen(&'a usize), + #[allow(dead_code)] + CloseRecordsLen(usize), /// Store cost StoreCost { /// Cost diff --git a/sn_networking/src/record_store.rs b/sn_networking/src/record_store.rs index 3a38ab8116..96eacbb3ea 100644 --- a/sn_networking/src/record_store.rs +++ b/sn_networking/src/record_store.rs @@ -614,7 +614,7 @@ impl NodeRecordStore { }) .count(); - Marker::CloseRecordsLen(&relevant_records_len).log(); + Marker::CloseRecordsLen(relevant_records_len).log(); relevant_records_len } diff --git a/sn_transfers/src/cashnotes/nano.rs b/sn_transfers/src/cashnotes/nano.rs index 3624fc4260..2c9ff3e4b7 100644 --- a/sn_transfers/src/cashnotes/nano.rs +++ b/sn_transfers/src/cashnotes/nano.rs @@ -117,7 +117,6 @@ impl Display for NanoTokens { #[cfg(test)] mod tests { use super::*; - use std::u64; #[test] fn from_str() -> Result<()> { diff --git a/sn_transfers/src/cashnotes/spend_reason.rs b/sn_transfers/src/cashnotes/spend_reason.rs index ded813c7a2..157ee2d3bc 100644 --- a/sn_transfers/src/cashnotes/spend_reason.rs +++ b/sn_transfers/src/cashnotes/spend_reason.rs @@ -61,7 +61,7 @@ impl SpendReason { } } -const MAX_CIPHER_SIZE: usize = std::u8::MAX as usize; +const MAX_CIPHER_SIZE: usize = u8::MAX as usize; const DERIVATION_INDEX_SIZE: usize = 32; const HASH_SIZE: usize = 32; const CHECK_SUM_SIZE: usize = 8; diff --git a/sn_transfers/src/wallet/hot_wallet.rs b/sn_transfers/src/wallet/hot_wallet.rs index c5f2ba47c9..3706c9a49b 100644 --- a/sn_transfers/src/wallet/hot_wallet.rs +++ b/sn_transfers/src/wallet/hot_wallet.rs @@ -151,10 +151,8 @@ impl HotWallet { std::fs::create_dir_all(&wallet_dir)?; // Create the new wallet for this key store_new_keypair(&wallet_dir, &key)?; - let unconfirmed_spend_requests = match get_unconfirmed_spend_requests(&wallet_dir)? { - Some(unconfirmed_spend_requests) => unconfirmed_spend_requests, - None => Default::default(), - }; + let unconfirmed_spend_requests = + (get_unconfirmed_spend_requests(&wallet_dir)?).unwrap_or_default(); let watchonly_wallet = WatchOnlyWallet::load_from(&wallet_dir, key.main_pubkey())?; Ok(Self { @@ -667,10 +665,8 @@ impl HotWallet { } } }; - let unconfirmed_spend_requests = match get_unconfirmed_spend_requests(wallet_dir)? { - Some(unconfirmed_spend_requests) => unconfirmed_spend_requests, - None => Default::default(), - }; + let unconfirmed_spend_requests = + (get_unconfirmed_spend_requests(wallet_dir)?).unwrap_or_default(); let watchonly_wallet = WatchOnlyWallet::load_from(wallet_dir, key.main_pubkey())?; Ok(Self {