mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-01-08 23:08:19 -05:00
chore: simplify size functions (#20560)
This commit is contained in:
@@ -258,10 +258,7 @@ impl<T: TxTy> IsTyped2718 for Receipt<T> {
|
|||||||
|
|
||||||
impl<T: TxTy> InMemorySize for Receipt<T> {
|
impl<T: TxTy> InMemorySize for Receipt<T> {
|
||||||
fn size(&self) -> usize {
|
fn size(&self) -> usize {
|
||||||
self.tx_type.size() +
|
size_of::<Self>() + self.logs.iter().map(|log| log.size()).sum::<usize>()
|
||||||
core::mem::size_of::<bool>() +
|
|
||||||
core::mem::size_of::<u64>() +
|
|
||||||
self.logs.iter().map(|log| log.size()).sum::<usize>()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -472,7 +472,7 @@ impl<B: Block + Default> Default for RecoveredBlock<B> {
|
|||||||
impl<B: Block> InMemorySize for RecoveredBlock<B> {
|
impl<B: Block> InMemorySize for RecoveredBlock<B> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn size(&self) -> usize {
|
fn size(&self) -> usize {
|
||||||
self.block.size() + self.senders.len() * core::mem::size_of::<Address>()
|
self.block.size() + self.senders.capacity() * core::mem::size_of::<Address>()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ use alloy_consensus::{
|
|||||||
use alloy_eips::{eip2930::AccessList, eip7702::SignedAuthorization, Typed2718};
|
use alloy_eips::{eip2930::AccessList, eip7702::SignedAuthorization, Typed2718};
|
||||||
use alloy_primitives::{Address, Bytes, ChainId, Signature, TxKind, B256, U256};
|
use alloy_primitives::{Address, Bytes, ChainId, Signature, TxKind, B256, U256};
|
||||||
use alloy_rlp::{BufMut, Decodable, Encodable};
|
use alloy_rlp::{BufMut, Decodable, Encodable};
|
||||||
use core::mem;
|
|
||||||
use reth_ethereum::primitives::{serde_bincode_compat::RlpBincode, InMemorySize};
|
use reth_ethereum::primitives::{serde_bincode_compat::RlpBincode, InMemorySize};
|
||||||
|
|
||||||
/// A transaction with a priority fee ([EIP-1559](https://eips.ethereum.org/EIPS/eip-1559)).
|
/// A transaction with a priority fee ([EIP-1559](https://eips.ethereum.org/EIPS/eip-1559)).
|
||||||
@@ -75,17 +74,10 @@ impl TxPayment {
|
|||||||
super::tx::TxTypeCustom::Payment
|
super::tx::TxTypeCustom::Payment
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Calculates a heuristic for the in-memory size of the [TxPayment]
|
/// Calculates a heuristic for the in-memory size of the [TxPayment] transaction.
|
||||||
/// transaction.
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn size(&self) -> usize {
|
pub fn size(&self) -> usize {
|
||||||
mem::size_of::<ChainId>() + // chain_id
|
size_of::<Self>()
|
||||||
mem::size_of::<u64>() + // nonce
|
|
||||||
mem::size_of::<u64>() + // gas_limit
|
|
||||||
mem::size_of::<u128>() + // max_fee_per_gas
|
|
||||||
mem::size_of::<u128>() + // max_priority_fee_per_gas
|
|
||||||
mem::size_of::<Address>() + // to
|
|
||||||
mem::size_of::<U256>() // value
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user