diff --git a/pallets/phala/src/compute/base_pool.rs b/pallets/phala/src/compute/base_pool.rs index f6616a309..0db9c2c89 100644 --- a/pallets/phala/src/compute/base_pool.rs +++ b/pallets/phala/src/compute/base_pool.rs @@ -573,11 +573,18 @@ pub mod pallet { pub fn set_reimbursements( origin: OriginFor, input: Vec<(T::AccountId, u64, BalanceOf)>, + add: bool, ) -> DispatchResult { let who = ensure_signed(origin)?; Self::ensure_migration_root(who)?; for (account_id, pid, balance) in input.iter() { - Reimbursements::::insert((account_id.clone(), *pid), *balance); + let key = (account_id, pid); + let new_balance = if add { + Reimbursements::::get(key).unwrap_or_default() + *balance + } else { + *balance + }; + Reimbursements::::insert(key, new_balance); } Ok(()) }