/// The method downloads chunks for adverts with the highest priority from
/// the given peer.
The method downloads chunks for adverts with the highest priority from
the given peer.
The method downloads chunks for adverts with the highest priority from the given peer .
fn on_advert(&self, gossip_advert: GossipAdvert, peer_id: NodeId) {
        // The precondition ensured by gossip_protocol.on_advert() is that
        // the corresponding artifact is not in the artifact pool.
        // Check if we have seen this artifact before:
        if self
            .receive_check_caches
            .read()
            .unwrap()
            .values()
            .any(|cache| cache.contains(&gossip_advert.integrity_hash))
        {
            // If yes, the advert is ignored.
            return;
        }
        let mut current_peers = self.current_peers.lock().unwrap();
        if let Some(_peer_context) = current_peers.get_mut(&peer_id) {
            let _ = self.prioritizer.add_advert(gossip_advert, peer_id);
        } else {
            warn!(every_n_seconds => 30, self.log, "Dropping advert from unknown node {:?}", peer_id);
        }
        self.metrics.adverts_received.inc();
    }
fn on_advert ( & self , gossip_advert : GossipAdvert , peer_id : NodeId ) { // The precondition ensured by gossip_protocol.on_advert() is that // the corresponding artifact is not in the artifact pool. // Check if we have seen this artifact before: if self . receive_check_caches . read ( ) . unwrap ( ) . values ( ) . any ( | cache | cache . contains ( & gossip_advert . integrity_hash ) ) { // If yes, the advert is ignored. return ; } let mut current_peers = self . current_peers . lock ( ) . unwrap ( ) ; if let Some ( _peer_context ) = current_peers . get_mut ( & peer_id ) { let _ = self . prioritizer . add_advert ( gossip_advert , peer_id ) ; } else { warn ! ( every_n_seconds 30 self log " " peer_id ) ; } self . metrics . adverts_received . inc ( ) ; }
The method downloads chunks for adverts with the highest priority from
the given peer.
The method downloads chunks for adverts with the highest priority from the given peer .
&self
gossip_advert
GossipAdvert
peer_id
NodeId