pub(crate) fn valid_panorama(
        &self,
        creator: ValidatorIndex,
        mut pan: Panorama<C>,
    ) -> Panorama<C> {
        // Make sure the panorama sees the creator's own previous unit.
        let maybe_prev_uhash = self.panorama()[creator].correct();
        if let Some(prev_uhash) = maybe_prev_uhash {
            if pan[creator].correct() != Some(prev_uhash) {
                pan = pan.merge(self, &self.inclusive_panorama(prev_uhash));
            }
        }
        let endorsed = self.seen_endorsed(&pan);
        if self.validate_lnc(creator, &pan, &endorsed).is_none() {
            return pan;
        }
        // `pan` violates the LNC.
        // Start from the creator's previous unit, mark all faulty
        // validators as faulty, and add only endorsed units from correct validators.
        pan = maybe_prev_uhash.map_or_else(
            || Panorama::new(self.validator_count()),
            |prev_uhash| self.inclusive_panorama(prev_uhash),
        );
        for faulty_v in self.faulty_validators() {
            pan[faulty_v] = Observation::Faulty;
        }
        for endorsed_hash in &endorsed {
            if !pan.sees_correct(self, endorsed_hash) {
                pan = pan.merge(self, &self.inclusive_panorama(endorsed_hash));
            }
        }
        pan
    }
/// Creates a panorama that is valid for use in `creator`'s next unit, and as close as possible
/// to the given one. It is only modified if necessary for validity:
/// * Cite `creator`'s previous unit, i.e. don't equivocate.
/// * Satisfy the LNC, i.e. don't add new naively cited forks.
Creates a panorama that is valid for use in `creator`'s next unit, and as close as possible
to the given one. It is only modified if necessary for validity:
Cite `creator`'s previous unit, i.e. don't equivocate.
Creates a panorama that is valid for use in ` creator ` ' s next unit and as close as possible to the given one . It is only modified if necessary for validity : Cite ` creator ` ' s previous unit i . e . don ' t equivocate .
pub(crate) fn valid_panorama(
        &self,
        creator: ValidatorIndex,
        mut pan: Panorama<C>,
    ) -> Panorama<C> {
        // Make sure the panorama sees the creator's own previous unit.
        let maybe_prev_uhash = self.panorama()[creator].correct();
        if let Some(prev_uhash) = maybe_prev_uhash {
            if pan[creator].correct() != Some(prev_uhash) {
                pan = pan.merge(self, &self.inclusive_panorama(prev_uhash));
            }
        }
        let endorsed = self.seen_endorsed(&pan);
        if self.validate_lnc(creator, &pan, &endorsed).is_none() {
            return pan;
        }
        // `pan` violates the LNC.
        // Start from the creator's previous unit, mark all faulty
        // validators as faulty, and add only endorsed units from correct validators.
        pan = maybe_prev_uhash.map_or_else(
            || Panorama::new(self.validator_count()),
            |prev_uhash| self.inclusive_panorama(prev_uhash),
        );
        for faulty_v in self.faulty_validators() {
            pan[faulty_v] = Observation::Faulty;
        }
        for endorsed_hash in &endorsed {
            if !pan.sees_correct(self, endorsed_hash) {
                pan = pan.merge(self, &self.inclusive_panorama(endorsed_hash));
            }
        }
        pan
    }
pub ( crate ) fn valid_panorama ( & self , creator : ValidatorIndex , mut pan : Panorama < C > , ) -> Panorama < C > { // Make sure the panorama sees the creator's own previous unit. let maybe_prev_uhash = self . panorama ( ) [ creator ] . correct ( ) ; if let Some ( prev_uhash ) = maybe_prev_uhash { if pan [ creator ] . correct ( ) != Some ( prev_uhash ) { pan = pan . merge ( self , & self . inclusive_panorama ( prev_uhash ) ) ; } } let endorsed = self . seen_endorsed ( & pan ) ; if self . validate_lnc ( creator , & pan , & endorsed ) . is_none ( ) { return pan ; } // `pan` violates the LNC. // Start from the creator's previous unit, mark all faulty // validators as faulty, and add only endorsed units from correct validators. pan = maybe_prev_uhash . map_or_else ( | | Panorama :: new ( self . validator_count ( ) ) , | prev_uhash | self . inclusive_panorama ( prev_uhash ) , ) ; for faulty_v in self . faulty_validators ( ) { pan [ faulty_v ] = Observation :: Faulty ; } for endorsed_hash in & endorsed { if ! pan . sees_correct ( self , endorsed_hash ) { pan = pan . merge ( self , & self . inclusive_panorama ( endorsed_hash ) ) ; } } pan }
Creates a panorama that is valid for use in `creator`'s next unit, and as close as possible
to the given one.
Creates a panorama that is valid for use in ` creator ` ' s next unit and as close as possible to the given one .
&self
creator
ValidatorIndex
pan
Panorama<C>
&self
creator
ValidatorIndex
pan
Panorama<C>