fn peer_queues_update(
        &self,
        peer_map: &mut PeerAdvertMap,
        change: (AdvertTrackerRef, Priority, Priority),
    ) {
        let (advert_tracker_ref, old_priority, new_priority) = change;
        let advert_tracker = advert_tracker_ref.read().unwrap();
        advert_tracker.peers.iter().for_each(|peer_id| {
            if let Some(peer_advert_map) = peer_map.get_mut(peer_id) {
                let mut peer_advert_map = peer_advert_map.write().unwrap();
                peer_advert_map[old_priority].remove(&advert_tracker.advert.integrity_hash);
                self.metrics
                    .advert_queue_remove
                    .with_label_values(&[&peer_id.to_string(), &format!("{:?}", old_priority)])
                    .inc();
                self.metrics
                    .advert_queue_size
                    .with_label_values(&[&peer_id.to_string(), &format!("{:?}", old_priority)])
                    .dec();
                if new_priority != Priority::Drop {
                    peer_advert_map[new_priority].insert(
                        advert_tracker.advert.integrity_hash.clone(),
                        advert_tracker_ref.clone(),
                    );
                    self.metrics
                        .advert_queue_add
                        .with_label_values(&[&peer_id.to_string(), &format!("{:?}", new_priority)])
                        .inc();
                    self.metrics
                        .advert_queue_size
                        .with_label_values(&[&peer_id.to_string(), &format!("{:?}", new_priority)])
                        .inc();
                }
            }
        })
    }
/// Updates peer queues by setting a new priority for an advert.
Updates peer queues by setting a new priority for an advert.
Updates peer queues by setting a new priority for an advert .
fn peer_queues_update(
        &self,
        peer_map: &mut PeerAdvertMap,
        change: (AdvertTrackerRef, Priority, Priority),
    ) {
        let (advert_tracker_ref, old_priority, new_priority) = change;
        let advert_tracker = advert_tracker_ref.read().unwrap();
        advert_tracker.peers.iter().for_each(|peer_id| {
            if let Some(peer_advert_map) = peer_map.get_mut(peer_id) {
                let mut peer_advert_map = peer_advert_map.write().unwrap();
                peer_advert_map[old_priority].remove(&advert_tracker.advert.integrity_hash);
                self.metrics
                    .advert_queue_remove
                    .with_label_values(&[&peer_id.to_string(), &format!("{:?}", old_priority)])
                    .inc();
                self.metrics
                    .advert_queue_size
                    .with_label_values(&[&peer_id.to_string(), &format!("{:?}", old_priority)])
                    .dec();
                if new_priority != Priority::Drop {
                    peer_advert_map[new_priority].insert(
                        advert_tracker.advert.integrity_hash.clone(),
                        advert_tracker_ref.clone(),
                    );
                    self.metrics
                        .advert_queue_add
                        .with_label_values(&[&peer_id.to_string(), &format!("{:?}", new_priority)])
                        .inc();
                    self.metrics
                        .advert_queue_size
                        .with_label_values(&[&peer_id.to_string(), &format!("{:?}", new_priority)])
                        .inc();
                }
            }
        })
    }
fn peer_queues_update ( & self , peer_map : & mut PeerAdvertMap , change : ( AdvertTrackerRef , Priority , Priority ) , ) { let ( advert_tracker_ref , old_priority , new_priority ) = change ; let advert_tracker = advert_tracker_ref . read ( ) . unwrap ( ) ; advert_tracker . peers . iter ( ) . for_each ( | peer_id | { if let Some ( peer_advert_map ) = peer_map . get_mut ( peer_id ) { let mut peer_advert_map = peer_advert_map . write ( ) . unwrap ( ) ; peer_advert_map [ old_priority ] . remove ( & advert_tracker . advert . integrity_hash ) ; self . metrics . advert_queue_remove . with_label_values ( & [ & peer_id . to_string ( ) , & format ! ( " " old_priority ) ] ) . inc ( ) ; self . metrics . advert_queue_size . with_label_values ( & [ & peer_id . to_string ( ) , & format ! ( " " old_priority ) ] ) . dec ( ) ; if new_priority != Priority :: Drop { peer_advert_map [ new_priority ] . insert ( advert_tracker . advert . integrity_hash . clone ( ) , advert_tracker_ref . clone ( ) , ) ; self . metrics . advert_queue_add . with_label_values ( & [ & peer_id . to_string ( ) , & format ! ( " " new_priority ) ] ) . inc ( ) ; self . metrics . advert_queue_size . with_label_values ( & [ & peer_id . to_string ( ) , & format ! ( " " new_priority ) ] ) . inc ( ) ; } } } ) }
Updates peer queues by setting a new priority for an advert.
Updates peer queues by setting a new priority for an advert .
&self
peer_map
&mut PeerAdvertMap
change
(AdvertTrackerRef, Priority, Priority)
&self
peer_map
&mut PeerAdvertMap
change
(AdvertTrackerRef, Priority, Priority)