Log a chain-reorg. (#1715)

* Log a chain-reorg.

* Nicer output

* Use imported rather than enacted.

Enacted can include previously imported blocks which makes the
info incorrect.
This commit is contained in:
Gav Wood
2016-07-26 00:20:37 +02:00
committed by GitHub
parent 431ba5e260
commit 856657e39a
2 changed files with 52 additions and 45 deletions

View File

@@ -154,13 +154,13 @@ impl Informant {
}
impl ChainNotify for Informant {
fn new_blocks(&self, _imported: Vec<H256>, _invalid: Vec<H256>, enacted: Vec<H256>, _retracted: Vec<H256>, _sealed: Vec<H256>, duration: u64) {
fn new_blocks(&self, imported: Vec<H256>, _invalid: Vec<H256>, _enacted: Vec<H256>, _retracted: Vec<H256>, _sealed: Vec<H256>, duration: u64) {
let mut last_import = self.last_import.lock();
let queue_info = self.client.queue_info();
let importing = queue_info.unverified_queue_size + queue_info.verified_queue_size > 3
|| self.sync.as_ref().map_or(false, |s| s.status().is_major_syncing());
if Instant::now() > *last_import + Duration::from_secs(1) && !importing {
if let Some(block) = enacted.last().and_then(|h| self.client.block(BlockID::Hash(h.clone()))) {
if let Some(block) = imported.last().and_then(|h| self.client.block(BlockID::Hash(h.clone()))) {
let view = BlockView::new(&block);
let header = view.header();
let tx_count = view.transactions_count();
@@ -179,7 +179,7 @@ impl ChainNotify for Informant {
}
self.skipped.store(0, AtomicOrdering::Relaxed);
} else {
self.skipped.fetch_add(enacted.len(), AtomicOrdering::Relaxed);
self.skipped.fetch_add(imported.len(), AtomicOrdering::Relaxed);
}
}
}