Skip to content

Commit

Permalink
[meta] update to rust 1.73 (#147)
Browse files Browse the repository at this point in the history
This is bumping the rust version to the most
recent rust version (by feature that we use) before the new edition.

Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
  • Loading branch information
vincenzopalazzo authored Mar 1, 2024
1 parent 29bdf44 commit bb52d6e
Show file tree
Hide file tree
Showing 12 changed files with 17 additions and 31 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 3 additions & 9 deletions chain/src/block/cache/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(_))
});
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#![deny(missing_docs, unsafe_code)]
mod client;
mod error;
#[allow(hidden_glob_reexports)]
mod event;
mod peer;
mod service;
Expand Down
9 changes: 2 additions & 7 deletions common/src/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -29,12 +30,6 @@ impl From<Services> for ServiceFlags {
}
}

impl Default for Services {
fn default() -> Self {
Services::All
}
}

/// Bitcoin peer network.
#[derive(Debug, Copy, Clone)]
pub enum Network {
Expand Down
2 changes: 1 addition & 1 deletion net/src/simulator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion p2p/src/fsm/addrmgr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ impl<P: Store, C: Clock> AddressManager<P, C> {
// Peer misbehaving, got empty message or too many addresses.
return;
}
self.insert(addrs.into_iter(), Source::Peer(peer));
self.insert(addrs, Source::Peer(peer));
}

/// Add addresses to the address manager. The input matches that of the `addr` message
Expand Down
2 changes: 1 addition & 1 deletion p2p/src/fsm/fees.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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, _)));

Expand Down
6 changes: 1 addition & 5 deletions p2p/src/fsm/filter_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<usize>();
let size = cache.cache.values().map(|f| f.content.len()).sum::<usize>();

assert!(cache.size <= cache.capacity);
assert!(size == cache.size);
Expand Down
7 changes: 4 additions & 3 deletions p2p/src/fsm/invmgr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -594,9 +594,10 @@ mod tests {
assert!(!invmgr.remaining.is_empty());

let Some((addr, _)) = output::test::messages(&mut invmgr)
.find(|(_, m)| matches!(m, NetworkMessage::GetData(i) if i == &inv)) else {
continue;
};
.find(|(_, m)| matches!(m, NetworkMessage::GetData(i) if i == &inv))
else {
continue;
};

assert!(
clock.local_time() - last_request >= REQUEST_TIMEOUT,
Expand Down
2 changes: 1 addition & 1 deletion p2p/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.66
1.73
1 change: 0 additions & 1 deletion test/src/block.rs
Original file line number Diff line number Diff line change
@@ -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::*;

Expand Down

0 comments on commit bb52d6e

Please sign in to comment.