diff --git a/crates/transaction-pool/src/lib.rs b/crates/transaction-pool/src/lib.rs index 154cabe644..296e676a0c 100644 --- a/crates/transaction-pool/src/lib.rs +++ b/crates/transaction-pool/src/lib.rs @@ -154,7 +154,7 @@ //! - `test-utils`: Export utilities for testing use crate::pool::PoolInner; use aquamarine as _; -use reth_primitives::{Address, TxHash, U256}; +use reth_primitives::{Address, BlobTransactionSidecar, TxHash, U256}; use reth_provider::StateProviderFactory; use std::{ collections::{HashMap, HashSet}, @@ -163,7 +163,7 @@ use std::{ use tokio::sync::mpsc::Receiver; use tracing::{instrument, trace}; -use crate::blobstore::BlobStore; +use crate::blobstore::{BlobStore, BlobStoreError}; pub use crate::{ config::{ PoolConfig, PriceBumpConfig, SubPoolLimit, DEFAULT_PRICE_BUMP, REPLACE_BLOB_PRICE_BUMP, @@ -458,6 +458,17 @@ where fn unique_senders(&self) -> HashSet
{ self.pool.unique_senders() } + + fn get_blob(&self, tx_hash: TxHash) -> Result, BlobStoreError> { + self.pool.blob_store().get(tx_hash) + } + + fn get_all_blobs( + &self, + tx_hashes: Vec, + ) -> Result, BlobStoreError> { + self.pool.blob_store().get_all(tx_hashes) + } } impl TransactionPoolExt for Pool diff --git a/crates/transaction-pool/src/noop.rs b/crates/transaction-pool/src/noop.rs index 0c0aa86066..027c106e99 100644 --- a/crates/transaction-pool/src/noop.rs +++ b/crates/transaction-pool/src/noop.rs @@ -4,13 +4,13 @@ //! to be generic over it. use crate::{ - error::PoolError, traits::PendingTransactionListenerKind, validate::ValidTransaction, - AllPoolTransactions, AllTransactionsEvents, BestTransactions, BlockInfo, EthPooledTransaction, - NewTransactionEvent, PoolResult, PoolSize, PoolTransaction, PropagatedTransactions, - TransactionEvents, TransactionOrigin, TransactionPool, TransactionValidationOutcome, - TransactionValidator, ValidPoolTransaction, + blobstore::BlobStoreError, error::PoolError, traits::PendingTransactionListenerKind, + validate::ValidTransaction, AllPoolTransactions, AllTransactionsEvents, BestTransactions, + BlockInfo, EthPooledTransaction, NewTransactionEvent, PoolResult, PoolSize, PoolTransaction, + PropagatedTransactions, TransactionEvents, TransactionOrigin, TransactionPool, + TransactionValidationOutcome, TransactionValidator, ValidPoolTransaction, }; -use reth_primitives::{Address, TxHash}; +use reth_primitives::{Address, BlobTransactionSidecar, TxHash}; use std::{collections::HashSet, marker::PhantomData, sync::Arc}; use tokio::sync::{mpsc, mpsc::Receiver}; @@ -162,6 +162,17 @@ impl TransactionPool for NoopTransactionPool { fn unique_senders(&self) -> HashSet
{ Default::default() } + + fn get_blob(&self, _tx_hash: TxHash) -> Result, BlobStoreError> { + Ok(None) + } + + fn get_all_blobs( + &self, + _tx_hashes: Vec, + ) -> Result, BlobStoreError> { + Ok(vec![]) + } } /// A [`TransactionValidator`] that does nothing. diff --git a/crates/transaction-pool/src/pool/mod.rs b/crates/transaction-pool/src/pool/mod.rs index 1e70b45283..3b633eec22 100644 --- a/crates/transaction-pool/src/pool/mod.rs +++ b/crates/transaction-pool/src/pool/mod.rs @@ -158,6 +158,11 @@ where } } + /// Returns the configured blob store. + pub(crate) fn blob_store(&self) -> &S { + &self.blob_store + } + /// Returns stats about the size of the pool. pub(crate) fn size(&self) -> PoolSize { self.pool.read().size() diff --git a/crates/transaction-pool/src/traits.rs b/crates/transaction-pool/src/traits.rs index 2169c70039..cc7f1ae8a5 100644 --- a/crates/transaction-pool/src/traits.rs +++ b/crates/transaction-pool/src/traits.rs @@ -20,6 +20,7 @@ use std::{ }; use tokio::sync::mpsc::Receiver; +use crate::blobstore::BlobStoreError; #[cfg(feature = "serde")] use serde::{Deserialize, Serialize}; @@ -266,6 +267,20 @@ pub trait TransactionPool: Send + Sync + Clone { /// Returns a set of all senders of transactions in the pool fn unique_senders(&self) -> HashSet
; + + /// Returns the [BlobTransactionSidecar] for the given transaction hash if it exists in the blob + /// store. + fn get_blob(&self, tx_hash: TxHash) -> Result, BlobStoreError>; + + /// Returns all [BlobTransactionSidecar] for the given transaction hashes if they exists in the + /// blob store. + /// + /// This only returns the blobs that were found in the store. + /// If there's no blob it will not be returned. + fn get_all_blobs( + &self, + tx_hashes: Vec, + ) -> Result, BlobStoreError>; } /// Extension for [TransactionPool] trait that allows to set the current block info.