use crate::{ordered_broadcast::types::Epoch, Supervisor}; use commonware_cryptography::PublicKey; use std::collections::HashMap; #[derive(Clone)] pub struct Sequencers { participants: Vec

, participants_map: HashMap, } impl Sequencers

{ pub fn new(mut participants: Vec

) -> Self { // Setup participants participants.sort(); let mut participants_map = HashMap::new(); for (index, validator) in participants.iter().enumerate() { participants_map.insert(validator.clone(), index as u32); } Self { participants, participants_map, } } } impl Supervisor for Sequencers

{ type Index = Epoch; type PublicKey = P; fn leader(&self, _: Self::Index) -> Option { unimplemented!() } fn participants(&self, _: Self::Index) -> Option<&Vec> { Some(&self.participants) } fn is_participant(&self, _: Self::Index, candidate: &Self::PublicKey) -> Option { self.participants_map.get(candidate).cloned() } }