diff --git a/client/consensus/qpow/src/worker.rs b/client/consensus/qpow/src/worker.rs index f795b20c..cec36923 100644 --- a/client/consensus/qpow/src/worker.rs +++ b/client/consensus/qpow/src/worker.rs @@ -76,7 +76,7 @@ pub struct MiningHandle, justification_sync_link: Arc, build: Arc>>>, - block_import: Arc>>, + block_import: Arc>, } impl MiningHandle @@ -100,7 +100,7 @@ where client, justification_sync_link: Arc::new(justification_sync_link), build: Arc::new(Mutex::new(None)), - block_import: Arc::new(Mutex::new(block_import)), + block_import: Arc::new(block_import), } } @@ -193,7 +193,6 @@ where /// Submit a mined seal. The seal will be validated again. Returns true if the submission is /// successful. - #[allow(clippy::await_holding_lock)] pub async fn submit(&self, seal: Seal) -> bool { let build = if let Some(build) = { let mut build = self.build.lock(); @@ -219,7 +218,7 @@ where StateAction::ApplyChanges(StorageChanges::Changes(build.proposal.storage_changes)); let header = import_block.post_header(); - let import_result = self.block_import.lock().import_block(import_block).await; + let import_result = self.block_import.import_block(import_block).await; match import_result { Ok(res) => { diff --git a/node/src/service.rs b/node/src/service.rs index a2f1ccee..918b33c9 100644 --- a/node/src/service.rs +++ b/node/src/service.rs @@ -221,7 +221,7 @@ async fn handle_external_mining( } // Seal is valid, submit it - if futures::executor::block_on(worker_handle.submit(seal.clone())) { + if worker_handle.submit(seal.clone()).await { let mining_time = mining_start_time.elapsed().as_secs(); log::info!( "🥇 Successfully mined and submitted a new block via external miner {} (mining time: {}s)", @@ -290,7 +290,7 @@ async fn handle_local_mining( /// Submit a mined seal to the worker handle. /// /// Returns `true` if submission was successful, `false` otherwise. -fn submit_mined_block( +async fn submit_mined_block( worker_handle: &MiningHandle< Block, FullClient, @@ -301,7 +301,7 @@ fn submit_mined_block( mining_start_time: &mut std::time::Instant, source: &str, ) -> bool { - if futures::executor::block_on(worker_handle.submit(seal)) { + if worker_handle.submit(seal).await { let mining_time = mining_start_time.elapsed().as_secs(); log::info!( "🥇 Successfully mined and submitted a new block{} (mining time: {}s)", @@ -374,7 +374,7 @@ async fn mining_loop( .await; } else if let Some(seal) = handle_local_mining(&client, &worker_handle).await { // Local mining path - submit_mined_block(&worker_handle, seal, &mut mining_start_time, ""); + submit_mined_block(&worker_handle, seal, &mut mining_start_time, "").await; } // Yield to let other async tasks run