fn apply_updates(&mut self, from: Pubkey, update_index: u64, data: &[(NodeInfo, u64)]) {
        trace!("got updates {}", data.len());
        // TODO we need to punish/spam resist here
        // sigverify the whole update and slash anyone who sends a bad update
        let mut insert_total = 0;
        for v in data {
            insert_total += self.insert(&v.0);
        }
        inc_new_counter_info!("cluster_info-update-count", insert_total);

        for (node, external_remote_index) in data {
            let pubkey = node.id;
            let remote_entry = if let Some(v) = self.remote.get(&pubkey) {
                *v
            } else {
                0
            };

            if remote_entry >= *external_remote_index {
                continue;
            }

            let liveness_entry = self
                .external_liveness
                .entry(pubkey)
                .or_insert_with(HashMap::new);
            let peer_index = *liveness_entry.entry(from).or_insert(*external_remote_index);
            if *external_remote_index > peer_index {
                liveness_entry.insert(from, *external_remote_index);
            }
        }

        *self.remote.entry(from).or_insert(update_index) = update_index;

        // Clear the remote liveness table for this node, b/c we've heard directly from them
        // so we don't need to rely on rumors
        self.external_liveness.remove(&from);
    }
/// Apply updates that we received from the identity `from`
/// # Arguments
/// * `from` - identity of the sender of the updates
/// * `update_index` - the number of updates that `from` has completed and this set of `data` represents
/// * `data` - the update data
Apply updates that we received from the identity `from`
Apply updates that we received from the identity ` from `
fn apply_updates(&mut self, from: Pubkey, update_index: u64, data: &[(NodeInfo, u64)]) {
        trace!("got updates {}", data.len());
        // TODO we need to punish/spam resist here
        // sigverify the whole update and slash anyone who sends a bad update
        let mut insert_total = 0;
        for v in data {
            insert_total += self.insert(&v.0);
        }
        inc_new_counter_info!("cluster_info-update-count", insert_total);
        for (node, external_remote_index) in data {
            let pubkey = node.id;
            let remote_entry = if let Some(v) = self.remote.get(&pubkey) {
                *v
            } else {
                0
            };
            if remote_entry >= *external_remote_index {
                continue;
            }
            let liveness_entry = self
                .external_liveness
                .entry(pubkey)
                .or_insert_with(HashMap::new);
            let peer_index = *liveness_entry.entry(from).or_insert(*external_remote_index);
            if *external_remote_index > peer_index {
                liveness_entry.insert(from, *external_remote_index);
            }
        }
        *self.remote.entry(from).or_insert(update_index) = update_index;
        // Clear the remote liveness table for this node, b/c we've heard directly from them
        // so we don't need to rely on rumors
        self.external_liveness.remove(&from);
    }
fn apply_updates ( & mut self , from : Pubkey , update_index : u64 , data : & [ ( NodeInfo , u64 ) ] ) { trace ! ( " " data len ( ) ) ; // TODO we need to punish/spam resist here // sigverify the whole update and slash anyone who sends a bad update let mut insert_total = 0 ; for v in data { insert_total += self . insert ( & v . 0 ) ; } inc_new_counter_info ! ( " " insert_total ) ; for ( node , external_remote_index ) in data { let pubkey = node . id ; let remote_entry = if let Some ( v ) = self . remote . get ( & pubkey ) { * v } else { 0 } ; if remote_entry >= * external_remote_index { continue ; } let liveness_entry = self . external_liveness . entry ( pubkey ) . or_insert_with ( HashMap :: new ) ; let peer_index = * liveness_entry . entry ( from ) . or_insert ( * external_remote_index ) ; if * external_remote_index > peer_index { liveness_entry . insert ( from , * external_remote_index ) ; } } * self . remote . entry ( from ) . or_insert ( update_index ) = update_index ; // Clear the remote liveness table for this node, b/c we've heard directly from them // so we don't need to rely on rumors self . external_liveness . remove ( & from ) ; }
Apply updates that we received from the identity `from`
Apply updates that we received from the identity ` from `
&mut self
from
Pubkey
update_index
u64
data
&[(NodeInfo, u64)]
&mut self
from
Pubkey
update_index
u64
data
&[(NodeInfo, u64)]