From 9d73a21146086cb7d47dcf33bbd6cced91b32b43 Mon Sep 17 00:00:00 2001 From: SW van Heerden Date: Wed, 29 Jan 2025 17:26:59 +0200 Subject: [PATCH] some changes --- .cargo/config.toml | 4 ++-- .github/workflows/ci.yml | 7 ++++--- .../src/authentication/basic_auth.rs | 4 ++-- .../src/parse_miner_input.rs | 2 +- .../common_types/src/types/bullet_rangeproofs.rs | 2 +- base_layer/core/src/base_node/proto/response.rs | 1 - .../state_machine_service/state_machine.rs | 1 - .../core/src/chain_storage/lmdb_db/lmdb_db.rs | 4 ++-- .../src/consensus/consensus_encoding/hashing.rs | 4 ++-- base_layer/core/src/covenants/macros.rs | 1 - base_layer/core/src/proof_of_work/difficulty.rs | 1 - base_layer/core/src/proof_of_work/lwma_diff.rs | 5 +---- .../transaction_components/transaction_output.rs | 1 - .../transaction_components/unblinded_output.rs | 1 - .../transaction_components/wallet_output.rs | 1 - base_layer/key_manager/src/mnemonic_wordlists.rs | 14 +++++++------- base_layer/mmr/src/merkle_proof.rs | 4 ++-- base_layer/mmr/src/sparse_merkle_tree/node.rs | 6 +++--- base_layer/mmr/src/sparse_merkle_tree/tree.rs | 2 +- base_layer/p2p/src/initialization.rs | 1 - base_layer/p2p/src/services/liveness/service.rs | 5 ++--- comms/core/src/connection_manager/common.rs | 4 ++-- comms/core/src/connectivity/connection_pool.rs | 2 +- comms/core/src/memsocket/mod.rs | 2 +- comms/core/src/noise/socket.rs | 2 +- comms/core/src/peer_manager/node_id.rs | 2 +- comms/core/src/protocol/rpc/body.rs | 2 +- comms/core/src/socks/client.rs | 4 ++-- .../src/test_utils/mocks/connectivity_manager.rs | 3 +-- .../src/tor/control_client/commands/del_onion.rs | 2 +- .../tor/control_client/commands/protocol_info.rs | 2 +- comms/core/src/transports/dns/tor.rs | 2 +- comms/core/src/transports/predicate.rs | 2 +- comms/dht/examples/propagation/prompt.rs | 2 +- 34 files changed, 45 insertions(+), 57 deletions(-) diff --git a/.cargo/config.toml b/.cargo/config.toml index 6c87c0b6df..c9e7e1ce57 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -5,9 +5,9 @@ linker = "aarch64-linux-gnu-gcc" linker = "riscv64-linux-gnu-gcc" [alias] -ci-fmt = "fmt --all -- --check" +ci-fmt = "+nightly fmt --all -- --check" ci-fmt-fix = "fmt --all" -ci-clippy = "lints clippy --all-targets --all-features" +ci-clippy = "lints +nightly clippy --all-targets --all-features" ci-test-compile = "test --no-run --workspace --all-features --no-default-features" ci-test = "nextest run --all-features --release --workspace --exclude tari_integration_tests --profile ci" ci-cucumber = "test --release --test cucumber --all-features --package tari_integration_tests -- -t @critical" \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 740665d46b..1fe8e9654d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,6 +15,7 @@ name: CI env: toolchain: stable + nightly_toolchain: nightly-2024-07-07 CARGO_HTTP_MULTIPLEXING: false CARGO_TERM_COLOR: always CARGO_UNSTABLE_SPARSE_REGISTRY: true @@ -36,7 +37,7 @@ jobs: steps: - name: checkout uses: actions/checkout@v4 - - name: toolchain + - name: nightly_toolchain uses: dtolnay/rust-toolchain@master with: toolchain: ${{ env.toolchain }} @@ -69,11 +70,11 @@ jobs: tari-${{ runner.os }}-${{ runner.cpu-model }}-${{ env.toolchain }}-nightly-${{ hashFiles('**/Cargo.lock') }} tari-${{ runner.os }}-${{ runner.cpu-model }}-${{ env.toolchain }}-nightly - name: cargo format - run: cargo fmt --all -- --check + run: cargo +nightly fmt --all -- --check - name: Install cargo-lints run: cargo install cargo-lints - name: Clippy check (with lints) - run: cargo lints clippy --all-targets --all-features + run: cargo +nightly lints clippy --all-targets --all-features machete: # Checks for unused dependencies. diff --git a/applications/minotari_app_grpc/src/authentication/basic_auth.rs b/applications/minotari_app_grpc/src/authentication/basic_auth.rs index d1d148e21b..5d05733b97 100644 --- a/applications/minotari_app_grpc/src/authentication/basic_auth.rs +++ b/applications/minotari_app_grpc/src/authentication/basic_auth.rs @@ -53,7 +53,7 @@ impl BasicAuthCredentials { /// Creates a new `Credentials` instance from a username and password (PHC string bytes). pub fn new(user_name: String, phc_password_hash: SafePassword) -> Result { // Validate the username is well formed - if user_name.as_bytes().len() > MAX_USERNAME_LEN { + if user_name.len() > MAX_USERNAME_LEN { return Err(BasicAuthError::InvalidUsername); } // Validate the password is a well formed byte representation of a PHC string @@ -72,7 +72,7 @@ impl BasicAuthCredentials { user_name_bytes[bytes.len()..MAX_USERNAME_LEN].clone_from_slice(&random_bytes[bytes.len()..MAX_USERNAME_LEN]); Ok(Self { - user_name_bytes_length: user_name.as_bytes().len(), + user_name_bytes_length: user_name.len(), user_name_bytes, phc_password_hash, random_bytes, diff --git a/applications/minotari_app_utilities/src/parse_miner_input.rs b/applications/minotari_app_utilities/src/parse_miner_input.rs index 5e258ea803..d7e9aff281 100644 --- a/applications/minotari_app_utilities/src/parse_miner_input.rs +++ b/applications/minotari_app_utilities/src/parse_miner_input.rs @@ -105,7 +105,7 @@ pub fn wallet_payment_address( network: Network, ) -> Result { // Verify config setting - return match TariAddress::from_str(&config_wallet_payment_address) { + match TariAddress::from_str(&config_wallet_payment_address) { Ok(address) => { if address == TariAddress::default() { println!(); diff --git a/base_layer/common_types/src/types/bullet_rangeproofs.rs b/base_layer/common_types/src/types/bullet_rangeproofs.rs index 52b5b27769..28953a884d 100644 --- a/base_layer/common_types/src/types/bullet_rangeproofs.rs +++ b/base_layer/common_types/src/types/bullet_rangeproofs.rs @@ -101,7 +101,7 @@ impl<'de> Deserialize<'de> for BulletRangeProof { where D: Deserializer<'de> { struct RangeProofVisitor; - impl<'de> Visitor<'de> for RangeProofVisitor { + impl Visitor<'_> for RangeProofVisitor { type Value = BulletRangeProof; fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { diff --git a/base_layer/core/src/base_node/proto/response.rs b/base_layer/core/src/base_node/proto/response.rs index 87a4956541..223c373f76 100644 --- a/base_layer/core/src/base_node/proto/response.rs +++ b/base_layer/core/src/base_node/proto/response.rs @@ -86,7 +86,6 @@ impl TryFrom for ProtoNodeCommsResponse { .map(TryInto::try_into) .collect::, _>>()? .into_iter() - .map(Into::into) .collect(); Ok(ProtoNodeCommsResponse::HistoricalBlocks(historical_blocks)) }, diff --git a/base_layer/core/src/base_node/state_machine_service/state_machine.rs b/base_layer/core/src/base_node/state_machine_service/state_machine.rs index dd55ecb9f1..59735a571a 100644 --- a/base_layer/core/src/base_node/state_machine_service/state_machine.rs +++ b/base_layer/core/src/base_node/state_machine_service/state_machine.rs @@ -105,7 +105,6 @@ pub struct BaseNodeStateMachine { impl BaseNodeStateMachine { /// Instantiate a new Base Node. - pub fn new( db: AsyncBlockchainDb, local_node_interface: LocalNodeCommsInterface, diff --git a/base_layer/core/src/chain_storage/lmdb_db/lmdb_db.rs b/base_layer/core/src/chain_storage/lmdb_db/lmdb_db.rs index 2cd0020d45..556b8464f9 100644 --- a/base_layer/core/src/chain_storage/lmdb_db/lmdb_db.rs +++ b/base_layer/core/src/chain_storage/lmdb_db/lmdb_db.rs @@ -1641,7 +1641,7 @@ impl LMDBDatabase { txn: &ConstTransaction<'_>, height: u64, ) -> Result, ChainStorageError> { - lmdb_get(txn, &self.block_accumulated_data_db, &height).map_err(Into::into) + lmdb_get(txn, &self.block_accumulated_data_db, &height) } #[allow(clippy::ptr_arg)] @@ -1650,7 +1650,7 @@ impl LMDBDatabase { txn: &ConstTransaction<'_>, header_hash: &HashOutput, ) -> Result, ChainStorageError> { - lmdb_get(txn, &self.block_hashes_db, header_hash.as_slice()).map_err(Into::into) + lmdb_get(txn, &self.block_hashes_db, header_hash.as_slice()) } fn fetch_header_accumulated_data_by_height( diff --git a/base_layer/core/src/consensus/consensus_encoding/hashing.rs b/base_layer/core/src/consensus/consensus_encoding/hashing.rs index 811cdc8d40..ae916bc249 100644 --- a/base_layer/core/src/consensus/consensus_encoding/hashing.rs +++ b/base_layer/core/src/consensus/consensus_encoding/hashing.rs @@ -105,7 +105,7 @@ mod tests { // Script is chosen because the consensus encoding impl for TariScript has 2 writes let mut hasher = Blake2b::::default(); - TestHashDomain::add_domain_separation_tag(&mut hasher, &format!("{}.n{}", "foo", network.as_byte())); + TestHashDomain::add_domain_separation_tag(&mut hasher, format!("{}.n{}", "foo", network.as_byte())); let expected_hash = hasher.chain_update(b"\xff\x00\x00\x00\x00\x00\x00\x00").finalize(); let hash = DomainSeparatedConsensusHasher::>::new("foo") @@ -122,7 +122,7 @@ mod tests { // Script is chosen because the consensus encoding impl for TariScript has 2 writes let test_subject = script!(Nop).unwrap(); let mut hasher = Blake2b::::default(); - TestHashDomain::add_domain_separation_tag(&mut hasher, &format!("{}.n{}", "foo", network.as_byte())); + TestHashDomain::add_domain_separation_tag(&mut hasher, format!("{}.n{}", "foo", network.as_byte())); let expected_hash = hasher.chain_update(b"\x01\x73").finalize(); let hash = DomainSeparatedConsensusHasher::>::new("foo") diff --git a/base_layer/core/src/covenants/macros.rs b/base_layer/core/src/covenants/macros.rs index c3fbb06904..fb5e69abda 100644 --- a/base_layer/core/src/covenants/macros.rs +++ b/base_layer/core/src/covenants/macros.rs @@ -36,7 +36,6 @@ /// let covenant = covenant!(or(absolute_height(@uint(42)), field_eq(@field::features_flags, @uint(8)))).unwrap(); /// covenant.execute(...)?; /// ``` - #[macro_export] macro_rules! covenant { ($token:ident($($args:tt)*)) => {{ diff --git a/base_layer/core/src/proof_of_work/difficulty.rs b/base_layer/core/src/proof_of_work/difficulty.rs index c90fc69afd..9295ae2c29 100644 --- a/base_layer/core/src/proof_of_work/difficulty.rs +++ b/base_layer/core/src/proof_of_work/difficulty.rs @@ -106,7 +106,6 @@ impl Difficulty { /// - `Div for Difficulty` `/` must not be used at all; difficulties should only be added to or subtracted from /// - `From for Difficulty` `Difficulty::from` must not be used, use `from_u64(value)` instead; to prevent /// assignment `< MIN_DIFFICULTY` - impl Default for Difficulty { fn default() -> Self { Difficulty::min() diff --git a/base_layer/core/src/proof_of_work/lwma_diff.rs b/base_layer/core/src/proof_of_work/lwma_diff.rs index 9d06b19e21..086a4037b6 100644 --- a/base_layer/core/src/proof_of_work/lwma_diff.rs +++ b/base_layer/core/src/proof_of_work/lwma_diff.rs @@ -102,10 +102,7 @@ impl LinearWeightedMovingAverage { if *timestamp > previous_timestamp { this_timestamp = *timestamp; } else { - this_timestamp = match previous_timestamp.checked_add(EpochTime::from(1)) { - Some(t) => t, - None => return None, - }; + this_timestamp = previous_timestamp.checked_add(EpochTime::from(1))?; } let solve_time = min( this_timestamp diff --git a/base_layer/core/src/transactions/transaction_components/transaction_output.rs b/base_layer/core/src/transactions/transaction_components/transaction_output.rs index 9011e1a40c..fe76c28722 100644 --- a/base_layer/core/src/transactions/transaction_components/transaction_output.rs +++ b/base_layer/core/src/transactions/transaction_components/transaction_output.rs @@ -105,7 +105,6 @@ pub struct TransactionOutput { /// An output for a transaction, includes a range proof and Tari script metadata impl TransactionOutput { /// Create new Transaction Output - pub fn new( version: TransactionOutputVersion, features: OutputFeatures, diff --git a/base_layer/core/src/transactions/transaction_components/unblinded_output.rs b/base_layer/core/src/transactions/transaction_components/unblinded_output.rs index ca1de74b3e..1b9cb26159 100644 --- a/base_layer/core/src/transactions/transaction_components/unblinded_output.rs +++ b/base_layer/core/src/transactions/transaction_components/unblinded_output.rs @@ -71,7 +71,6 @@ pub struct UnblindedOutput { impl UnblindedOutput { /// Creates a new un-blinded output - #[allow(clippy::too_many_arguments)] pub fn new( version: TransactionOutputVersion, diff --git a/base_layer/core/src/transactions/transaction_components/wallet_output.rs b/base_layer/core/src/transactions/transaction_components/wallet_output.rs index 6380387fc2..efc9448c86 100644 --- a/base_layer/core/src/transactions/transaction_components/wallet_output.rs +++ b/base_layer/core/src/transactions/transaction_components/wallet_output.rs @@ -77,7 +77,6 @@ pub struct WalletOutput { impl WalletOutput { /// Creates a new wallet output - #[allow(clippy::too_many_arguments)] pub async fn new( version: TransactionOutputVersion, diff --git a/base_layer/key_manager/src/mnemonic_wordlists.rs b/base_layer/key_manager/src/mnemonic_wordlists.rs index 4349d829fe..9a9c75857e 100644 --- a/base_layer/key_manager/src/mnemonic_wordlists.rs +++ b/base_layer/key_manager/src/mnemonic_wordlists.rs @@ -8,7 +8,7 @@ /// A sorted mnemonic word list of 2048 characters for the Chinese Simplified language #[rustfmt::skip] -pub const MNEMONIC_CHINESE_SIMPLIFIED_WORDS: [&str; 2048] = [ +pub static MNEMONIC_CHINESE_SIMPLIFIED_WORDS: [&str; 2048] = [ "一", "丁", "七", "万", "丈", "三", "上", "下", "不", "与", "专", "且", "世", "丘", "丙", "业", "丛", "东", "丝", "丢", "两", "严", "丧", "个", "中", "丰", "串", "临", "丹", "为", "主", "丽", "举", "乃", "久", "么", "义", "之", "乌", "乎", "乏", "乐", "乔", "乘", "乙", "九", "也", "习", @@ -141,7 +141,7 @@ pub const MNEMONIC_CHINESE_SIMPLIFIED_WORDS: [&str; 2048] = [ /// A sorted mnemonic word list of 2048 words from the English language #[rustfmt::skip] -pub const MNEMONIC_ENGLISH_WORDS: [&str; 2048] = [ +pub static MNEMONIC_ENGLISH_WORDS: [&str; 2048] = [ "abandon", "ability", "able", "about", "above", "absent", "absorb", "abstract", "absurd", "abuse", "access", "accident", "account", "accuse", "achieve", "acid", "acoustic", "acquire", "across", "act", "action", "actor", "actress", "actual", "adapt", "add", "addict", "address", "adjust", "admit", "adult", "advance", "advice", "aerobic", "affair", "afford", "afraid", "again", "age", "agent", "agree", "ahead", "aim", "air", "airport", "aisle", "alarm", "album", @@ -274,7 +274,7 @@ pub const MNEMONIC_ENGLISH_WORDS: [&str; 2048] = [ /// A sorted mnemonic word list of 2048 words from the French language #[rustfmt::skip] -pub const MNEMONIC_FRENCH_WORDS: [&str; 2048] = [ +pub static MNEMONIC_FRENCH_WORDS: [&str; 2048] = [ "abaisser", "abandon", "abdiquer", "abeille", "abolir", "aborder", "aboutir", "aboyer", "abrasif", "abreuver", "abriter", "abroger", "abrupt", "absence", "absolu", "absurde", "abusif", "abyssal", "academie", "acajou", "acarien", "accabler", "accepter", "acclamer", "accolade", "accroche", "accuser", "acerbe", "achat", "acheter", "aciduler", "acier", "acompte", "acquerir", "acronyme", "acteur", "actif", "actuel", "adepte", "adequat", "adhesif", "adjectif", "adjuger", "admettre", "admirer", "adopter", "adorer", "adoucir", @@ -407,7 +407,7 @@ pub const MNEMONIC_FRENCH_WORDS: [&str; 2048] = [ /// A sorted mnemonic word list of 2048 words from the Italian language #[rustfmt::skip] -pub const MNEMONIC_ITALIAN_WORDS: [&str; 2048] = [ +pub static MNEMONIC_ITALIAN_WORDS: [&str; 2048] = [ "abaco", "abbaglio", "abbinato", "abete", "abisso", "abolire", "abrasivo", "abrogato", "accadere", "accenno", "accusato", "acetone", "achille", "acido", "acqua", "acre", "acrilico", "acrobata", "acuto", "adagio", "addebito", "addome", "adeguato", "aderire", "adipe", "adottare", "adulare", "affabile", "affetto", "affisso", "affranto", "aforisma", "afoso", "africano", "agave", "agente", "agevole", "aggancio", "agire", "agitare", "agonismo", "agricolo", "agrumeto", "aguzzo", "alabarda", "alato", "albatro", "alberato", @@ -540,7 +540,7 @@ pub const MNEMONIC_ITALIAN_WORDS: [&str; 2048] = [ /// A sorted mnemonic word list of 2048 words from the Japanese language #[rustfmt::skip] -pub const MNEMONIC_JAPANESE_WORDS: [&str; 2048] = [ +pub static MNEMONIC_JAPANESE_WORDS: [&str; 2048] = [ "あいこくしん", "あいさつ", "あいだ", "あおぞら", "あかちゃん", "あきる", "あけがた", "あける", "あこがれる", "あさい", "あさひ", "あしあと", "あじわう", "あずかる", "あずき", "あそぶ", "あたえる", "あたためる", "あたりまえ", "あたる", "あっしゅく", "あつい", "あつかう", "あつまり", "あつめる", "あてな", "あてはまる", "あひる", "あふれる", "あぶら", "あぶる", "あまい", "あまど", "あまやかす", "あまり", "あみもの", "あめりか", "あやまる", "あゆむ", "あらいぐま", "あらし", "あらすじ", "あらためる", "あらゆる", "あらわす", "ありがとう", "あわせる", "あわてる", @@ -673,7 +673,7 @@ pub const MNEMONIC_JAPANESE_WORDS: [&str; 2048] = [ /// A sorted mnemonic word list of 2048 words from the Korean language #[rustfmt::skip] -pub const MNEMONIC_KOREAN_WORDS: [&str; 2048] = [ +pub static MNEMONIC_KOREAN_WORDS: [&str; 2048] = [ "가격", "가끔", "가난", "가능", "가득", "가르침", "가뭄", "가방", "가상", "가슴", "가운데", "가을", "가이드", "가입", "가장", "가정", "가족", "가죽", "각오", "각자", "간격", "간부", "간섭", "간장", "간접", "간판", "갈등", "갈비", "갈색", "갈증", "감각", "감기", "감소", "감수성", "감자", "감정", "갑자기", "강남", "강당", "강도", "강력히", "강변", "강북", "강사", "강수량", "강아지", "강원도", "강의", @@ -806,7 +806,7 @@ pub const MNEMONIC_KOREAN_WORDS: [&str; 2048] = [ /// A sorted mnemonic word list of 2048 words from the Spanish language #[rustfmt::skip] -pub const MNEMONIC_SPANISH_WORDS: [&str; 2048] = [ +pub static MNEMONIC_SPANISH_WORDS: [&str; 2048] = [ "abaco", "abdomen", "abeja", "abierto", "abogado", "abono", "aborto", "abrazo", "abrir", "abuelo", "abuso", "acabar", "academia", "acceso", "accion", "aceite", "acelga", "acento", "aceptar", "acido", "aclarar", "acne", "acoger", "acoso", "activo", "acto", "actriz", "actuar", "acudir", "acuerdo", "acusar", "adicto", "admitir", "adoptar", "adorno", "aduana", "adulto", "aereo", "afectar", "aficion", "afinar", "afirmar", "agil", "agitar", "agonia", "agosto", "agotar", "agregar", diff --git a/base_layer/mmr/src/merkle_proof.rs b/base_layer/mmr/src/merkle_proof.rs index d695018f03..9a57c7e658 100644 --- a/base_layer/mmr/src/merkle_proof.rs +++ b/base_layer/mmr/src/merkle_proof.rs @@ -259,12 +259,12 @@ impl Display for MerkleProof { self.path .iter() .enumerate() - .fold(Ok(()), |_, (i, h)| f.write_str(&format!("{:3}: {}\n", i, h.to_hex())))?; + .try_fold((), |_, (i, h)| f.write_str(&format!("{:3}: {}\n", i, h.to_hex())))?; f.write_str("Peaks:\n")?; self.peaks .iter() .enumerate() - .fold(Ok(()), |_, (i, h)| f.write_str(&format!("{:3}: {}\n", i, h.to_hex())))?; + .try_fold((), |_, (i, h)| f.write_str(&format!("{:3}: {}\n", i, h.to_hex())))?; Ok(()) } } diff --git a/base_layer/mmr/src/sparse_merkle_tree/node.rs b/base_layer/mmr/src/sparse_merkle_tree/node.rs index 6d17a1426f..c97366cf2f 100644 --- a/base_layer/mmr/src/sparse_merkle_tree/node.rs +++ b/base_layer/mmr/src/sparse_merkle_tree/node.rs @@ -136,7 +136,7 @@ impl PathIterator<'_> { } } -impl<'a> Iterator for PathIterator<'a> { +impl Iterator for PathIterator<'_> { type Item = TraverseDirection; fn next(&mut self) -> Option { @@ -155,7 +155,7 @@ impl<'a> Iterator for PathIterator<'a> { } } -impl<'a> DoubleEndedIterator for PathIterator<'a> { +impl DoubleEndedIterator for PathIterator<'_> { fn next_back(&mut self) -> Option { if self.cursor_front >= self.cursor_back { return None; @@ -171,7 +171,7 @@ impl<'a> DoubleEndedIterator for PathIterator<'a> { } } -impl<'a> ExactSizeIterator for PathIterator<'a> { +impl ExactSizeIterator for PathIterator<'_> { fn len(&self) -> usize { self.cursor_back.saturating_sub(self.cursor_front) } diff --git a/base_layer/mmr/src/sparse_merkle_tree/tree.rs b/base_layer/mmr/src/sparse_merkle_tree/tree.rs index 73366350f3..b825b16acd 100644 --- a/base_layer/mmr/src/sparse_merkle_tree/tree.rs +++ b/base_layer/mmr/src/sparse_merkle_tree/tree.rs @@ -82,7 +82,7 @@ struct TerminalBranch<'a, H> { empty_siblings: Vec, } -impl<'a, H: Digest> TerminalBranch<'a, H> { +impl> TerminalBranch<'_, H> { /// Returns the terminal node of the branch pub fn terminal(&self) -> &Node { let branch = self.parent.as_branch().unwrap(); diff --git a/base_layer/p2p/src/initialization.rs b/base_layer/p2p/src/initialization.rs index b5cfbae70b..f9d52ed3c2 100644 --- a/base_layer/p2p/src/initialization.rs +++ b/base_layer/p2p/src/initialization.rs @@ -482,7 +482,6 @@ impl P2pInitializer { .map(|s| SeedPeer::from_str(s)) .map(|r| r.map(Peer::from)) .collect::, _>>() - .map_err(Into::into) } async fn try_resolve_dns_seeds(config: &PeerSeedsConfig) -> Result, ServiceInitializationError> { diff --git a/base_layer/p2p/src/services/liveness/service.rs b/base_layer/p2p/src/services/liveness/service.rs index 794f9d16c3..1d8693445c 100644 --- a/base_layer/p2p/src/services/liveness/service.rs +++ b/base_layer/p2p/src/services/liveness/service.rs @@ -37,7 +37,7 @@ use tari_comms::{ }; use tari_comms_dht::{ domain_message::OutboundDomainMessage, - outbound::{DhtOutboundError, OutboundMessageRequester}, + outbound::{OutboundMessageRequester}, }; use tari_service_framework::reply_channel::RequestContext; use tari_shutdown::ShutdownSignal; @@ -257,8 +257,7 @@ where OutboundDomainMessage::new(&TariMessageType::PingPong, msg), "Send ping".to_string(), ) - .await - .map_err(Into::::into)?; + .await?; Ok(nonce) } diff --git a/comms/core/src/connection_manager/common.rs b/comms/core/src/connection_manager/common.rs index 0a95a51d8f..89e0d232bd 100644 --- a/comms/core/src/connection_manager/common.rs +++ b/comms/core/src/connection_manager/common.rs @@ -141,9 +141,9 @@ pub(super) fn validate_peer_identity_message( .into()); } - if user_agent.as_bytes().len() > config.max_user_agent_byte_length { + if user_agent.len() > config.max_user_agent_byte_length { return Err(PeerValidatorError::PeerIdentityUserAgentTooLong { - length: user_agent.as_bytes().len(), + length: user_agent.len(), max: config.max_user_agent_byte_length, } .into()); diff --git a/comms/core/src/connectivity/connection_pool.rs b/comms/core/src/connectivity/connection_pool.rs index eb55cf0bd6..d674c7a66e 100644 --- a/comms/core/src/connectivity/connection_pool.rs +++ b/comms/core/src/connectivity/connection_pool.rs @@ -64,7 +64,7 @@ impl PeerConnectionState { /// Return true if the underlying connection exists and is connected, otherwise false pub fn is_connected(&self) -> bool { - self.status.is_connected() && self.connection().map_or(false, |c| c.is_connected()) + self.status.is_connected() && self.connection().is_some_and(|c| c.is_connected()) } pub fn connection_mut(&mut self) -> Option<&mut PeerConnection> { diff --git a/comms/core/src/memsocket/mod.rs b/comms/core/src/memsocket/mod.rs index 62fc050081..863ca09752 100644 --- a/comms/core/src/memsocket/mod.rs +++ b/comms/core/src/memsocket/mod.rs @@ -289,7 +289,7 @@ pub struct Incoming<'a> { inner: &'a mut MemoryListener, } -impl<'a> Stream for Incoming<'a> { +impl Stream for Incoming<'_> { type Item = io::Result; fn poll_next(mut self: Pin<&mut Self>, context: &mut Context) -> Poll> { diff --git a/comms/core/src/noise/socket.rs b/comms/core/src/noise/socket.rs index bbe3be4b1f..e70fe992ce 100644 --- a/comms/core/src/noise/socket.rs +++ b/comms/core/src/noise/socket.rs @@ -583,7 +583,7 @@ where TSocket: AsyncRead + AsyncWrite + Unpin } async fn flush(&mut self) -> io::Result<()> { - self.socket.flush().await.map_err(Into::into) + self.socket.flush().await } async fn receive(&mut self) -> io::Result { diff --git a/comms/core/src/peer_manager/node_id.rs b/comms/core/src/peer_manager/node_id.rs index f64dbca897..421660d4c7 100644 --- a/comms/core/src/peer_manager/node_id.rs +++ b/comms/core/src/peer_manager/node_id.rs @@ -248,7 +248,7 @@ where D: Deserializer<'de> { marker: PhantomData, } - impl<'de> de::Visitor<'de> for KeyStringVisitor { + impl de::Visitor<'_> for KeyStringVisitor { type Value = NodeId; fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { diff --git a/comms/core/src/protocol/rpc/body.rs b/comms/core/src/protocol/rpc/body.rs index fcf1060d42..d44172e0f5 100644 --- a/comms/core/src/protocol/rpc/body.rs +++ b/comms/core/src/protocol/rpc/body.rs @@ -188,7 +188,7 @@ impl BodyBytes { #[allow(clippy::from_over_into)] impl Into for BodyBytes { fn into(self) -> Bytes { - self.0.map(Bytes::from).unwrap_or_default() + self.0.unwrap_or_default() } } diff --git a/comms/core/src/socks/client.rs b/comms/core/src/socks/client.rs index 90f71eeef6..5ef7b6e321 100644 --- a/comms/core/src/socks/client.rs +++ b/comms/core/src/socks/client.rs @@ -143,13 +143,13 @@ where TSocket: AsyncRead + AsyncWrite + Unpin match auth { Authentication::None => {}, Authentication::Password { username, password } => { - let username_len = username.as_bytes().len(); + let username_len = username.len(); if !(1..=255).contains(&username_len) { return Err(SocksError::InvalidAuthValues( "username length should between 1 to 255".to_string(), )); } - let password_len = password.as_bytes().len(); + let password_len = password.len(); if !(1..=255).contains(&password_len) { return Err(SocksError::InvalidAuthValues( "password length should between 1 to 255".to_string(), diff --git a/comms/core/src/test_utils/mocks/connectivity_manager.rs b/comms/core/src/test_utils/mocks/connectivity_manager.rs index b66cdaa523..73bec55db5 100644 --- a/comms/core/src/test_utils/mocks/connectivity_manager.rs +++ b/comms/core/src/test_utils/mocks/connectivity_manager.rs @@ -254,8 +254,7 @@ impl ConnectivityManagerMock { .active_conns .get(&node_id) .cloned() - .ok_or(ConnectionManagerError::DialConnectFailedAllAddresses) - .map_err(Into::into), + .ok_or(ConnectionManagerError::DialConnectFailedAllAddresses), ); }, }) diff --git a/comms/core/src/tor/control_client/commands/del_onion.rs b/comms/core/src/tor/control_client/commands/del_onion.rs index fd3fd6c214..7476d7a367 100644 --- a/comms/core/src/tor/control_client/commands/del_onion.rs +++ b/comms/core/src/tor/control_client/commands/del_onion.rs @@ -37,7 +37,7 @@ impl<'a> DelOnion<'a> { } } -impl<'a> TorCommand for DelOnion<'a> { +impl TorCommand for DelOnion<'_> { type Error = TorClientError; type Output = (); diff --git a/comms/core/src/tor/control_client/commands/protocol_info.rs b/comms/core/src/tor/control_client/commands/protocol_info.rs index bcb49bc967..87dff64292 100644 --- a/comms/core/src/tor/control_client/commands/protocol_info.rs +++ b/comms/core/src/tor/control_client/commands/protocol_info.rs @@ -41,7 +41,7 @@ impl ProtocolInfo<'_> { } } -impl<'a> TorCommand for ProtocolInfo<'a> { +impl TorCommand for ProtocolInfo<'_> { type Error = TorClientError; type Output = ProtocolInfoResponse; diff --git a/comms/core/src/transports/dns/tor.rs b/comms/core/src/transports/dns/tor.rs index 04d59ae4ec..fd7e0f9bb2 100644 --- a/comms/core/src/transports/dns/tor.rs +++ b/comms/core/src/transports/dns/tor.rs @@ -80,7 +80,7 @@ impl DnsResolver for TorDnsResolver { } else { addr }; - common::convert_tcpip_multiaddr_to_socketaddr(&addr).map_err(Into::into) + common::convert_tcpip_multiaddr_to_socketaddr(&addr) }) } } diff --git a/comms/core/src/transports/predicate.rs b/comms/core/src/transports/predicate.rs index b16330661f..1df51fc287 100644 --- a/comms/core/src/transports/predicate.rs +++ b/comms/core/src/transports/predicate.rs @@ -41,7 +41,7 @@ where #[derive(Debug, Default)] pub struct FalsePredicate<'a, A>(PhantomData<&'a A>); -impl<'a, A> FalsePredicate<'a, A> { +impl FalsePredicate<'_, A> { pub fn new() -> Self { Self(PhantomData) } diff --git a/comms/dht/examples/propagation/prompt.rs b/comms/dht/examples/propagation/prompt.rs index f60c8ea831..5ccd0fc115 100644 --- a/comms/dht/examples/propagation/prompt.rs +++ b/comms/dht/examples/propagation/prompt.rs @@ -87,7 +87,7 @@ pub fn user_prompt(node_identity: &Arc) -> anyhow::Result('n')); - if ans.to_ascii_uppercase() != 'Y' { + if !ans.eq_ignore_ascii_case(&'Y') { continue; }