Skip to content
This repository was archived by the owner on Nov 6, 2020. It is now read-only.

Commit 9cdd2d2

Browse files
authored
Informant tidyup. (#1699)
* Informant tidyup. Clean indent. Don't skip skipping. * Move string to right place [ci:skip]
1 parent 3f841cc commit 9cdd2d2

File tree

1 file changed

+14
-16
lines changed

1 file changed

+14
-16
lines changed

parity/informant.rs

+14-16
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ impl Informant {
108108

109109
info!(target: "import", "{} {} {}",
110110
match importing {
111-
true => format!("{} {} {} {}+{} Qed",
111+
true => format!("Syncing {} {} {} {}+{} Qed",
112112
paint(White.bold(), format!("{:>8}", format!("#{}", chain_info.best_block_number))),
113113
paint(White.bold(), format!("{}", chain_info.best_block_hash)),
114114
{
@@ -156,28 +156,26 @@ impl Informant {
156156
impl ChainNotify for Informant {
157157
fn new_blocks(&self, _imported: Vec<H256>, _invalid: Vec<H256>, enacted: Vec<H256>, _retracted: Vec<H256>, _sealed: Vec<H256>, duration: u64) {
158158
let mut last_import = self.last_import.lock();
159-
if Instant::now() > *last_import + Duration::from_secs(1) {
160-
let queue_info = self.client.queue_info();
161-
let importing = queue_info.unverified_queue_size + queue_info.verified_queue_size > 3
162-
|| self.sync.as_ref().map_or(false, |s| s.status().is_major_syncing());
163-
if !importing {
164-
if let Some(block) = enacted.last().and_then(|h| self.client.block(BlockID::Hash(h.clone()))) {
165-
let view = BlockView::new(&block);
166-
let header = view.header();
167-
let tx_count = view.transactions_count();
168-
let size = block.len();
169-
let skipped = self.skipped.load(AtomicOrdering::Relaxed);
170-
info!(target: "import", "Imported {} {} ({} txs, {} Mgas, {} ms, {} KiB){}",
159+
let queue_info = self.client.queue_info();
160+
let importing = queue_info.unverified_queue_size + queue_info.verified_queue_size > 3
161+
|| self.sync.as_ref().map_or(false, |s| s.status().is_major_syncing());
162+
if Instant::now() > *last_import + Duration::from_secs(1) && !importing {
163+
if let Some(block) = enacted.last().and_then(|h| self.client.block(BlockID::Hash(h.clone()))) {
164+
let view = BlockView::new(&block);
165+
let header = view.header();
166+
let tx_count = view.transactions_count();
167+
let size = block.len();
168+
let skipped = self.skipped.load(AtomicOrdering::Relaxed);
169+
info!(target: "import", "Imported {} {} ({} txs, {} Mgas, {} ms, {} KiB){}",
171170
Colour::White.bold().paint(format!("#{}", header.number())),
172171
Colour::White.bold().paint(format!("{}", header.hash())),
173172
Colour::Yellow.bold().paint(format!("{}", tx_count)),
174173
Colour::Yellow.bold().paint(format!("{:.2}", header.gas_used.low_u64() as f32 / 1000000f32)),
175174
Colour::Purple.bold().paint(format!("{:.2}", duration as f32 / 1000000f32)),
176175
Colour::Blue.bold().paint(format!("{:.2}", size as f32 / 1024f32)),
177176
if skipped > 0 { format!(" + another {} block(s)", Colour::Red.bold().paint(format!("{}", skipped))) } else { String::new() }
178-
);
179-
*last_import = Instant::now();
180-
}
177+
);
178+
*last_import = Instant::now();
181179
}
182180
self.skipped.store(0, AtomicOrdering::Relaxed);
183181
} else {

0 commit comments

Comments
 (0)