Add tracing.
This commit is contained in:
parent
038b67cbd4
commit
0ab57c48c3
@ -166,28 +166,35 @@ impl MinerService for Miner {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn update_sealing(&self, chain: &BlockChainClient) {
|
fn update_sealing(&self, chain: &BlockChainClient) {
|
||||||
let should_disable_sealing = {
|
if self.sealing_enabled.load(atomic::Ordering::Relaxed) {
|
||||||
let current_no = chain.chain_info().best_block_number;
|
let should_disable_sealing = {
|
||||||
let last_request = self.sealing_block_last_request.lock().unwrap();
|
let current_no = chain.chain_info().best_block_number;
|
||||||
let is_greater = current_no > *last_request;
|
let last_request = self.sealing_block_last_request.lock().unwrap();
|
||||||
is_greater && current_no - *last_request > SEALING_TIMEOUT_IN_BLOCKS
|
let is_greater = current_no > *last_request;
|
||||||
};
|
is_greater && current_no - *last_request > SEALING_TIMEOUT_IN_BLOCKS
|
||||||
|
};
|
||||||
|
|
||||||
if should_disable_sealing {
|
if should_disable_sealing {
|
||||||
self.sealing_enabled.store(false, atomic::Ordering::Relaxed);
|
trace!(target: "miner", "Miner sleeping (current {}, last {})", current_no, last_request);
|
||||||
*self.sealing_block.lock().unwrap() = None;
|
self.sealing_enabled.store(false, atomic::Ordering::Relaxed);
|
||||||
} else if self.sealing_enabled.load(atomic::Ordering::Relaxed) {
|
*self.sealing_block.lock().unwrap() = None;
|
||||||
self.prepare_sealing(chain);
|
} else {
|
||||||
|
self.prepare_sealing(chain);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn sealing_block(&self, chain: &BlockChainClient) -> &Mutex<Option<ClosedBlock>> {
|
fn sealing_block(&self, chain: &BlockChainClient) -> &Mutex<Option<ClosedBlock>> {
|
||||||
if self.sealing_block.lock().unwrap().is_none() {
|
if self.sealing_block.lock().unwrap().is_none() {
|
||||||
self.sealing_enabled.store(true, atomic::Ordering::Relaxed);
|
self.sealing_enabled.store(true, atomic::Ordering::Relaxed);
|
||||||
|
|
||||||
self.prepare_sealing(chain);
|
self.prepare_sealing(chain);
|
||||||
}
|
}
|
||||||
*self.sealing_block_last_request.lock().unwrap() = chain.chain_info().best_block_number;
|
let sealing_block_last_request = self.sealing_block_last_request.lock().unwrap();
|
||||||
|
let best_number = chain.chain_info().best_block_number;
|
||||||
|
if *sealing_block_last_request != best_number {
|
||||||
|
trace!(target: "miner", "Miner received request (was {}, now {}) - waking up.", sealing_block_last_request, best_number);
|
||||||
|
*sealing_block_last_request = best_number;
|
||||||
|
}
|
||||||
&self.sealing_block
|
&self.sealing_block
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -398,10 +398,11 @@ impl<C, S, A, M, EM> Eth for EthClient<C, S, A, M, EM>
|
|||||||
match params {
|
match params {
|
||||||
Params::None => {
|
Params::None => {
|
||||||
let client = take_weak!(self.client);
|
let client = take_weak!(self.client);
|
||||||
// check if we're still syncing and return empty strings int that case
|
// check if we're still syncing and return empty strings in that case
|
||||||
{
|
{
|
||||||
let sync = take_weak!(self.sync);
|
let sync = take_weak!(self.sync);
|
||||||
if sync.status().state != SyncState::Idle && client.queue_info().is_empty() {
|
if sync.status().state != SyncState::Idle && client.queue_info().is_empty() {
|
||||||
|
trace!(target: "miner", "Syncing. Cannot give any work.");
|
||||||
return to_value(&(String::new(), String::new(), String::new()));
|
return to_value(&(String::new(), String::new(), String::new()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user