fixed the count of matching AUX messages

This commit is contained in:
Vladimir Komendantskiy 2018-05-10 09:57:58 +01:00
parent 259d5369b0
commit 51ef11b55c
3 changed files with 7 additions and 9 deletions

View File

@ -12,6 +12,7 @@ ring = "^0.12"
protobuf = "1.4.4"
crossbeam = "0.3.2"
crossbeam-channel = "0.1"
itertools = "0.7"
[build-dependencies]
protoc-rust = "1.4.4"

View File

@ -1,5 +1,6 @@
//! Binary Byzantine agreement protocol from a common coin protocol.
use itertools::Itertools;
use std::collections::{BTreeMap, BTreeSet, HashMap, VecDeque};
use std::hash::Hash;
@ -210,17 +211,12 @@ impl<NodeUid: Clone + Eq + Hash> Agreement<NodeUid> {
/// 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<bool>) {
let mut count = 0;
let vals: BTreeSet<bool> = self.received_aux
let (vals_cnt, vals) = self.received_aux
.values()
.filter(|b| {
count += 1;
self.bin_values.contains(b)
})
.cloned()
.collect();
.filter(|b| self.bin_values.contains(b))
.tee();
(count, vals)
(vals_cnt.count(), vals.cloned().collect())
}
/// Waits until at least (N f) AUX_r messages have been received, such that

View File

@ -8,6 +8,7 @@
extern crate log;
extern crate crossbeam;
extern crate crossbeam_channel;
extern crate itertools;
extern crate merkle;
extern crate protobuf;
extern crate reed_solomon_erasure;