Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down
4 changes: 4 additions & 0 deletions clippy.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ upper-case-acronyms-aggressive = true
# <https://rust-lang.github.io/rust-clippy/master/index.html#doc_markdown>
doc-valid-idents = [
"RandomX",
"PoW",
"PoWER",
"RandomX",
"EquiX",
# This adds the rest of the default exceptions.
".."
]
30 changes: 15 additions & 15 deletions consensus/context/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,21 +143,21 @@ impl BlockchainContext {
///
/// ref: <https://cuprate.github.io/monero-book/consensus_rules/transactions/unlock_time.html#getting-the-current-time>
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(),
}
}

Expand Down
1 change: 1 addition & 0 deletions cryptonight/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion net/epee-encoding/tests/seq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use cuprate_epee_encoding::{epee_object, from_bytes};

struct ObjSeq {
seq: Vec<ObjSeq>,
seq: Vec<Self>,
}

epee_object!(
Expand Down
2 changes: 1 addition & 1 deletion p2p/p2p/src/broadcast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down
2 changes: 1 addition & 1 deletion p2p/p2p/src/peer_set.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::{
future::{ready, Future, Ready},
pin::{pin, Pin},
pin::Pin,
task::{Context, Poll},
};

Expand Down
Loading