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 mut options: Vec<_> = self.push_options(crds, &self_id, stakes);
        if options.is_empty() {
            return;
        }
        while new_items.len() < need {
            let index = WeightedIndex::new(options.iter().map(|weighted| weighted.0));
            if index.is_err() {
                break;
            }
            let index = index.unwrap();
            let index = index.sample(&mut rand::thread_rng());
            let item = options[index].1;
            options.remove(index);
            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_BLOOM_SIZE, network_size);
            let bloom = Bloom::random(size, 0.1, 1024 * 8 * 4);
            new_items.insert(item.id, bloom);
        }
        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.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 mut options: Vec<_> = self.push_options(crds, &self_id, stakes);
        if options.is_empty() {
            return;
        }
        while new_items.len() < need {
            let index = WeightedIndex::new(options.iter().map(|weighted| weighted.0));
            if index.is_err() {
                break;
            }
            let index = index.unwrap();
            let index = index.sample(&mut rand::thread_rng());
            let item = options[index].1;
            options.remove(index);
            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_BLOOM_SIZE, network_size);
            let bloom = Bloom::random(size, 0.1, 1024 * 8 * 4);
            new_items.insert(item.id, bloom);
        }
        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.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 mut options : Vec < _ > = self . push_options ( crds , & self_id , stakes ) ; if options . is_empty ( ) { return ; } while new_items . len ( ) < need { let index = WeightedIndex :: new ( options . iter ( ) . map ( | weighted | weighted . 0 ) ) ; if index . is_err ( ) { break ; } let index = index . unwrap ( ) ; let index = index . sample ( & mut rand :: thread_rng ( ) ) ; let item = options [ index ] . 1 ; options . remove ( index ) ; 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_BLOOM_SIZE , network_size ) ; let bloom = Bloom :: random ( size , 0.1 , 1024 * 8 * 4 ) ; new_items . insert ( item . id , bloom ) ; } 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 . 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