optimize update_lock
@@ -644,10 +644,12 @@ pub mod pallet {
}
fn update_lock(who: T::AccountId, amount: BalanceOf<T>) {
+ if amount == Zero::zero() {
<T as Config>::Currency::remove_lock(STAKING_ID, &who);
- // reset lock
+ } else {
<T as Config>::Currency::set_lock(STAKING_ID, &who, amount, WithdrawReasons::all());
}
+ }
fn ensure_pool(pid: u64) -> Result<PoolInfo<T::AccountId, BalanceOf<T>>, Error<T>> {
Self::mining_pools(&pid).ok_or(Error::<T>::PoolNotExist)
