pub fn new(ids_and_stakes: &[(Pubkey, u64)], seed: [u8; 32], len: u64, repeat: u64) -> Self {
        let (ids, stakes): (Vec<_>, Vec<_>) = ids_and_stakes.iter().cloned().unzip();
        let rng = &mut ChaChaRng::from_seed(seed);
        let weighted_index = WeightedIndex::new(stakes).unwrap();
        let mut current_node = Pubkey::default();
        let slot_leaders = (0..len)
            .map(|i| {
                if i % repeat == 0 {
                    current_node = ids[weighted_index.sample(rng)];
                    current_node
                } else {
                    current_node
                }
            })
            .collect();
        Self { slot_leaders }
    }
// Note: passing in zero stakers will cause a panic.
passing in zero stakers will cause a panic.
passing in zero stakers will cause a panic .
pub fn new(ids_and_stakes: &[(Pubkey, u64)], seed: [u8; 32], len: u64, repeat: u64) -> Self {
        let (ids, stakes): (Vec<_>, Vec<_>) = ids_and_stakes.iter().cloned().unzip();
        let rng = &mut ChaChaRng::from_seed(seed);
        let weighted_index = WeightedIndex::new(stakes).unwrap();
        let mut current_node = Pubkey::default();
        let slot_leaders = (0..len)
            .map(|i| {
                if i % repeat == 0 {
                    current_node = ids[weighted_index.sample(rng)];
                    current_node
                } else {
                    current_node
                }
            })
            .collect();
        Self { slot_leaders }
    }
pub fn new ( ids_and_stakes : & [ ( Pubkey , u64 ) ] , seed : [ u8 ; 32 ] , len : u64 , repeat : u64 ) -> Self { let ( ids , stakes ) : ( Vec < _ > , Vec < _ > ) = ids_and_stakes . iter ( ) . cloned ( ) . unzip ( ) ; let rng = & mut ChaChaRng :: from_seed ( seed ) ; let weighted_index = WeightedIndex :: new ( stakes ) . unwrap ( ) ; let mut current_node = Pubkey :: default ( ) ; let slot_leaders = ( 0 .. len ) . map ( | i | { if i % repeat == 0 { current_node = ids [ weighted_index . sample ( rng ) ] ; current_node } else { current_node } } ) . collect ( ) ; Self { slot_leaders } }
Note: passing in zero stakers will cause a panic.
Note : passing in zero stakers will cause a panic .
ids_and_stakes
&[(Pubkey, u64)]
seed
[u8; 32]
len
u64
repeat
u64