mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 19:09:54 +00:00
feat: add TransactionPool blob getters (#4272)
This commit is contained in:
@ -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<Address> {
|
||||
self.pool.unique_senders()
|
||||
}
|
||||
|
||||
fn get_blob(&self, tx_hash: TxHash) -> Result<Option<BlobTransactionSidecar>, BlobStoreError> {
|
||||
self.pool.blob_store().get(tx_hash)
|
||||
}
|
||||
|
||||
fn get_all_blobs(
|
||||
&self,
|
||||
tx_hashes: Vec<TxHash>,
|
||||
) -> Result<Vec<(TxHash, BlobTransactionSidecar)>, BlobStoreError> {
|
||||
self.pool.blob_store().get_all(tx_hashes)
|
||||
}
|
||||
}
|
||||
|
||||
impl<V: TransactionValidator, T: TransactionOrdering, S> TransactionPoolExt for Pool<V, T, S>
|
||||
|
||||
@ -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<Address> {
|
||||
Default::default()
|
||||
}
|
||||
|
||||
fn get_blob(&self, _tx_hash: TxHash) -> Result<Option<BlobTransactionSidecar>, BlobStoreError> {
|
||||
Ok(None)
|
||||
}
|
||||
|
||||
fn get_all_blobs(
|
||||
&self,
|
||||
_tx_hashes: Vec<TxHash>,
|
||||
) -> Result<Vec<(TxHash, BlobTransactionSidecar)>, BlobStoreError> {
|
||||
Ok(vec![])
|
||||
}
|
||||
}
|
||||
|
||||
/// A [`TransactionValidator`] that does nothing.
|
||||
|
||||
@ -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()
|
||||
|
||||
@ -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<Address>;
|
||||
|
||||
/// Returns the [BlobTransactionSidecar] for the given transaction hash if it exists in the blob
|
||||
/// store.
|
||||
fn get_blob(&self, tx_hash: TxHash) -> Result<Option<BlobTransactionSidecar>, 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<TxHash>,
|
||||
) -> Result<Vec<(TxHash, BlobTransactionSidecar)>, BlobStoreError>;
|
||||
}
|
||||
|
||||
/// Extension for [TransactionPool] trait that allows to set the current block info.
|
||||
|
||||
Reference in New Issue
Block a user