mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-02-10 15:05:24 -05:00
optimise TransactionFetcher (#6012)
Co-authored-by: zerosnacks <95942363+zerosnacks@users.noreply.github.com>
This commit is contained in:
@@ -144,6 +144,14 @@ impl NewPooledTransactionHashes {
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns a mutable reference to transaction hashes.
|
||||
pub fn hashes_mut(&mut self) -> &mut Vec<B256> {
|
||||
match self {
|
||||
NewPooledTransactionHashes::Eth66(msg) => &mut msg.0,
|
||||
NewPooledTransactionHashes::Eth68(msg) => &mut msg.hashes,
|
||||
}
|
||||
}
|
||||
|
||||
/// Consumes the type and returns all hashes
|
||||
pub fn into_hashes(self) -> Vec<B256> {
|
||||
match self {
|
||||
@@ -188,6 +196,15 @@ impl NewPooledTransactionHashes {
|
||||
NewPooledTransactionHashes::Eth68(msg) => msg.hashes.len(),
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns an iterator over tx hashes zipped with corresponding eth68 metadata if this is
|
||||
/// an eth68 message.
|
||||
pub fn as_eth68(&self) -> Option<&NewPooledTransactionHashes68> {
|
||||
match self {
|
||||
NewPooledTransactionHashes::Eth66(_) => None,
|
||||
NewPooledTransactionHashes::Eth68(msg) => Some(msg),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<NewPooledTransactionHashes> for EthMessage {
|
||||
@@ -265,6 +282,13 @@ pub struct NewPooledTransactionHashes68 {
|
||||
pub hashes: Vec<B256>,
|
||||
}
|
||||
|
||||
impl NewPooledTransactionHashes68 {
|
||||
/// Returns an iterator over tx hashes zipped with corresponding metadata.
|
||||
pub fn metadata_iter(&self) -> impl Iterator<Item = (&B256, (u8, usize))> {
|
||||
self.hashes.iter().zip(self.types.iter().copied().zip(self.sizes.iter().copied()))
|
||||
}
|
||||
}
|
||||
|
||||
impl Encodable for NewPooledTransactionHashes68 {
|
||||
fn encode(&self, out: &mut dyn bytes::BufMut) {
|
||||
#[derive(RlpEncodable)]
|
||||
|
||||
Reference in New Issue
Block a user