pub(crate) fn add_endorsements(&mut self, endorsements: Endorsements<C>) {
        let uhash = *endorsements.unit();
        if self.endorsements.contains_key(&uhash) {
            return; // We already have a sufficient number of endorsements.
        }
        info!("Received endorsements of {:?}", uhash);
        self.incomplete_endorsements
            .entry(uhash)
            .or_default()
            .extend(endorsements.endorsers);
        let endorsed: Weight = self.incomplete_endorsements[&uhash]
            .keys()
            .map(|vidx| self.weight(*vidx))
            .sum();
        // Stake required to consider unit to be endorsed.
        let threshold = self.total_weight() / 2;
        if endorsed > threshold {
            info!(%uhash, "Unit endorsed by at least 1/2 of validators.");
            // Unwrap is safe: We created the map entry above.
            let mut fully_endorsed = self.incomplete_endorsements.remove(&uhash).unwrap();
            let endorsed_map = self
                .weights()
                .keys()
                .map(|vidx| fully_endorsed.remove(&vidx))
                .collect();
            self.endorsements.insert(uhash, endorsed_map);
        }
    }
/// Adds a set of endorsements to the state.
/// If, after adding, we have collected enough endorsements to consider unit _endorsed_,
/// it will be *upgraded* to fully endorsed.
///
/// Endorsements must be validated before calling this: The endorsers must exist, the
/// signatures must be valid and the endorsed unit must be present in `self.units`.
Adds a set of endorsements to the state.
If, after adding, we have collected enough endorsements to consider unit _endorsed_,
it will be *upgraded* to fully endorsed.

Endorsements must be validated before calling this: The endorsers must exist, the
signatures must be valid and the endorsed unit must be present in `self.units`.
Adds a set of endorsements to the state . If after adding we have collected enough endorsements to consider unit _endorsed_ it will be * upgraded * to fully endorsed . Endorsements must be validated before calling this : The endorsers must exist the signatures must be valid and the endorsed unit must be present in ` self . units ` .
pub(crate) fn add_endorsements(&mut self, endorsements: Endorsements<C>) {
        let uhash = *endorsements.unit();
        if self.endorsements.contains_key(&uhash) {
            return; // We already have a sufficient number of endorsements.
        }
        info!("Received endorsements of {:?}", uhash);
        self.incomplete_endorsements
            .entry(uhash)
            .or_default()
            .extend(endorsements.endorsers);
        let endorsed: Weight = self.incomplete_endorsements[&uhash]
            .keys()
            .map(|vidx| self.weight(*vidx))
            .sum();
        // Stake required to consider unit to be endorsed.
        let threshold = self.total_weight() / 2;
        if endorsed > threshold {
            info!(%uhash, "Unit endorsed by at least 1/2 of validators.");
            // Unwrap is safe: We created the map entry above.
            let mut fully_endorsed = self.incomplete_endorsements.remove(&uhash).unwrap();
            let endorsed_map = self
                .weights()
                .keys()
                .map(|vidx| fully_endorsed.remove(&vidx))
                .collect();
            self.endorsements.insert(uhash, endorsed_map);
        }
    }
pub ( crate ) fn add_endorsements ( & mut self , endorsements : Endorsements < C > ) { let uhash = * endorsements . unit ( ) ; if self . endorsements . contains_key ( & uhash ) { return ; // We already have a sufficient number of endorsements. } info ! ( " " uhash ) ; self . incomplete_endorsements . entry ( uhash ) . or_default ( ) . extend ( endorsements . endorsers ) ; let endorsed : Weight = self . incomplete_endorsements [ & uhash ] . keys ( ) . map ( | vidx | self . weight ( * vidx ) ) . sum ( ) ; // Stake required to consider unit to be endorsed. let threshold = self . total_weight ( ) / 2 ; if endorsed > threshold { info ! ( uhash " " ) ; // Unwrap is safe: We created the map entry above. let mut fully_endorsed = self . incomplete_endorsements . remove ( & uhash ) . unwrap ( ) ; let endorsed_map = self . weights ( ) . keys ( ) . map ( | vidx | fully_endorsed . remove ( & vidx ) ) . collect ( ) ; self . endorsements . insert ( uhash , endorsed_map ) ; } }
Adds a set of endorsements to the state.
Adds a set of endorsements to the state .
&mut self
endorsements
Endorsements<C>
&mut self
endorsements
Endorsements<C>