Skip to content

Commit

Permalink
Improve namings after code review
Browse files Browse the repository at this point in the history
Co-Authored-By: Oleh Mell <olehmell@users.noreply.github.com>
  • Loading branch information
F3Joule and olehmell committed Nov 6, 2023
1 parent 68f7357 commit 38cf11d
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions pallets/creator-staking/src/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -366,10 +366,10 @@ impl<T: Config> Pallet<T> {
staked: BalanceOf<T>,
era: EraIndex,
) -> BalanceOf<T> {
if let Some(reward_and_stake) = Self::general_era_info(era) {
if let Some(era_info) = Self::general_era_info(era) {
let (_, combined_backers_reward_share) =
Self::distributed_rewards_between_creator_and_backers(creator_stake_info, &reward_and_stake);
Perbill::from_rational(staked, reward_and_stake.staked) * combined_backers_reward_share
Self::distributed_rewards_between_creator_and_backers(creator_stake_info, &era_info);
Perbill::from_rational(staked, era_info.staked) * combined_backers_reward_share
} else {
Zero::zero()
}
Expand Down
4 changes: 2 additions & 2 deletions pallets/creator-staking/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -612,12 +612,12 @@ pub mod pallet {
let current_era = Self::current_era();
ensure!(era_to_claim < current_era, Error::<T>::CannotClaimInFutureEra);

let staking_info = Self::creator_stake_info(creator_id, era_to_claim).unwrap_or_default();
let creator_stake_info = Self::creator_stake_info(creator_id, era_to_claim).unwrap_or_default();
let reward_and_stake =
Self::general_era_info(era_to_claim).ok_or(Error::<T>::EraNotFound)?;

let (_, combined_backers_reward_share) =
Self::distributed_rewards_between_creator_and_backers(&staking_info, &reward_and_stake);
Self::distributed_rewards_between_creator_and_backers(&creator_stake_info, &reward_and_stake);
let backer_reward =
Perbill::from_rational(backer_staked, reward_and_stake.staked) * combined_backers_reward_share;

Expand Down
2 changes: 1 addition & 1 deletion pallets/creator-staking/src/tests/testing_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ pub(super) fn assert_claim_creator(creator_id: SpaceId, claim_era: EraIndex) {

assert!(final_state.creator_stakes_info.rewards_claimed);

// Just in case dev is also a backer - this shouldn't cause any change in StakesInfo or BackerLocksByAccount
// Just in case creator is also a backer - this shouldn't cause any change in StakesInfo or BackerLocksByAccount
assert_eq!(init_state.backer_stakes.stakes, final_state.backer_stakes.stakes);
assert_eq!(init_state.backer_locks.total_locked, final_state.backer_locks.total_locked);
assert_eq!(init_state.backer_locks.unbonding_info.vec(), final_state.backer_locks.unbonding_info.vec());
Expand Down
6 changes: 3 additions & 3 deletions pallets/creator-staking/src/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1817,12 +1817,12 @@ fn distributed_rewards_between_creator_and_backers_util() {

let creator_stake_ratio = Perbill::from_rational(staked_on_creator, total_staked);
let calculated_backers_reward = base_backers_reward;
let calculated_dev_reward = creator_stake_ratio * base_creators_reward;
assert_eq!(calculated_dev_reward, creator_reward_share);
let calculated_creator_reward = creator_stake_ratio * base_creators_reward;
assert_eq!(calculated_creator_reward, creator_reward_share);
assert_eq!(calculated_backers_reward, combined_backers_reward_share);

assert_eq!(
calculated_backers_reward + calculated_dev_reward,
calculated_backers_reward + calculated_creator_reward,
creator_reward_share + combined_backers_reward_share
);
}
Expand Down

0 comments on commit 38cf11d

Please sign in to comment.