Skip to content
Snippets Groups Projects
Unverified Commit 15ced219 authored by Liam Aharon's avatar Liam Aharon
Browse files

reduce code duplication

parent 5c8185a2
Branches
No related merge requests found
Pipeline #462935 failed with stages
in 8 minutes and 6 seconds
...@@ -628,16 +628,13 @@ pub mod pallet { ...@@ -628,16 +628,13 @@ pub mod pallet {
/// NOTE: this is a pure function without side effects. It does not modify any state /// NOTE: this is a pure function without side effects. It does not modify any state
/// directly, that is the responsibility of the caller. /// directly, that is the responsibility of the caller.
pub fn update_pool_and_staker_rewards( pub fn update_pool_and_staker_rewards(
mut pool_info: PoolInfoFor<T>, pool_info: PoolInfoFor<T>,
mut staker_info: PoolStakerInfo<T::Balance>, mut staker_info: PoolStakerInfo<T::Balance>,
) -> Result<(PoolInfoFor<T>, PoolStakerInfo<T::Balance>), DispatchError> { ) -> Result<(PoolInfoFor<T>, PoolStakerInfo<T::Balance>), DispatchError> {
let reward_per_token = Self::reward_per_token(&pool_info)?; let pool_info = Self::update_pool_rewards(pool_info)?;
pool_info.last_update_block = frame_system::Pallet::<T>::block_number();
pool_info.reward_per_token_stored = reward_per_token;
staker_info.rewards = Self::derive_rewards(&pool_info, &staker_info)?; staker_info.rewards = Self::derive_rewards(&pool_info, &staker_info)?;
staker_info.reward_per_token_paid = reward_per_token; staker_info.reward_per_token_paid = pool_info.reward_per_token_stored;
return Ok((pool_info, staker_info)); return Ok((pool_info, staker_info));
} }
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment