pub fn initialize(&mut self, staked_amount: U512) -> bool {
        if self.locked_amounts.is_some() {
            return false;
        }

        let release_period: U512 = U512::from(LOCKED_AMOUNTS_LENGTH);
        let weekly_release = staked_amount / release_period;

        let mut locked_amounts = [U512::zero(); LOCKED_AMOUNTS_LENGTH];
        let mut remaining_locked = staked_amount;

        // Ed and Henry prefer this idiom
        #[allow(clippy::needless_range_loop)]
        for i in 0..LOCKED_AMOUNTS_LENGTH - 1 {
            remaining_locked -= weekly_release;
            locked_amounts[i] = remaining_locked;
        }
        locked_amounts[LOCKED_AMOUNTS_LENGTH - 1] = U512::zero();

        self.locked_amounts = Some(locked_amounts);
        true
    }
/// Returns `false` if already initialized.
Returns `false` if already initialized.
Returns ` false ` if already initialized .
pub fn initialize(&mut self, staked_amount: U512) -> bool {
        if self.locked_amounts.is_some() {
            return false;
        }
        let release_period: U512 = U512::from(LOCKED_AMOUNTS_LENGTH);
        let weekly_release = staked_amount / release_period;
        let mut locked_amounts = [U512::zero(); LOCKED_AMOUNTS_LENGTH];
        let mut remaining_locked = staked_amount;
        // Ed and Henry prefer this idiom
        #[allow(clippy::needless_range_loop)]
        for i in 0..LOCKED_AMOUNTS_LENGTH - 1 {
            remaining_locked -= weekly_release;
            locked_amounts[i] = remaining_locked;
        }
        locked_amounts[LOCKED_AMOUNTS_LENGTH - 1] = U512::zero();
        self.locked_amounts = Some(locked_amounts);
        true
    }
pub fn initialize ( & mut self , staked_amount : U512 ) -> bool { if self . locked_amounts . is_some ( ) { return false ; } let release_period : U512 = U512 :: from ( LOCKED_AMOUNTS_LENGTH ) ; let weekly_release = staked_amount / release_period ; let mut locked_amounts = [ U512 :: zero ( ) ; LOCKED_AMOUNTS_LENGTH ] ; let mut remaining_locked = staked_amount ; // Ed and Henry prefer this idiom # [ allow ( clippy needless_range_loop ) ] for i in 0 .. LOCKED_AMOUNTS_LENGTH - 1 { remaining_locked -= weekly_release ; locked_amounts [ i ] = remaining_locked ; } locked_amounts [ LOCKED_AMOUNTS_LENGTH - 1 ] = U512 :: zero ( ) ; self . locked_amounts = Some ( locked_amounts ) ; true }
Returns `false` if already initialized.
Returns ` false ` if already initialized .
&mut self
staked_amount
U512
&mut self
staked_amount
U512