From 259d5369b02f45967c75031d02705e5751cc9124 Mon Sep 17 00:00:00 2001 From: Vladimir Komendantskiy Date: Wed, 9 May 2018 16:39:45 +0100 Subject: [PATCH] corrected the count of AUX messages --- src/agreement.rs | 18 ++++++++++-------- src/common_subset.rs | 3 +-- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/agreement.rs b/src/agreement.rs index d81b55c9..9a02934b 100644 --- a/src/agreement.rs +++ b/src/agreement.rs @@ -210,15 +210,17 @@ impl Agreement { /// can, however, expect every good node to send an AUX value that will /// eventually end up in our bin_values. fn count_aux(&self) -> (usize, BTreeSet) { - let mut vals: BTreeSet = BTreeSet::new(); - - for b in self.received_aux.values() { - if self.bin_values.contains(b) { - vals.insert(b.clone()); - } - } + let mut count = 0; + let vals: BTreeSet = self.received_aux + .values() + .filter(|b| { + count += 1; + self.bin_values.contains(b) + }) + .cloned() + .collect(); - (vals.len(), vals) + (count, vals) } /// Waits until at least (N − f) AUX_r messages have been received, such that diff --git a/src/common_subset.rs b/src/common_subset.rs index 5d2a4aec..97087e17 100644 --- a/src/common_subset.rs +++ b/src/common_subset.rs @@ -179,8 +179,7 @@ impl CommonSubset { let mut result = Err(Error::NoSuchAgreementInstance); // Send the message to the local instance of Agreement - if let Some(mut agreement_instance) = self.agreement_instances.get_mut(&element_proposer_id) - { + if let Some(agreement_instance) = self.agreement_instances.get_mut(&element_proposer_id) { // Optional output of agreement and outgoing agreement // messages to remote nodes. result = if agreement_instance.terminated() {