payout function return the reward
@@ -1238,11 +1238,9 @@ impl<T: Config> Module<T> {
round_stats.frac_target_online_reward,
round_stats.online_workers,
);
- Self::payout(online, payout_target, PayoutReason::OnlineReward);
- let coins = T::TEECurrency::issue(online);
- let (coin_reward, _) = coins.ration(T::RewardRation::get(), T::TreasuryRation::get());
- StashFire::<T>::mutate(stash, |x| *x += coin_reward.peek());
- RewardOnline::<T>::mutate(stash, |x| *x += coin_reward.peek());
+ let coin_reward = Self::payout(online, payout_target, PayoutReason::OnlineReward);
+ StashFire::<T>::mutate(stash, |x| *x += coin_reward);
+ RewardOnline::<T>::mutate(stash, |x| *x += coin_reward);
}
// Adjusted compute worker reward
if claim_compute {
@@ -1251,11 +1249,9 @@ impl<T: Config> Module<T> {
round_stats.frac_target_compute_reward,
round_stats.compute_workers,
);
- Self::payout(compute, payout_target, PayoutReason::ComputeReward);
- let coins = T::TEECurrency::issue(compute);
- let (coin_reward, _) = coins.ration(T::RewardRation::get(), T::TreasuryRation::get());
- StashFire::<T>::mutate(stash, |x| *x += coin_reward.peek());
- RewardCompute::<T>::mutate(stash, |x| *x += coin_reward.peek());
+ let coin_reward = Self::payout(compute, payout_target, PayoutReason::ComputeReward);
+ StashFire::<T>::mutate(stash, |x| *x += coin_reward);
+ RewardCompute::<T>::mutate(stash, |x| *x += coin_reward);
// TODO: remove after PoC-3
WorkerComputeReward::<T>::mutate(stash, |x| *x += 1);
PayoutComputeReward::<T>::mutate(payout_target, |x| *x += 1);
@@ -1362,7 +1358,7 @@ impl<T: Config> Module<T> {
}
/// Actually pays out the reward
- fn payout(value: BalanceOf<T>, target: &T::AccountId, reason: PayoutReason) {
+ fn payout(value: BalanceOf<T>, target: &T::AccountId, reason: PayoutReason) -> BalanceOf<T> {
// Retion the reward and the treasury deposit
let coins = T::TEECurrency::issue(value);
let (coin_reward, coin_treasury) =
@@ -1377,6 +1373,7 @@ impl<T: Config> Module<T> {
));
Self::add_fire(&target, coin_reward.peek());
T::Treasury::on_unbalanced(coin_treasury);
+ coin_reward.peek()
}
fn add_fire(dest: &T::AccountId, amount: BalanceOf<T>) {
