From 8851acec7c76914b07969037fb568afff4a6f0e9 Mon Sep 17 00:00:00 2001 From: keorn Date: Mon, 5 Sep 2016 17:06:43 +0200 Subject: [PATCH] fix propose collect locking --- ethcore/src/engines/propose_collect.rs | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/ethcore/src/engines/propose_collect.rs b/ethcore/src/engines/propose_collect.rs index 46defd557..ad245e2cd 100644 --- a/ethcore/src/engines/propose_collect.rs +++ b/ethcore/src/engines/propose_collect.rs @@ -49,12 +49,12 @@ impl ProposeCollect { /// Vote on hash using the signed hash, true if vote counted. pub fn vote(&self, voter: Address) -> bool { - match self.votes.try_read().unwrap().contains(&voter) || !self.voters.contains(&voter) { - true => false, - false => { - self.votes.try_write().unwrap().insert(voter); - true - }, + let is_known = self.votes.try_read().unwrap().contains(&voter); + if !is_known && self.voters.contains(&voter) { + self.votes.try_write().unwrap().insert(voter); + true + } else { + false } } @@ -66,11 +66,6 @@ impl ProposeCollect { }; self.is_won.load(Ordering::Relaxed) || threshold_checker() } - - /// Get addresses backing given hash. - pub fn votes(&self) -> HashSet
{ - self.votes.try_read().unwrap().clone() - } } #[cfg(test)]