Skip to content

Commit

Permalink
Merge pull request #1557 from Phala-Network/add-reimbursements
Browse files Browse the repository at this point in the history
compute: allow add in set_reimbursements
  • Loading branch information
h4x3rotab authored Mar 25, 2024
2 parents d92a10a + 6ba128c commit 021a8c1
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion pallets/phala/src/compute/base_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -573,11 +573,18 @@ pub mod pallet {
pub fn set_reimbursements(
origin: OriginFor<T>,
input: Vec<(T::AccountId, u64, BalanceOf<T>)>,
add: bool,
) -> DispatchResult {
let who = ensure_signed(origin)?;
Self::ensure_migration_root(who)?;
for (account_id, pid, balance) in input.iter() {
Reimbursements::<T>::insert((account_id.clone(), *pid), *balance);
let key = (account_id, pid);
let new_balance = if add {
Reimbursements::<T>::get(key).unwrap_or_default() + *balance
} else {
*balance
};
Reimbursements::<T>::insert(key, new_balance);
}
Ok(())
}
Expand Down

0 comments on commit 021a8c1

Please sign in to comment.