diff --git a/Cargo.toml b/Cargo.toml index eb7a5fad0..3ab3d6cf2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -253,7 +253,7 @@ const_is_empty = "deny" doc_lazy_continuation = "deny" doc_link_with_quotes = "deny" duplicated_attributes = "deny" -empty_enum = "deny" +empty_enums = "deny" enum_glob_use = "deny" expl_impl_clone_on_copy = "deny" explicit_into_iter_loop = "deny" @@ -395,7 +395,7 @@ return_self_not_must_use = "deny" single_match_else = "deny" string_add_assign = "deny" transmute_ptr_to_ptr = "deny" -unchecked_duration_subtraction = "deny" +unchecked_time_subtraction = "deny" unnecessary_box_returns = "deny" unnecessary_wraps = "deny" branches_sharing_code = "deny" diff --git a/clippy.toml b/clippy.toml index d558c4688..e34f4085c 100644 --- a/clippy.toml +++ b/clippy.toml @@ -4,6 +4,10 @@ upper-case-acronyms-aggressive = true # doc-valid-idents = [ "RandomX", + "PoW", + "PoWER", + "RandomX", + "EquiX", # This adds the rest of the default exceptions. ".." ] diff --git a/consensus/context/src/lib.rs b/consensus/context/src/lib.rs index d649197fe..ddf933675 100644 --- a/consensus/context/src/lib.rs +++ b/consensus/context/src/lib.rs @@ -143,21 +143,21 @@ impl BlockchainContext { /// /// ref: pub fn current_adjusted_timestamp_for_time_lock(&self) -> u64 { - if self.current_hf < HardFork::V13 || self.median_block_timestamp.is_none() { - current_unix_timestamp() - } else { - // This is safe as we just checked if this was None. - let median = self.median_block_timestamp.unwrap(); - - let adjusted_median = median - + (BLOCKCHAIN_TIMESTAMP_CHECK_WINDOW + 1) * self.current_hf.block_time().as_secs() - / 2; - - // This is safe as we just checked if the median was None and this will only be none for genesis and the first block. - let adjusted_top_block = - self.top_block_timestamp.unwrap() + self.current_hf.block_time().as_secs(); - - min(adjusted_median, adjusted_top_block) + // FIXME: use if let chain with Rust 2024. + match self.median_block_timestamp { + Some(median) if self.current_hf >= HardFork::V13 => { + let adjusted_median = median + + (BLOCKCHAIN_TIMESTAMP_CHECK_WINDOW + 1) + * self.current_hf.block_time().as_secs() + / 2; + + // This is safe as we just checked if the median was None and this will only be none for genesis and the first block. + let adjusted_top_block = + self.top_block_timestamp.unwrap() + self.current_hf.block_time().as_secs(); + + min(adjusted_median, adjusted_top_block) + } + Some(_) | None => current_unix_timestamp(), } } diff --git a/cryptonight/src/util.rs b/cryptonight/src/util.rs index 292139739..41ce64976 100644 --- a/cryptonight/src/util.rs +++ b/cryptonight/src/util.rs @@ -83,6 +83,7 @@ mod tests { } #[test] + #[expect(unused_assignments)] fn test_subarray_copy() { let mut array = [1_u8, 2, 3, 4, 5]; let sub_copied: [u8; 3] = subarray_copy(&array, 1); diff --git a/net/epee-encoding/tests/seq.rs b/net/epee-encoding/tests/seq.rs index b4ae788d7..c648ec831 100644 --- a/net/epee-encoding/tests/seq.rs +++ b/net/epee-encoding/tests/seq.rs @@ -3,7 +3,7 @@ use cuprate_epee_encoding::{epee_object, from_bytes}; struct ObjSeq { - seq: Vec, + seq: Vec, } epee_object!( diff --git a/p2p/p2p/src/broadcast.rs b/p2p/p2p/src/broadcast.rs index 09fe1f768..e79449726 100644 --- a/p2p/p2p/src/broadcast.rs +++ b/p2p/p2p/src/broadcast.rs @@ -3,7 +3,7 @@ //! This module handles broadcasting messages to multiple peers with the [`BroadcastSvc`]. use std::{ future::{ready, Future, Ready}, - pin::{pin, Pin}, + pin::Pin, task::{ready, Context, Poll}, time::Duration, }; diff --git a/p2p/p2p/src/peer_set.rs b/p2p/p2p/src/peer_set.rs index 498eaafcb..bf21ae698 100644 --- a/p2p/p2p/src/peer_set.rs +++ b/p2p/p2p/src/peer_set.rs @@ -1,6 +1,6 @@ use std::{ future::{ready, Future, Ready}, - pin::{pin, Pin}, + pin::Pin, task::{Context, Poll}, };