From 347634ac6c9dfbcd9defb53f434158a6f7853cf9 Mon Sep 17 00:00:00 2001 From: keorn Date: Wed, 7 Dec 2016 16:42:58 +0100 Subject: [PATCH] dont rebroadcast propose --- ethcore/src/engines/tendermint/mod.rs | 9 +++++++++ ethcore/src/engines/tendermint/vote_collector.rs | 7 ++++++- ethcore/src/miner/miner.rs | 8 +++++--- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/ethcore/src/engines/tendermint/mod.rs b/ethcore/src/engines/tendermint/mod.rs index 6f7ce2097..a1f2fb03a 100644 --- a/ethcore/src/engines/tendermint/mod.rs +++ b/ethcore/src/engines/tendermint/mod.rs @@ -52,6 +52,15 @@ pub enum Step { Commit } +impl Step { + pub fn is_pre(self) -> bool { + match self { + Step::Prevote | Step::Precommit => true, + _ => false, + } + } +} + pub type Height = usize; pub type Round = usize; pub type BlockHash = H256; diff --git a/ethcore/src/engines/tendermint/vote_collector.rs b/ethcore/src/engines/tendermint/vote_collector.rs index 271ff5f9a..9df2574ec 100644 --- a/ethcore/src/engines/tendermint/vote_collector.rs +++ b/ethcore/src/engines/tendermint/vote_collector.rs @@ -125,7 +125,12 @@ impl VoteCollector { pub fn get_up_to(&self, height: Height) -> Vec { let guard = self.votes.read(); - guard.keys().take_while(|m| m.height <= height).map(|m| ::rlp::encode(m).to_vec()).collect() + guard + .keys() + .filter(|m| m.step.is_pre()) + .take_while(|m| m.height <= height) + .map(|m| ::rlp::encode(m).to_vec()) + .collect() } } diff --git a/ethcore/src/miner/miner.rs b/ethcore/src/miner/miner.rs index 892e37f40..6e2bbb27b 100644 --- a/ethcore/src/miner/miner.rs +++ b/ethcore/src/miner/miner.rs @@ -480,9 +480,11 @@ impl Miner { /// Uses Engine to seal the block internally and then imports it to chain. fn seal_and_import_block_internally(&self, chain: &MiningBlockChainClient, block: ClosedBlock) -> bool { - let mut sealing_work = self.sealing_work.lock(); - sealing_work.queue.push(block.clone()); - sealing_work.queue.use_last_ref(); + { + let mut sealing_work = self.sealing_work.lock(); + sealing_work.queue.push(block.clone()); + sealing_work.queue.use_last_ref(); + } if !block.transactions().is_empty() || self.forced_sealing() { if let Ok(sealed) = self.seal_block_internally(block) { if chain.import_sealed_block(sealed).is_ok() {