From f1cc82ae53e7c01a78b1dba10fa4a467bb359648 Mon Sep 17 00:00:00 2001 From: Robert Habermeier Date: Fri, 17 Aug 2018 22:13:01 +0200 Subject: [PATCH] Continue from next round when re-building on same block (#582) * keep rounds consistent when encountering bad block * fix interval logic * Fixed indentation --- polkadot/consensus/src/service.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/polkadot/consensus/src/service.rs b/polkadot/consensus/src/service.rs index d0d89786c3..d7360bb45a 100644 --- a/polkadot/consensus/src/service.rs +++ b/polkadot/consensus/src/service.rs @@ -164,7 +164,11 @@ impl Service { interval.map_err(|e| debug!("Timer error: {:?}", e)).for_each(move |_| { if let Ok(best_block) = c.best_block_header() { let hash = best_block.hash(); - if hash == prev_best && s.live_agreement() != Some(hash) { + let last_agreement = s.last_agreement(); + let can_build_upon = last_agreement + .map_or(true, |x| !x.live || x.parent_hash != hash); + + if hash == prev_best && can_build_upon { debug!("Starting consensus round after a timeout"); start_bft(best_block, s.clone()); }