Skip to content

Commit

Permalink
perf: only lookup in db in cache layer (#3773)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattsse authored Jul 14, 2023
1 parent ad4c590 commit e3ac77a
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions crates/rpc/rpc/src/eth/cache/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
use futures::{future::Either, Stream, StreamExt};
use reth_interfaces::{provider::ProviderError, Result};
use reth_primitives::{Block, Receipt, SealedBlock, TransactionSigned, H256};
use reth_provider::{BlockReader, CanonStateNotification, EvmEnvProvider, StateProviderFactory};
use reth_provider::{
BlockReader, BlockSource, CanonStateNotification, EvmEnvProvider, StateProviderFactory,
};
use reth_tasks::{TaskSpawner, TokioTaskExecutor};
use revm::primitives::{BlockEnv, CfgEnv};
use schnellru::{ByLength, Limiter};
Expand Down Expand Up @@ -307,7 +309,10 @@ where
let provider = this.provider.clone();
let action_tx = this.action_tx.clone();
this.action_task_spawner.spawn_blocking(Box::pin(async move {
let res = provider.block_by_hash(block_hash);
// Only look in the database to prevent situations where we
// looking up the tree is blocking
let res = provider
.find_block_by_hash(block_hash, BlockSource::Database);
let _ = action_tx
.send(CacheAction::BlockResult { block_hash, res });
}));
Expand All @@ -325,7 +330,10 @@ where
let provider = this.provider.clone();
let action_tx = this.action_tx.clone();
this.action_task_spawner.spawn_blocking(Box::pin(async move {
let res = provider.block_by_hash(block_hash);
// Only look in the database to prevent situations where we
// looking up the tree is blocking
let res = provider
.find_block_by_hash(block_hash, BlockSource::Database);
let _ = action_tx
.send(CacheAction::BlockResult { block_hash, res });
}));
Expand Down

0 comments on commit e3ac77a

Please sign in to comment.