Skip to content

Commit

Permalink
perf(rpc-tx-helpers): simplify clones (#12800)
Browse files Browse the repository at this point in the history
  • Loading branch information
hai-rise authored Nov 23, 2024
1 parent 5db3ad1 commit 047bf86
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions crates/rpc/rpc-eth-api/src/helpers/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,22 +166,20 @@ pub trait EthTransactions: LoadTransaction<Provider: BlockReaderIdExt> {
where
Self: 'static,
{
let this = self.clone();
let provider = self.provider().clone();
self.spawn_blocking_io(move |_| {
let (tx, meta) = match this
.provider()
let (tx, meta) = match provider
.transaction_by_hash_with_meta(hash)
.map_err(Self::Error::from_eth_err)?
{
Some((tx, meta)) => (tx, meta),
None => return Ok(None),
};

let receipt =
match this.provider().receipt_by_hash(hash).map_err(Self::Error::from_eth_err)? {
Some(recpt) => recpt,
None => return Ok(None),
};
let receipt = match provider.receipt_by_hash(hash).map_err(Self::Error::from_eth_err)? {
Some(recpt) => recpt,
None => return Ok(None),
};

Ok(Some((tx, meta, receipt)))
})
Expand Down Expand Up @@ -334,7 +332,7 @@ pub trait EthTransactions: LoadTransaction<Provider: BlockReaderIdExt> {
tx: Bytes,
) -> impl Future<Output = Result<B256, Self::Error>> + Send {
async move {
let recovered = recover_raw_transaction(tx.clone())?;
let recovered = recover_raw_transaction(tx)?;
let pool_transaction =
<Self::Pool as TransactionPool>::Transaction::from_pooled(recovered.into());

Expand Down

0 comments on commit 047bf86

Please sign in to comment.