diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml index d3113f15..6500009d 100644 --- a/.github/workflows/actions.yml +++ b/.github/workflows/actions.yml @@ -47,7 +47,7 @@ jobs: - uses: actions/checkout@v2 - uses: actions-rs/toolchain@v1 with: - toolchain: 1.65 + toolchain: "1.73" profile: minimal components: clippy, rustfmt override: true diff --git a/chain/src/block/cache/test.rs b/chain/src/block/cache/test.rs index 4d6affd1..872e983a 100644 --- a/chain/src/block/cache/test.rs +++ b/chain/src/block/cache/test.rs @@ -1323,17 +1323,13 @@ fn test_cache_import_duplicate() { let a2 = a1.next(g); let a3 = a2.next(g); - assert!(matches! { - cache.import_block(a1.block(), &ctx), Ok(_) - }); + assert!(cache.import_block(a1.block(), &ctx).is_ok()); assert!(matches! { cache.import_block(a1.block(), &ctx), Err(Error::DuplicateBlock(h)) if h == a1.hash }); - assert!(matches! { - cache.import_block(a2.block(), &ctx), Ok(_) - }); + assert!(cache.import_block(a2.block(), &ctx).is_ok()); assert!(matches! { cache.import_block(a2.block(), &ctx), Err(Error::DuplicateBlock(_)) }); @@ -1343,9 +1339,7 @@ fn test_cache_import_duplicate() { // <- b3 let b3 = a1.next(g); - assert!(matches! { - cache.import_block(b3.block(), &ctx), Ok(_) - }); + assert!(cache.import_block(b3.block(), &ctx).is_ok()); assert!(matches! { cache.import_block(b3.block(), &ctx), Err(Error::DuplicateBlock(h)) if h == b3.hash diff --git a/client/src/lib.rs b/client/src/lib.rs index 77cd719d..e3269484 100644 --- a/client/src/lib.rs +++ b/client/src/lib.rs @@ -4,6 +4,7 @@ #![deny(missing_docs, unsafe_code)] mod client; mod error; +#[allow(hidden_glob_reexports)] mod event; mod peer; mod service; diff --git a/common/src/network.rs b/common/src/network.rs index b77dd9cd..7ad0e519 100644 --- a/common/src/network.rs +++ b/common/src/network.rs @@ -12,9 +12,10 @@ use bitcoin_hashes::sha256d; use crate::block::Height; /// Peer services supported by nakamoto. -#[derive(Debug, Copy, Clone)] +#[derive(Debug, Copy, Clone, Default)] pub enum Services { /// Peers with compact filter support. + #[default] All, /// Peers with only block support. Chain, @@ -29,12 +30,6 @@ impl From for ServiceFlags { } } -impl Default for Services { - fn default() -> Self { - Services::All - } -} - /// Bitcoin peer network. #[derive(Debug, Copy, Clone)] pub enum Network { diff --git a/net/src/simulator.rs b/net/src/simulator.rs index 781bb587..bed0113b 100644 --- a/net/src/simulator.rs +++ b/net/src/simulator.rs @@ -593,7 +593,7 @@ where } } Io::Event(event) => { - let events = self.events.entry(node).or_insert_with(VecDeque::new); + let events = self.events.entry(node).or_default(); if events.len() >= MAX_EVENTS { warn!(target: "sim", "Dropping event: buffer is full"); } else { diff --git a/p2p/src/fsm/addrmgr.rs b/p2p/src/fsm/addrmgr.rs index b1179501..d024766c 100644 --- a/p2p/src/fsm/addrmgr.rs +++ b/p2p/src/fsm/addrmgr.rs @@ -345,7 +345,7 @@ impl AddressManager { return; } self.insert(addrs.into_iter(), Source::Peer(peer)); - } + } /// Add addresses to the address manager. The input matches that of the `addr` message /// sent by peers on the network. diff --git a/p2p/src/fsm/fees.rs b/p2p/src/fsm/fees.rs index 96ff3282..4ec322af 100644 --- a/p2p/src/fsm/fees.rs +++ b/p2p/src/fsm/fees.rs @@ -195,7 +195,7 @@ mod tests { let estimate = fe.process(block, height as Height); estimates.insert(height, estimate); } - assert_eq!(fe.snapshots.len(), MAX_UTXO_SNAPSHOTS as usize); + assert_eq!(fe.snapshots.len(), { MAX_UTXO_SNAPSHOTS }); assert_eq!(fe.height, 21); assert_matches!(fe.snapshots.back(), Some((20, _))); diff --git a/p2p/src/fsm/filter_cache.rs b/p2p/src/fsm/filter_cache.rs index 6e7e248c..08c69e90 100644 --- a/p2p/src/fsm/filter_cache.rs +++ b/p2p/src/fsm/filter_cache.rs @@ -286,11 +286,7 @@ mod tests { for op in operations.into_iter() { op.apply(&mut cache, &mut rng); - let size = cache - .cache - .iter() - .map(|(_, f)| f.content.len()) - .sum::(); + let size = cache.cache.values().map(|f| f.content.len()).sum::(); assert!(cache.size <= cache.capacity); assert!(size == cache.size); diff --git a/p2p/src/lib.rs b/p2p/src/lib.rs index 09b7825b..72ce07f5 100644 --- a/p2p/src/lib.rs +++ b/p2p/src/lib.rs @@ -1,7 +1,7 @@ //! Nakamoto's peer-to-peer library. //! //! The `p2p` crate implements the core protocol state-machine. It can be found under the -//! [fsm](crate::fsm) module. +//! [fsm] module. //! //! Nakamoto's implementation of the peer-to-peer protocol(s) is *I/O-free*. The //! core logic is implemented as a state machine with *inputs* and *outputs* and a diff --git a/rust-toolchain b/rust-toolchain index 9cf4011b..07cde984 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -1.66 +1.75 diff --git a/test/src/block.rs b/test/src/block.rs index d8bee761..7eec966a 100644 --- a/test/src/block.rs +++ b/test/src/block.rs @@ -1,7 +1,6 @@ use std::collections::HashMap; use nakamoto_common::bitcoin::blockdata::transaction::{OutPoint, TxOut}; -use nakamoto_common::block::BlockHeader; pub use nakamoto_common::block::*;