mirror of https://github.com/poanetwork/hbbft.git
Add NetworkInfo::other_ids.
This commit is contained in:
parent
71e1953b25
commit
bb17bd7a9c
|
@ -434,11 +434,7 @@ fn main() {
|
|||
|
||||
let new_honey_badger = |netinfo: NetworkInfo<NodeId>, rng: &mut OsRng| {
|
||||
let our_id = *netinfo.our_id();
|
||||
let peer_ids: Vec<_> = netinfo
|
||||
.all_ids()
|
||||
.filter(|&&them| them != our_id)
|
||||
.cloned()
|
||||
.collect();
|
||||
let peer_ids: Vec<_> = netinfo.other_ids().cloned().collect();
|
||||
let dhb = DynamicHoneyBadger::builder().build(netinfo);
|
||||
let (qhb, qhb_step) = QueueingHoneyBadger::builder(dhb)
|
||||
.batch_size(args.flag_b)
|
||||
|
|
|
@ -86,6 +86,13 @@ impl<N: NodeIdT> NetworkInfo<N> {
|
|||
self.public_keys.keys()
|
||||
}
|
||||
|
||||
/// ID of all nodes in the network except this one.
|
||||
#[inline]
|
||||
pub fn other_ids(&self) -> impl Iterator<Item = &N> + Clone {
|
||||
let our_id = self.our_id.clone();
|
||||
self.public_keys.keys().filter(move |id| **id != our_id)
|
||||
}
|
||||
|
||||
/// The total number _N_ of nodes.
|
||||
#[inline]
|
||||
pub fn num_nodes(&self) -> usize {
|
||||
|
|
|
@ -109,11 +109,7 @@ fn do_drop_and_re_add(cfg: TestConfig) {
|
|||
id
|
||||
);
|
||||
let dhb = DynamicHoneyBadger::builder().build(node.netinfo.clone());
|
||||
SenderQueue::builder(
|
||||
dhb,
|
||||
node.netinfo.all_ids().filter(|&&them| them != id).cloned(),
|
||||
)
|
||||
.build(node.id)
|
||||
SenderQueue::builder(dhb, node.netinfo.other_ids().cloned()).build(node.id)
|
||||
})
|
||||
.build(&mut rng)
|
||||
.expect("could not construct test network");
|
||||
|
|
|
@ -188,12 +188,12 @@ where
|
|||
fn new_honey_badger(
|
||||
netinfo: Arc<NetworkInfo<NodeId>>,
|
||||
) -> (UsizeHoneyBadger, Step<HoneyBadger<Vec<usize>, NodeId>>) {
|
||||
let our_id = *netinfo.our_id();
|
||||
let nc = netinfo.clone();
|
||||
let peer_ids = nc.all_ids().filter(|&&them| them != our_id).cloned();
|
||||
let peer_ids = nc.other_ids().cloned();
|
||||
let hb = HoneyBadger::builder(netinfo)
|
||||
.encryption_schedule(EncryptionSchedule::EveryNthEpoch(2))
|
||||
.build();
|
||||
let our_id = *nc.our_id();
|
||||
SenderQueue::builder(hb, peer_ids).build(our_id)
|
||||
}
|
||||
|
||||
|
|
|
@ -225,13 +225,13 @@ fn new_queueing_hb(
|
|||
seed: TestRngSeed,
|
||||
) -> (QHB, Step<QueueingHoneyBadger<usize, NodeId, Vec<usize>>>) {
|
||||
let mut rng: TestRng = TestRng::from_seed(seed);
|
||||
let our_id = *netinfo.our_id();
|
||||
let peer_ids = netinfo.all_ids().filter(|&&them| them != our_id).cloned();
|
||||
let peer_ids = netinfo.other_ids().cloned();
|
||||
let dhb = DynamicHoneyBadger::builder().build((*netinfo).clone());
|
||||
let (qhb, qhb_step) = QueueingHoneyBadger::builder(dhb)
|
||||
.batch_size(3)
|
||||
.build(&mut rng)
|
||||
.expect("failed to build QueueingHoneyBadger");
|
||||
let our_id = *netinfo.our_id();
|
||||
let (sq, mut step) = SenderQueue::builder(qhb, peer_ids).build(our_id);
|
||||
let output = step.extend_with(qhb_step, |fault| fault, Message::from);
|
||||
assert!(output.is_empty());
|
||||
|
|
Loading…
Reference in New Issue