Skip to content

Commit

Permalink
use tokio block_in_place in SchedulerDB
Browse files Browse the repository at this point in the history
  • Loading branch information
nekomoto911 committed Jan 14, 2025
1 parent 8ba091d commit 1dad8f8
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ where
fn load_cache_account(&mut self, address: Address) -> Result<&mut CacheAccount, DB::Error> {
match self.state.cache.accounts.entry(address) {
hash_map::Entry::Vacant(entry) => {
let info = self.database.basic_ref(address)?;
let info = tokio::task::block_in_place(|| self.database.basic_ref(address))?;
Ok(entry.insert(into_cache_account(info)))
}
hash_map::Entry::Occupied(entry) => Ok(entry.into_mut()),
Expand Down Expand Up @@ -355,7 +355,8 @@ where
let res = match self.state.cache.contracts.entry(code_hash) {
hash_map::Entry::Occupied(entry) => Ok(entry.get().clone()),
hash_map::Entry::Vacant(entry) => {
let code = self.database.code_by_hash_ref(code_hash)?;
let code =
tokio::task::block_in_place(|| self.database.code_by_hash_ref(code_hash))?;
entry.insert(code.clone());
Ok(code)
}
Expand All @@ -371,7 +372,8 @@ where
match self.state.block_hashes.entry(number) {
btree_map::Entry::Occupied(entry) => Ok(*entry.get()),
btree_map::Entry::Vacant(entry) => {
let ret = *entry.insert(self.database.block_hash_ref(number)?);
let ret = *entry
.insert(tokio::task::block_in_place(|| self.database.block_hash_ref(number))?);

// prune all hashes that are older than BLOCK_HASH_HISTORY
let last_block = number.saturating_sub(BLOCK_HASH_HISTORY);
Expand Down

0 comments on commit 1dad8f8

Please sign in to comment.