mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
feat: impl InMemorySize for PooledTx (#12791)
This commit is contained in:
@ -10,15 +10,32 @@ pub trait InMemorySize {
|
||||
|
||||
impl<T: InMemorySize> InMemorySize for alloy_consensus::Signed<T> {
|
||||
fn size(&self) -> usize {
|
||||
T::size(self.tx()) + core::mem::size_of::<Signature>() + core::mem::size_of::<TxHash>()
|
||||
T::size(self.tx()) + self.signature().size() + self.hash().size()
|
||||
}
|
||||
}
|
||||
|
||||
/// Implement `InMemorySize` for a type with `size_of`
|
||||
macro_rules! impl_in_mem_size_size_of {
|
||||
($($ty:ty),*) => {
|
||||
$(
|
||||
impl InMemorySize for $ty {
|
||||
#[inline]
|
||||
fn size(&self) -> usize {
|
||||
core::mem::size_of::<Self>()
|
||||
}
|
||||
}
|
||||
)*
|
||||
};
|
||||
}
|
||||
|
||||
impl_in_mem_size_size_of!(Signature, TxHash);
|
||||
|
||||
/// Implement `InMemorySize` for a type with a native `size` method.
|
||||
macro_rules! impl_in_mem_size {
|
||||
($($ty:ty),*) => {
|
||||
$(
|
||||
impl InMemorySize for $ty {
|
||||
#[inline]
|
||||
fn size(&self) -> usize {
|
||||
Self::size(self)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user