fn on_timer(&self, event_handler: Arc<dyn P2PEventHandlerControl>) {
        let (update_priority_fns, retransmission_request, refresh_registry) =
            self.get_timer_tasks();
        if update_priority_fns {
            let dropped_adverts = self
                .prioritizer
                .update_priority_functions(self.artifact_manager.as_ref());
            let mut artifacts_under_construction =
                self.artifacts_under_construction.write().unwrap();
            dropped_adverts
                .iter()
                .for_each(|id| artifacts_under_construction.remove_tracker(id));
        }

        if retransmission_request {
            // Send a retransmission request to all peers.
            let current_peers = self.peer_manager.get_current_peer_ids();
            for peer in current_peers {
                self.send_retransmission_request(peer);
            }
        }

        if refresh_registry {
            self.refresh_registry(&event_handler);
        }

        // Collect the peers with timed-out requests.
        let mut timed_out_peers = Vec::new();
        for (node_id, peer_context) in self.current_peers.lock().unwrap().iter_mut() {
            if self.process_timed_out_requests(node_id, peer_context) {
                timed_out_peers.push(*node_id);
            }
        }

        // Process timed-out artifacts.
        self.process_timed_out_artifacts();

        // Compute the set of peers that need to be evaluated by the download manager.
        let peer_ids = if update_priority_fns {
            self.peer_manager.get_current_peer_ids().into_iter()
        } else {
            timed_out_peers.into_iter()
        };

        // Invoke download_next(i) for each peer i.
        for peer_id in peer_ids {
            let _ = self.download_next(peer_id);
        }
    }
/// The method is invoked periodically by the *Gossip* component to perform
/// P2P book keeping tasks.
The method is invoked periodically by the *Gossip* component to perform
P2P book keeping tasks.
The method is invoked periodically by the * Gossip * component to perform P2P book keeping tasks .
fn on_timer(&self, event_handler: Arc<dyn P2PEventHandlerControl>) {
        let (update_priority_fns, retransmission_request, refresh_registry) =
            self.get_timer_tasks();
        if update_priority_fns {
            let dropped_adverts = self
                .prioritizer
                .update_priority_functions(self.artifact_manager.as_ref());
            let mut artifacts_under_construction =
                self.artifacts_under_construction.write().unwrap();
            dropped_adverts
                .iter()
                .for_each(|id| artifacts_under_construction.remove_tracker(id));
        }
        if retransmission_request {
            // Send a retransmission request to all peers.
            let current_peers = self.peer_manager.get_current_peer_ids();
            for peer in current_peers {
                self.send_retransmission_request(peer);
            }
        }
        if refresh_registry {
            self.refresh_registry(&event_handler);
        }
        // Collect the peers with timed-out requests.
        let mut timed_out_peers = Vec::new();
        for (node_id, peer_context) in self.current_peers.lock().unwrap().iter_mut() {
            if self.process_timed_out_requests(node_id, peer_context) {
                timed_out_peers.push(*node_id);
            }
        }
        // Process timed-out artifacts.
        self.process_timed_out_artifacts();
        // Compute the set of peers that need to be evaluated by the download manager.
        let peer_ids = if update_priority_fns {
            self.peer_manager.get_current_peer_ids().into_iter()
        } else {
            timed_out_peers.into_iter()
        };
        // Invoke download_next(i) for each peer i.
        for peer_id in peer_ids {
            let _ = self.download_next(peer_id);
        }
    }
fn on_timer ( & self , event_handler : Arc < dyn P2PEventHandlerControl > ) { let ( update_priority_fns , retransmission_request , refresh_registry ) = self . get_timer_tasks ( ) ; if update_priority_fns { let dropped_adverts = self . prioritizer . update_priority_functions ( self . artifact_manager . as_ref ( ) ) ; let mut artifacts_under_construction = self . artifacts_under_construction . write ( ) . unwrap ( ) ; dropped_adverts . iter ( ) . for_each ( | id | artifacts_under_construction . remove_tracker ( id ) ) ; } if retransmission_request { // Send a retransmission request to all peers. let current_peers = self . peer_manager . get_current_peer_ids ( ) ; for peer in current_peers { self . send_retransmission_request ( peer ) ; } } if refresh_registry { self . refresh_registry ( & event_handler ) ; } // Collect the peers with timed-out requests. let mut timed_out_peers = Vec :: new ( ) ; for ( node_id , peer_context ) in self . current_peers . lock ( ) . unwrap ( ) . iter_mut ( ) { if self . process_timed_out_requests ( node_id , peer_context ) { timed_out_peers . push ( * node_id ) ; } } // Process timed-out artifacts. self . process_timed_out_artifacts ( ) ; // Compute the set of peers that need to be evaluated by the download manager. let peer_ids = if update_priority_fns { self . peer_manager . get_current_peer_ids ( ) . into_iter ( ) } else { timed_out_peers . into_iter ( ) } ; // Invoke download_next(i) for each peer i. for peer_id in peer_ids { let _ = self . download_next ( peer_id ) ; } }
The method is invoked periodically by the *Gossip* component to perform
P2P book keeping tasks.
The method is invoked periodically by the * Gossip * component to perform P2P book keeping tasks .
&self
event_handler
Arc<dyn P2PEventHandlerControl>
&self
event_handler
Arc<dyn P2PEventHandlerControl>