mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 19:09:54 +00:00
perf: only check pool if disk lookup came up empty (#2973)
This commit is contained in:
@ -244,17 +244,15 @@ where
|
||||
}
|
||||
|
||||
async fn transaction_by_hash(&self, hash: H256) -> EthResult<Option<TransactionSource>> {
|
||||
if let Some(tx) = self.pool().get(&hash).map(|tx| tx.transaction.to_recovered_transaction())
|
||||
{
|
||||
return Ok(Some(TransactionSource::Pool(tx)))
|
||||
}
|
||||
|
||||
self.on_blocking_task(|this| async move {
|
||||
// Try to find the transaction on disk
|
||||
let mut resp = self
|
||||
.on_blocking_task(|this| async move {
|
||||
match this.client().transaction_by_hash_with_meta(hash)? {
|
||||
None => Ok(None),
|
||||
Some((tx, meta)) => {
|
||||
let transaction =
|
||||
tx.into_ecrecovered().ok_or(EthApiError::InvalidTransactionSignature)?;
|
||||
let transaction = tx
|
||||
.into_ecrecovered()
|
||||
.ok_or(EthApiError::InvalidTransactionSignature)?;
|
||||
|
||||
let tx = TransactionSource::Block {
|
||||
transaction,
|
||||
@ -267,7 +265,18 @@ where
|
||||
}
|
||||
}
|
||||
})
|
||||
.await
|
||||
.await?;
|
||||
|
||||
if resp.is_none() {
|
||||
// tx not found on disk, check pool
|
||||
if let Some(tx) =
|
||||
self.pool().get(&hash).map(|tx| tx.transaction.to_recovered_transaction())
|
||||
{
|
||||
resp = Some(TransactionSource::Pool(tx));
|
||||
}
|
||||
}
|
||||
|
||||
Ok(resp)
|
||||
}
|
||||
|
||||
async fn transaction_by_hash_at(
|
||||
|
||||
Reference in New Issue
Block a user