fix propose collect locking

This commit is contained in:
keorn 2016-09-05 17:06:43 +02:00
parent 83c371e6d4
commit 8851acec7c

View File

@ -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 => {
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<Address> {
self.votes.try_read().unwrap().clone()
}
}
#[cfg(test)]