pub fn compute_global_reward(
    reward_emission_index: &mut RewardEmissionsIndex,
    spread: Uint256,
    block_height: u64,
) {
    if reward_emission_index.last_reward_updated >= block_height {
        return;
    }

    // Get the reward accrued since the last call to compute_global_reward for this reward index
    let passed_blocks =
        Decimal256::from_uint256(block_height - reward_emission_index.last_reward_updated);
    let reward_accrued = passed_blocks * reward_emission_index.glow_emission_rate;

    if !reward_accrued.is_zero() && !spread.is_zero() {
        reward_emission_index.global_reward_index +=
            reward_accrued / Decimal256::from_uint256(spread);
    }

    reward_emission_index.last_reward_updated = block_height;
}
/// Compute distributed reward and update global reward index
Compute distributed reward and update global reward index
Compute distributed reward and update global reward index
pub fn compute_global_reward(
    reward_emission_index: &mut RewardEmissionsIndex,
    spread: Uint256,
    block_height: u64,
) {
    if reward_emission_index.last_reward_updated >= block_height {
        return;
    }
    // Get the reward accrued since the last call to compute_global_reward for this reward index
    let passed_blocks =
        Decimal256::from_uint256(block_height - reward_emission_index.last_reward_updated);
    let reward_accrued = passed_blocks * reward_emission_index.glow_emission_rate;
    if !reward_accrued.is_zero() && !spread.is_zero() {
        reward_emission_index.global_reward_index +=
            reward_accrued / Decimal256::from_uint256(spread);
    }
    reward_emission_index.last_reward_updated = block_height;
}
pub fn compute_global_reward ( reward_emission_index : & mut RewardEmissionsIndex , spread : Uint256 , block_height : u64 , ) { if reward_emission_index . last_reward_updated >= block_height { return ; } // Get the reward accrued since the last call to compute_global_reward for this reward index let passed_blocks = Decimal256 :: from_uint256 ( block_height - reward_emission_index . last_reward_updated ) ; let reward_accrued = passed_blocks * reward_emission_index . glow_emission_rate ; if ! reward_accrued . is_zero ( ) && ! spread . is_zero ( ) { reward_emission_index . global_reward_index += reward_accrued / Decimal256 :: from_uint256 ( spread ) ; } reward_emission_index . last_reward_updated = block_height ; }
Compute distributed reward and update global reward index
Compute distributed reward and update global reward index
reward_emission_index
&mut RewardEmissionsIndex
spread
Uint256
block_height
u64
reward_emission_index
&mut RewardEmissionsIndex
spread
Uint256
block_height
u64