moved the own ID membership test to the NetworkInfo constructor

This commit is contained in:
Vladimir Komendantskiy 2018-05-29 14:58:17 +01:00
parent 98f5304d4c
commit ede1c7d157
2 changed files with 4 additions and 5 deletions

View File

@ -27,7 +27,6 @@ error_chain!{
} }
errors { errors {
OwnIdMissing
UnknownSender UnknownSender
} }
} }
@ -111,9 +110,6 @@ where
where where
TI: IntoIterator<Item = T>, TI: IntoIterator<Item = T>,
{ {
if !netinfo.all_uids().contains(netinfo.our_uid()) {
return Err(ErrorKind::OwnIdMissing.into());
}
let mut honey_badger = HoneyBadger { let mut honey_badger = HoneyBadger {
netinfo, netinfo,
buffer: txs.into_iter().collect(), buffer: txs.into_iter().collect(),

View File

@ -133,8 +133,11 @@ pub struct NetworkInfo<NodeUid> {
num_faulty: usize, num_faulty: usize,
} }
impl<NodeUid> NetworkInfo<NodeUid> { impl<NodeUid: Ord> NetworkInfo<NodeUid> {
pub fn new(our_uid: NodeUid, all_uids: BTreeSet<NodeUid>) -> Self { pub fn new(our_uid: NodeUid, all_uids: BTreeSet<NodeUid>) -> Self {
if !all_uids.contains(&our_uid) {
panic!("Missing own ID");
}
let num_nodes = all_uids.len(); let num_nodes = all_uids.len();
NetworkInfo { NetworkInfo {
our_uid, our_uid,