pub fn validate_bonding(&self, validator: &PublicKey, amount: U512) -> Result<()> {
        let max = self
            .min_without(validator)
            .unwrap_or(U512::MAX)
            .saturating_add(MAX_SPREAD);
        let min = self
            .max_without(validator)
            .unwrap_or_else(U512::zero)
            .saturating_sub(MAX_SPREAD);
        let stake = self.0.get(validator).map(|s| *s + amount).unwrap_or(amount);
        if stake > max || stake < min {
            return Err(Error::SpreadTooHigh);
        }
        let max_increase = MAX_INCREASE.min(self.sum() * MAX_REL_INCREASE / 1_000_000);
        if (stake.is_zero() && amount > min.saturating_add(max_increase))
            || (!stake.is_zero() && amount > max_increase)
        {
            return Err(Error::BondTooLarge);
        }
        Ok(())
    }
/// Returns an error if bonding the specified amount is not allowed.
Returns an error if bonding the specified amount is not allowed.
Returns an error if bonding the specified amount is not allowed .
pub fn validate_bonding(&self, validator: &PublicKey, amount: U512) -> Result<()> {
        let max = self
            .min_without(validator)
            .unwrap_or(U512::MAX)
            .saturating_add(MAX_SPREAD);
        let min = self
            .max_without(validator)
            .unwrap_or_else(U512::zero)
            .saturating_sub(MAX_SPREAD);
        let stake = self.0.get(validator).map(|s| *s + amount).unwrap_or(amount);
        if stake > max || stake < min {
            return Err(Error::SpreadTooHigh);
        }
        let max_increase = MAX_INCREASE.min(self.sum() * MAX_REL_INCREASE / 1_000_000);
        if (stake.is_zero() && amount > min.saturating_add(max_increase))
            || (!stake.is_zero() && amount > max_increase)
        {
            return Err(Error::BondTooLarge);
        }
        Ok(())
    }
pub fn validate_bonding ( & self , validator : & PublicKey , amount : U512 ) -> Result < ( ) > { let max = self . min_without ( validator ) . unwrap_or ( U512 :: MAX ) . saturating_add ( MAX_SPREAD ) ; let min = self . max_without ( validator ) . unwrap_or_else ( U512 :: zero ) . saturating_sub ( MAX_SPREAD ) ; let stake = self . 0 . get ( validator ) . map ( | s | * s + amount ) . unwrap_or ( amount ) ; if stake > max || stake < min { return Err ( Error :: SpreadTooHigh ) ; } let max_increase = MAX_INCREASE . min ( self . sum ( ) * MAX_REL_INCREASE / 1_000_000 ) ; if ( stake . is_zero ( ) && amount > min . saturating_add ( max_increase ) ) || ( ! stake . is_zero ( ) && amount > max_increase ) { return Err ( Error :: BondTooLarge ) ; } Ok ( ( ) ) }
Returns an error if bonding the specified amount is not allowed.
Returns an error if bonding the specified amount is not allowed .
&self
validator
&PublicKey
amount
U512
&self
validator
&PublicKey
amount
U512