From a3758161ac8eb3fb3886f17c8af686a51ca87555 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Tue, 28 Jun 2016 18:46:09 +0200 Subject: [PATCH] Ensure we always get the latest work when mining on submitted. (#1469) * Ensure we always get the latest work when mining on submitted. * Build fix. * Smaller timeslices for the wait. --- rpc/src/v1/impls/eth.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/rpc/src/v1/impls/eth.rs b/rpc/src/v1/impls/eth.rs index 9b1f06416..05dc89564 100644 --- a/rpc/src/v1/impls/eth.rs +++ b/rpc/src/v1/impls/eth.rs @@ -18,6 +18,8 @@ extern crate ethash; +use std::thread; +use std::time::{Instant, Duration}; use std::sync::{Arc, Weak, Mutex}; use std::ops::Deref; use ethsync::{SyncProvider, SyncState}; @@ -479,6 +481,12 @@ impl Eth for EthClient where trace!(target: "miner", "Syncing. Cannot give any work."); return Err(no_work_err()); } + + // Otherwise spin until our submitted block has been included. + let timeout = Instant::now() + Duration::from_millis(1000); + while Instant::now() < timeout && client.queue_info().total_queue_size() > 0 { + thread::sleep(Duration::from_millis(1)); + } } let miner = take_weak!(self.miner);