Skip to content
Merged
Show file tree
Hide file tree
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
7 changes: 3 additions & 4 deletions client/consensus/qpow/src/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ pub struct MiningHandle<Block: BlockT, AC, L: sc_consensus::JustificationSyncLin
client: Arc<AC>,
justification_sync_link: Arc<L>,
build: Arc<Mutex<Option<MiningBuild<Block, Proof>>>>,
block_import: Arc<Mutex<BoxBlockImport<Block>>>,
block_import: Arc<BoxBlockImport<Block>>,
}

impl<Block, AC, L, Proof> MiningHandle<Block, AC, L, Proof>
Expand All @@ -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),
}
}

Expand Down Expand Up @@ -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();
Expand All @@ -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) => {
Expand Down
8 changes: 4 additions & 4 deletions node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)",
Expand Down Expand Up @@ -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,
Expand All @@ -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)",
Expand Down Expand Up @@ -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
Expand Down