rpc: add missing fields in send_transaction (#1976)

Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
This commit is contained in:
Bharath Vedartham
2023-04-02 21:17:45 +05:30
committed by GitHub
parent 7c6c0b41e8
commit 481f60acee
7 changed files with 130 additions and 14 deletions

View File

@ -96,7 +96,7 @@ use crate::{
pool::PoolInner,
traits::{NewTransactionEvent, PoolSize},
};
use reth_primitives::{TxHash, U256};
use reth_primitives::{Address, TxHash, U256};
use reth_provider::StateProviderFactory;
use std::{collections::HashMap, sync::Arc};
use tokio::sync::mpsc::Receiver;
@ -325,6 +325,18 @@ where
fn on_propagated(&self, txs: PropagatedTransactions) {
self.inner().on_propagated(txs)
}
fn get_transactions_by_sender(
&self,
sender: Address,
) -> Vec<Arc<ValidPoolTransaction<Self::Transaction>>> {
self.pool
.pooled_transactions()
.iter()
.filter(|tx| tx.transaction.sender().eq(&sender))
.map(Arc::clone)
.collect()
}
}
impl<V: TransactionValidator, T: TransactionOrdering> Clone for Pool<V, T> {

View File

@ -374,6 +374,18 @@ where
self.pool.read().get(tx_hash)
}
/// Returns all transactions of the address
pub(crate) fn get_transactions_by_sender(
&self,
sender: Address,
) -> Vec<Arc<ValidPoolTransaction<T::Transaction>>> {
self.pooled_transactions()
.iter()
.filter(|tx| tx.transaction.sender().eq(&sender))
.map(Arc::clone)
.collect()
}
/// Returns all the transactions belonging to the hashes.
///
/// If no transaction exists, it is skipped.

View File

@ -145,6 +145,12 @@ pub trait TransactionPool: Send + Sync + Clone {
///
/// Consumer: P2P
fn on_propagated(&self, txs: PropagatedTransactions);
/// Returns all transactions sent by a given user
fn get_transactions_by_sender(
&self,
sender: Address,
) -> Vec<Arc<ValidPoolTransaction<Self::Transaction>>>;
}
/// Represents a transaction that was propagated over the network.