diff --git a/firewood/src/db.rs b/firewood/src/db.rs index ace4a7593..bf6bffb02 100644 --- a/firewood/src/db.rs +++ b/firewood/src/db.rs @@ -281,7 +281,8 @@ pub struct DbRev { #[async_trait] impl + Send + Sync> api::DbView for DbRev { async fn root_hash(&self) -> Result { - block_in_place(|| self.merkle.root_hash(self.header.kv_root)) + self.merkle + .root_hash(self.header.kv_root) .map(|h| *h) .map_err(|e| api::Error::IO(std::io::Error::new(ErrorKind::Other, e))) } @@ -414,7 +415,7 @@ impl api::Db for Db { type Proposal = proposal::Proposal; async fn revision(&self, root_hash: HashKey) -> Result, api::Error> { - let rev = block_in_place(|| self.get_revision(&TrieHash(root_hash))); + let rev = self.get_revision(&TrieHash(root_hash)); if let Some(rev) = rev { Ok(Arc::new(rev.rev)) } else { @@ -425,16 +426,14 @@ impl api::Db for Db { } async fn root_hash(&self) -> Result { - block_in_place(|| self.kv_root_hash()) - .map(|hash| hash.0) - .map_err(Into::into) + self.kv_root_hash().map(|hash| hash.0).map_err(Into::into) } async fn propose( &self, batch: api::Batch, ) -> Result { - block_in_place(|| self.new_proposal(batch)).map_err(Into::into) + self.new_proposal(batch).map_err(Into::into) } } diff --git a/firewood/src/db/proposal.rs b/firewood/src/db/proposal.rs index 33c6f25a9..a7c560aa0 100644 --- a/firewood/src/db/proposal.rs +++ b/firewood/src/db/proposal.rs @@ -57,7 +57,7 @@ impl crate::v2::api::Proposal for Proposal { self: Arc, data: api::Batch, ) -> Result { - block_in_place(|| self.propose_sync(data)).map_err(Into::into) + self.propose_sync(data).map_err(Into::into) } } diff --git a/firewood/src/storage/buffer.rs b/firewood/src/storage/buffer.rs index d691cfe53..5a6e23323 100644 --- a/firewood/src/storage/buffer.rs +++ b/firewood/src/storage/buffer.rs @@ -20,6 +20,7 @@ use growthring::{ walerror::WalError, WalFileImpl, WalStoreImpl, }; +use tokio::task::block_in_place; use tokio::{ sync::{ mpsc, @@ -588,7 +589,7 @@ impl DiskBufferRequester { .map_err(StoreError::Send) .ok(); #[allow(clippy::unwrap_used)] - resp_rx.blocking_recv().unwrap() + block_in_place(move || resp_rx.blocking_recv().unwrap()) } /// Sends a batch of writes to the buffer. @@ -622,7 +623,7 @@ impl DiskBufferRequester { .send(BufferCmd::CollectAsh(nrecords, resp_tx)) .map_err(StoreError::Send) .ok(); - resp_rx.blocking_recv().map_err(StoreError::Receive) + block_in_place(|| resp_rx.blocking_recv().map_err(StoreError::Receive)) } /// Register a cached space to the buffer.