pub fn refresh_push_active_set(
        &mut self,
        crds: &Crds,
        stakes: &HashMap<Pubkey, u64>,
        self_id: &Pubkey,
        network_size: usize,
        ratio: usize,
    ) {
        let need = Self::compute_need(self.num_active, self.active_set.len(), ratio);
        let mut new_items = HashMap::new();

        let options: Vec<_> = self.push_options(crds, &self_id, stakes);
        if options.is_empty() {
            return;
        }

        let mut seed = [0; 32];
        seed[0..8].copy_from_slice(&thread_rng().next_u64().to_le_bytes());
        let mut shuffle = weighted_shuffle(
            options.iter().map(|weighted| weighted.0).collect_vec(),
            seed,
        )
        .into_iter();

        while new_items.len() < need {
            match shuffle.next() {
                Some(index) => {
                    let item = options[index].1;
                    if self.active_set.get(&item.id).is_some() {
                        continue;
                    }
                    if new_items.get(&item.id).is_some() {
                        continue;
                    }
                    let size = cmp::max(CRDS_GOSSIP_DEFAULT_BLOOM_ITEMS, network_size);
                    let mut bloom = Bloom::random(size, 0.1, 1024 * 8 * 4);
                    bloom.add(&item.id);
                    new_items.insert(item.id, bloom);
                }
                _ => break,
            }
        }
        let mut keys: Vec<Pubkey> = self.active_set.keys().cloned().collect();
        keys.shuffle(&mut rand::thread_rng());
        let num = keys.len() / ratio;
        for k in &keys[..num] {
            self.active_set.swap_remove(k);
        }
        for (k, v) in new_items {
            self.active_set.insert(k, v);
        }
    }
/// refresh the push active set
/// * ratio - active_set.len()/ratio is the number of actives to rotate
refresh the push active set
ratio - active_set.len()/ratio is the number of actives to rotate
refresh the push active set ratio - active_set . len () / ratio is the number of actives to rotate
pub fn refresh_push_active_set(
        &mut self,
        crds: &Crds,
        stakes: &HashMap<Pubkey, u64>,
        self_id: &Pubkey,
        network_size: usize,
        ratio: usize,
    ) {
        let need = Self::compute_need(self.num_active, self.active_set.len(), ratio);
        let mut new_items = HashMap::new();
        let options: Vec<_> = self.push_options(crds, &self_id, stakes);
        if options.is_empty() {
            return;
        }
        let mut seed = [0; 32];
        seed[0..8].copy_from_slice(&thread_rng().next_u64().to_le_bytes());
        let mut shuffle = weighted_shuffle(
            options.iter().map(|weighted| weighted.0).collect_vec(),
            seed,
        )
        .into_iter();
        while new_items.len() < need {
            match shuffle.next() {
                Some(index) => {
                    let item = options[index].1;
                    if self.active_set.get(&item.id).is_some() {
                        continue;
                    }
                    if new_items.get(&item.id).is_some() {
                        continue;
                    }
                    let size = cmp::max(CRDS_GOSSIP_DEFAULT_BLOOM_ITEMS, network_size);
                    let mut bloom = Bloom::random(size, 0.1, 1024 * 8 * 4);
                    bloom.add(&item.id);
                    new_items.insert(item.id, bloom);
                }
                _ => break,
            }
        }
        let mut keys: Vec<Pubkey> = self.active_set.keys().cloned().collect();
        keys.shuffle(&mut rand::thread_rng());
        let num = keys.len() / ratio;
        for k in &keys[..num] {
            self.active_set.swap_remove(k);
        }
        for (k, v) in new_items {
            self.active_set.insert(k, v);
        }
    }
pub fn refresh_push_active_set ( & mut self , crds : & Crds , stakes : & HashMap < Pubkey , u64 > , self_id : & Pubkey , network_size : usize , ratio : usize , ) { let need = Self :: compute_need ( self . num_active , self . active_set . len ( ) , ratio ) ; let mut new_items = HashMap :: new ( ) ; let options : Vec < _ > = self . push_options ( crds , & self_id , stakes ) ; if options . is_empty ( ) { return ; } let mut seed = [ 0 ; 32 ] ; seed [ 0 .. 8 ] . copy_from_slice ( & thread_rng ( ) . next_u64 ( ) . to_le_bytes ( ) ) ; let mut shuffle = weighted_shuffle ( options . iter ( ) . map ( | weighted | weighted . 0 ) . collect_vec ( ) , seed , ) . into_iter ( ) ; while new_items . len ( ) < need { match shuffle . next ( ) { Some ( index ) => { let item = options [ index ] . 1 ; if self . active_set . get ( & item . id ) . is_some ( ) { continue ; } if new_items . get ( & item . id ) . is_some ( ) { continue ; } let size = cmp :: max ( CRDS_GOSSIP_DEFAULT_BLOOM_ITEMS , network_size ) ; let mut bloom = Bloom :: random ( size , 0.1 , 1024 * 8 * 4 ) ; bloom . add ( & item . id ) ; new_items . insert ( item . id , bloom ) ; } _ => break , } } let mut keys : Vec < Pubkey > = self . active_set . keys ( ) . cloned ( ) . collect ( ) ; keys . shuffle ( & mut rand :: thread_rng ( ) ) ; let num = keys . len ( ) / ratio ; for k in & keys [ .. num ] { self . active_set . swap_remove ( k ) ; } for ( k , v ) in new_items { self . active_set . insert ( k , v ) ; } }
refresh the push active set
 ratio - active_set.len()/ratio is the number of actives to rotate
refresh the push active set ratio - active_set . len () / ratio is the number of actives to rotate
&mut self
crds
&Crds
stakes
&HashMap<Pubkey, u64>
self_id
&Pubkey
network_size
usize
ratio
usize
&mut self
crds
&Crds
stakes
&HashMap<Pubkey, u64>
self_id
&Pubkey
network_size
usize
ratio
usize