fn internal_apply_pending_slope_changes_to_state(
    mut imstorage: IMStorage,
    state: &mut State,
    timestamp: u64,
) -> StdResult<()> {
    // Get the week that comes before the state's timestamp
    let mut week_iterator_timestamp = state.timestamp / SECONDS_PER_WEEK * SECONDS_PER_WEEK;

    // Go to the next week because we already processed
    // all weeks at or before the state's timestamp
    week_iterator_timestamp += SECONDS_PER_WEEK;

    // Loop to update state.
    for _ in 0..255 {
        if week_iterator_timestamp > timestamp {
            // We are past the current block timestamp, so break out of the loop
            break;
        }

        // Get the coefficient change corresponding to the week_iterator_timestamp
        let coefficient_changes = COEFFICIENT_CHANGES
            .may_load(
                match &imstorage {
                    IMStorage::ImmutableStorage(x) => *x,
                    IMStorage::MutableStorage(x) => *x,
                },
                U64Key::from(week_iterator_timestamp),
            )?
            .unwrap_or_default();

        // Subtract the coefficient changes from the total_balance_coefficients
        state.voting_power_coefficients -= coefficient_changes;

        if let IMStorage::MutableStorage(storage) = &mut imstorage {
            // Set the timestamp to that corresponding to the iterator
            state.timestamp = week_iterator_timestamp;

            // Save the state to storage at the corresponding timestamp
            STATE.save(*storage, state, state.timestamp)?;
        }

        // Increment week_interator
        week_iterator_timestamp += SECONDS_PER_WEEK;
    }

    Ok(())
}
/// Apply pending slope changes to state between state.timestamp and block_timestamp.
/// If imstorage is of type IMStorage::MutableStorage, then save each updated state to storage.
Apply pending slope changes to state between state.timestamp and block_timestamp.
If imstorage is of type IMStorage::MutableStorage, then save each updated state to storage.
Apply pending slope changes to state between state . timestamp and block_timestamp . If imstorage is of type IMStorage :: MutableStorage then save each updated state to storage .
fn internal_apply_pending_slope_changes_to_state(
    mut imstorage: IMStorage,
    state: &mut State,
    timestamp: u64,
) -> StdResult<()> {
    // Get the week that comes before the state's timestamp
    let mut week_iterator_timestamp = state.timestamp / SECONDS_PER_WEEK * SECONDS_PER_WEEK;
    // Go to the next week because we already processed
    // all weeks at or before the state's timestamp
    week_iterator_timestamp += SECONDS_PER_WEEK;
    // Loop to update state.
    for _ in 0..255 {
        if week_iterator_timestamp > timestamp {
            // We are past the current block timestamp, so break out of the loop
            break;
        }
        // Get the coefficient change corresponding to the week_iterator_timestamp
        let coefficient_changes = COEFFICIENT_CHANGES
            .may_load(
                match &imstorage {
                    IMStorage::ImmutableStorage(x) => *x,
                    IMStorage::MutableStorage(x) => *x,
                },
                U64Key::from(week_iterator_timestamp),
            )?
            .unwrap_or_default();
        // Subtract the coefficient changes from the total_balance_coefficients
        state.voting_power_coefficients -= coefficient_changes;
        if let IMStorage::MutableStorage(storage) = &mut imstorage {
            // Set the timestamp to that corresponding to the iterator
            state.timestamp = week_iterator_timestamp;
            // Save the state to storage at the corresponding timestamp
            STATE.save(*storage, state, state.timestamp)?;
        }
        // Increment week_interator
        week_iterator_timestamp += SECONDS_PER_WEEK;
    }
    Ok(())
}
fn internal_apply_pending_slope_changes_to_state ( mut imstorage : IMStorage , state : & mut State , timestamp : u64 , ) -> StdResult < ( ) > { // Get the week that comes before the state's timestamp let mut week_iterator_timestamp = state . timestamp / SECONDS_PER_WEEK * SECONDS_PER_WEEK ; // Go to the next week because we already processed // all weeks at or before the state's timestamp week_iterator_timestamp += SECONDS_PER_WEEK ; // Loop to update state. for _ in 0 .. 255 { if week_iterator_timestamp > timestamp { // We are past the current block timestamp, so break out of the loop break ; } // Get the coefficient change corresponding to the week_iterator_timestamp let coefficient_changes = COEFFICIENT_CHANGES . may_load ( match & imstorage { IMStorage :: ImmutableStorage ( x ) => * x , IMStorage :: MutableStorage ( x ) => * x , } , U64Key :: from ( week_iterator_timestamp ) , ) ? . unwrap_or_default ( ) ; // Subtract the coefficient changes from the total_balance_coefficients state . voting_power_coefficients -= coefficient_changes ; if let IMStorage :: MutableStorage ( storage ) = & mut imstorage { // Set the timestamp to that corresponding to the iterator state . timestamp = week_iterator_timestamp ; // Save the state to storage at the corresponding timestamp STATE . save ( * storage , state , state . timestamp ) ? ; } // Increment week_interator week_iterator_timestamp += SECONDS_PER_WEEK ; } Ok ( ( ) ) }
Apply pending slope changes to state between state.timestamp and block_timestamp.
Apply pending slope changes to state between state . timestamp and block_timestamp .
imstorage
IMStorage
state
&mut State
timestamp
u64