mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
chore(reth_primitives): Use trait for size methods in primitive types (#12201)
Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
This commit is contained in:
@ -14,6 +14,7 @@ workspace = true
|
||||
[dependencies]
|
||||
# reth
|
||||
reth-primitives.workspace = true
|
||||
reth-primitives-traits.workspace = true
|
||||
reth-eth-wire-types.workspace = true
|
||||
reth-consensus.workspace = true
|
||||
reth-network-peers.workspace = true
|
||||
@ -32,7 +33,6 @@ tokio = { workspace = true, features = ["sync"] }
|
||||
auto_impl.workspace = true
|
||||
tracing.workspace = true
|
||||
derive_more.workspace = true
|
||||
|
||||
parking_lot = { workspace = true, optional = true }
|
||||
|
||||
[dev-dependencies]
|
||||
@ -47,11 +47,13 @@ test-utils = [
|
||||
"reth-consensus/test-utils",
|
||||
"parking_lot",
|
||||
"reth-network-types/test-utils",
|
||||
"reth-primitives/test-utils"
|
||||
"reth-primitives/test-utils",
|
||||
"reth-primitives-traits/test-utils"
|
||||
]
|
||||
std = [
|
||||
"reth-consensus/std",
|
||||
"reth-primitives/std",
|
||||
"alloy-eips/std",
|
||||
"alloy-primitives/std"
|
||||
"alloy-primitives/std",
|
||||
"reth-primitives-traits/std"
|
||||
]
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
use alloy_primitives::{BlockNumber, U256};
|
||||
use reth_primitives::{SealedBlock, SealedHeader};
|
||||
use reth_primitives_traits::InMemorySize;
|
||||
|
||||
/// The block response
|
||||
#[derive(PartialEq, Eq, Debug, Clone)]
|
||||
@ -19,15 +20,6 @@ impl BlockResponse {
|
||||
}
|
||||
}
|
||||
|
||||
/// Calculates a heuristic for the in-memory size of the [`BlockResponse`].
|
||||
#[inline]
|
||||
pub fn size(&self) -> usize {
|
||||
match self {
|
||||
Self::Full(block) => SealedBlock::size(block),
|
||||
Self::Empty(header) => SealedHeader::size(header),
|
||||
}
|
||||
}
|
||||
|
||||
/// Return the block number
|
||||
pub fn block_number(&self) -> BlockNumber {
|
||||
self.header().number
|
||||
@ -41,3 +33,14 @@ impl BlockResponse {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl InMemorySize for BlockResponse {
|
||||
/// Calculates a heuristic for the in-memory size of the [`BlockResponse`].
|
||||
#[inline]
|
||||
fn size(&self) -> usize {
|
||||
match self {
|
||||
Self::Full(block) => SealedBlock::size(block),
|
||||
Self::Empty(header) => SealedHeader::size(header),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user