mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
Add missing_const_for_fn clippy lint (#8498)
This commit is contained in:
@ -12,17 +12,17 @@ pub struct ParallelTrieStats {
|
||||
|
||||
impl ParallelTrieStats {
|
||||
/// Return general trie stats.
|
||||
pub fn trie_stats(&self) -> TrieStats {
|
||||
pub const fn trie_stats(&self) -> TrieStats {
|
||||
self.trie
|
||||
}
|
||||
|
||||
/// The number of pre-computed storage roots.
|
||||
pub fn precomputed_storage_roots(&self) -> u64 {
|
||||
pub const fn precomputed_storage_roots(&self) -> u64 {
|
||||
self.precomputed_storage_roots
|
||||
}
|
||||
|
||||
/// The number of added leaf nodes for which we did not precompute the storage root.
|
||||
pub fn missed_leaves(&self) -> u64 {
|
||||
pub const fn missed_leaves(&self) -> u64 {
|
||||
self.missed_leaves
|
||||
}
|
||||
}
|
||||
|
||||
@ -54,7 +54,7 @@ pub struct DatabaseHashedStorageCursor<C> {
|
||||
|
||||
impl<C> DatabaseHashedStorageCursor<C> {
|
||||
/// Create new [DatabaseHashedStorageCursor].
|
||||
pub fn new(cursor: C, hashed_address: B256) -> Self {
|
||||
pub const fn new(cursor: C, hashed_address: B256) -> Self {
|
||||
Self { cursor, hashed_address }
|
||||
}
|
||||
}
|
||||
|
||||
@ -11,7 +11,7 @@ pub struct HashedPostStateCursorFactory<'a, CF> {
|
||||
|
||||
impl<'a, CF> HashedPostStateCursorFactory<'a, CF> {
|
||||
/// Create a new factory.
|
||||
pub fn new(cursor_factory: CF, post_state: &'a HashedPostStateSorted) -> Self {
|
||||
pub const fn new(cursor_factory: CF, post_state: &'a HashedPostStateSorted) -> Self {
|
||||
Self { cursor_factory, post_state }
|
||||
}
|
||||
}
|
||||
@ -51,7 +51,7 @@ pub struct HashedPostStateAccountCursor<'b, C> {
|
||||
|
||||
impl<'b, C> HashedPostStateAccountCursor<'b, C> {
|
||||
/// Create new instance of [HashedPostStateAccountCursor].
|
||||
pub fn new(cursor: C, post_state: &'b HashedPostStateSorted) -> Self {
|
||||
pub const fn new(cursor: C, post_state: &'b HashedPostStateSorted) -> Self {
|
||||
Self { cursor, post_state, last_account: None, post_state_account_index: 0 }
|
||||
}
|
||||
|
||||
@ -195,7 +195,11 @@ pub struct HashedPostStateStorageCursor<'b, C> {
|
||||
|
||||
impl<'b, C> HashedPostStateStorageCursor<'b, C> {
|
||||
/// Create new instance of [HashedPostStateStorageCursor] for the given hashed address.
|
||||
pub fn new(cursor: C, post_state: &'b HashedPostStateSorted, hashed_address: B256) -> Self {
|
||||
pub const fn new(
|
||||
cursor: C,
|
||||
post_state: &'b HashedPostStateSorted,
|
||||
hashed_address: B256,
|
||||
) -> Self {
|
||||
Self { cursor, post_state, hashed_address, last_slot: None, post_state_storage_index: 0 }
|
||||
}
|
||||
|
||||
|
||||
@ -15,7 +15,7 @@ pub struct TrieBranchNode {
|
||||
|
||||
impl TrieBranchNode {
|
||||
/// Creates a new `TrieBranchNode`.
|
||||
pub fn new(key: Nibbles, value: B256, children_are_in_trie: bool) -> Self {
|
||||
pub const fn new(key: Nibbles, value: B256, children_are_in_trie: bool) -> Self {
|
||||
Self { key, value, children_are_in_trie }
|
||||
}
|
||||
}
|
||||
@ -48,7 +48,7 @@ pub struct TrieNodeIter<C, H: HashedCursor> {
|
||||
|
||||
impl<C, H: HashedCursor> TrieNodeIter<C, H> {
|
||||
/// Creates a new [TrieNodeIter].
|
||||
pub fn new(walker: TrieWalker<C>, hashed_cursor: H) -> Self {
|
||||
pub const fn new(walker: TrieWalker<C>, hashed_cursor: H) -> Self {
|
||||
Self {
|
||||
walker,
|
||||
hashed_cursor,
|
||||
@ -60,7 +60,7 @@ impl<C, H: HashedCursor> TrieNodeIter<C, H> {
|
||||
|
||||
/// Sets the last iterated hashed key and returns the modified [TrieNodeIter].
|
||||
/// This is used to resume iteration from the last checkpoint.
|
||||
pub fn with_last_hashed_key(mut self, previous_hashed_key: B256) -> Self {
|
||||
pub const fn with_last_hashed_key(mut self, previous_hashed_key: B256) -> Self {
|
||||
self.previous_hashed_key = Some(previous_hashed_key);
|
||||
self
|
||||
}
|
||||
|
||||
@ -19,7 +19,7 @@ pub struct PrefixSetLoader<'a, TX>(&'a TX);
|
||||
|
||||
impl<'a, TX> PrefixSetLoader<'a, TX> {
|
||||
/// Create a new loader.
|
||||
pub fn new(tx: &'a TX) -> Self {
|
||||
pub const fn new(tx: &'a TX) -> Self {
|
||||
Self(tx)
|
||||
}
|
||||
}
|
||||
|
||||
@ -30,7 +30,7 @@ pub struct Proof<'a, TX, H> {
|
||||
|
||||
impl<'a, TX> Proof<'a, TX, &'a TX> {
|
||||
/// Create a new [Proof] instance.
|
||||
pub fn new(tx: &'a TX) -> Self {
|
||||
pub const fn new(tx: &'a TX) -> Self {
|
||||
Self { tx, hashed_cursor_factory: tx }
|
||||
}
|
||||
}
|
||||
|
||||
@ -10,17 +10,17 @@ pub struct TrieStats {
|
||||
|
||||
impl TrieStats {
|
||||
/// Duration for root calculation.
|
||||
pub fn duration(&self) -> Duration {
|
||||
pub const fn duration(&self) -> Duration {
|
||||
self.duration
|
||||
}
|
||||
|
||||
/// Number of leaves added to the hash builder during the calculation.
|
||||
pub fn leaves_added(&self) -> u64 {
|
||||
pub const fn leaves_added(&self) -> u64 {
|
||||
self.leaves_added
|
||||
}
|
||||
|
||||
/// Number of branches added to the hash builder during the calculation.
|
||||
pub fn branches_added(&self) -> u64 {
|
||||
pub const fn branches_added(&self) -> u64 {
|
||||
self.branches_added
|
||||
}
|
||||
}
|
||||
|
||||
@ -49,13 +49,13 @@ impl<T, H> StateRoot<T, H> {
|
||||
}
|
||||
|
||||
/// Set the threshold.
|
||||
pub fn with_threshold(mut self, threshold: u64) -> Self {
|
||||
pub const fn with_threshold(mut self, threshold: u64) -> Self {
|
||||
self.threshold = threshold;
|
||||
self
|
||||
}
|
||||
|
||||
/// Set the threshold to maximum value so that intermediate progress is not returned.
|
||||
pub fn with_no_threshold(mut self) -> Self {
|
||||
pub const fn with_no_threshold(mut self) -> Self {
|
||||
self.threshold = u64::MAX;
|
||||
self
|
||||
}
|
||||
|
||||
@ -34,7 +34,7 @@ pub struct DatabaseAccountTrieCursor<C>(C);
|
||||
|
||||
impl<C> DatabaseAccountTrieCursor<C> {
|
||||
/// Create a new account trie cursor.
|
||||
pub fn new(cursor: C) -> Self {
|
||||
pub const fn new(cursor: C) -> Self {
|
||||
Self(cursor)
|
||||
}
|
||||
}
|
||||
@ -76,7 +76,7 @@ pub struct DatabaseStorageTrieCursor<C> {
|
||||
|
||||
impl<C> DatabaseStorageTrieCursor<C> {
|
||||
/// Create a new storage trie cursor.
|
||||
pub fn new(cursor: C, hashed_address: B256) -> Self {
|
||||
pub const fn new(cursor: C, hashed_address: B256) -> Self {
|
||||
Self { cursor, hashed_address }
|
||||
}
|
||||
}
|
||||
|
||||
@ -69,7 +69,7 @@ impl CursorSubNode {
|
||||
|
||||
/// Returns the full key of the current node.
|
||||
#[inline]
|
||||
pub fn full_key(&self) -> &Nibbles {
|
||||
pub const fn full_key(&self) -> &Nibbles {
|
||||
&self.full_key
|
||||
}
|
||||
|
||||
@ -114,7 +114,7 @@ impl CursorSubNode {
|
||||
|
||||
/// Returns the next child index to visit.
|
||||
#[inline]
|
||||
pub fn nibble(&self) -> i8 {
|
||||
pub const fn nibble(&self) -> i8 {
|
||||
self.nibble
|
||||
}
|
||||
|
||||
|
||||
@ -36,7 +36,7 @@ pub enum TrieOp {
|
||||
|
||||
impl TrieOp {
|
||||
/// Returns `true` if the operation is an update.
|
||||
pub fn is_update(&self) -> bool {
|
||||
pub const fn is_update(&self) -> bool {
|
||||
matches!(self, Self::Update(..))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user