Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use tokio block_in_place in SchedulerDB #46

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading