pub(crate) fn pre_validate_unit(&self, swunit: &SignedWireUnit<C>) -> Result<(), UnitError> {
        let wunit = swunit.wire_unit();
        let creator = wunit.creator;
        if creator.0 as usize >= self.validator_count() {
            error!("Nonexistent validator should be rejected in Highway::pre_validate_unit.");
            return Err(UnitError::Creator); // Should be unreachable.
        }
        if Some(&Fault::Banned) == self.faults.get(&creator) {
            return Err(UnitError::Banned);
        }
        if wunit.round_exp < self.params.min_round_exp() {
            return Err(UnitError::RoundLengthExpLessThanMinimum);
        }
        if wunit.round_exp > self.params.max_round_exp() {
            return Err(UnitError::RoundLengthExpGreaterThanMaximum);
        }
        if wunit.value.is_none() && !wunit.panorama.has_correct() {
            return Err(UnitError::MissingBlock);
        }
        if wunit.panorama.len() != self.validator_count() {
            return Err(UnitError::PanoramaLength(wunit.panorama.len()));
        }
        if wunit.panorama[creator].is_faulty() {
            return Err(UnitError::FaultyCreator);
        }
        Ok(())
    }
/// Returns an error if `swunit` is invalid. This can be called even if the dependencies are
/// not present yet.
Returns an error if `swunit` is invalid. This can be called even if the dependencies are
not present yet.
Returns an error if ` swunit ` is invalid . This can be called even if the dependencies are not present yet .
pub(crate) fn pre_validate_unit(&self, swunit: &SignedWireUnit<C>) -> Result<(), UnitError> {
        let wunit = swunit.wire_unit();
        let creator = wunit.creator;
        if creator.0 as usize >= self.validator_count() {
            error!("Nonexistent validator should be rejected in Highway::pre_validate_unit.");
            return Err(UnitError::Creator); // Should be unreachable.
        }
        if Some(&Fault::Banned) == self.faults.get(&creator) {
            return Err(UnitError::Banned);
        }
        if wunit.round_exp < self.params.min_round_exp() {
            return Err(UnitError::RoundLengthExpLessThanMinimum);
        }
        if wunit.round_exp > self.params.max_round_exp() {
            return Err(UnitError::RoundLengthExpGreaterThanMaximum);
        }
        if wunit.value.is_none() && !wunit.panorama.has_correct() {
            return Err(UnitError::MissingBlock);
        }
        if wunit.panorama.len() != self.validator_count() {
            return Err(UnitError::PanoramaLength(wunit.panorama.len()));
        }
        if wunit.panorama[creator].is_faulty() {
            return Err(UnitError::FaultyCreator);
        }
        Ok(())
    }
pub ( crate ) fn pre_validate_unit ( & self , swunit : & SignedWireUnit < C > ) -> Result < ( ) , UnitError > { let wunit = swunit . wire_unit ( ) ; let creator = wunit . creator ; if creator . 0 as usize >= self . validator_count ( ) { error ! ( " " ) ; return Err ( UnitError :: Creator ) ; // Should be unreachable. } if Some ( & Fault :: Banned ) == self . faults . get ( & creator ) { return Err ( UnitError :: Banned ) ; } if wunit . round_exp < self . params . min_round_exp ( ) { return Err ( UnitError :: RoundLengthExpLessThanMinimum ) ; } if wunit . round_exp > self . params . max_round_exp ( ) { return Err ( UnitError :: RoundLengthExpGreaterThanMaximum ) ; } if wunit . value . is_none ( ) && ! wunit . panorama . has_correct ( ) { return Err ( UnitError :: MissingBlock ) ; } if wunit . panorama . len ( ) != self . validator_count ( ) { return Err ( UnitError :: PanoramaLength ( wunit . panorama . len ( ) ) ) ; } if wunit . panorama [ creator ] . is_faulty ( ) { return Err ( UnitError :: FaultyCreator ) ; } Ok ( ( ) ) }
Returns an error if `swunit` is invalid.
Returns an error if ` swunit ` is invalid .
&self
swunit
&SignedWireUnit<C>
&self
swunit
&SignedWireUnit<C>