mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 23:21:06 +00:00
Apply some clippy lints (#11154)
* Apply some clippy hints * Revert clippy ci changes * Update client/cli/src/commands/generate.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update client/cli/src/commands/inspect_key.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update client/db/src/bench.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update client/db/src/bench.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update client/service/src/client/block_rules.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update client/service/src/client/block_rules.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update client/network/src/transactions.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update client/network/src/protocol.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Revert due to missing `or_default` function. * Fix compilation and simplify code * Undo change that corrupts benchmark. * fix clippy * Update client/service/test/src/lib.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update client/state-db/src/noncanonical.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update client/state-db/src/noncanonical.rs remove leftovers! * Update client/tracing/src/logging/directives.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update utils/fork-tree/src/lib.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * added needed ref * Update frame/referenda/src/benchmarking.rs * Simplify byte-vec creation * let's just not overlap the ranges * Correction * cargo fmt * Update utils/frame/benchmarking-cli/src/shared/stats.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update utils/frame/benchmarking-cli/src/pallet/command.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update utils/frame/benchmarking-cli/src/pallet/command.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> Co-authored-by: Giles Cope <gilescope@gmail.com>
This commit is contained in:
committed by
GitHub
parent
a990473cf9
commit
b581604aa7
@@ -775,7 +775,7 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
|
||||
|
||||
/// Get both the free and reserved balances of an account.
|
||||
fn account(who: &T::AccountId) -> AccountData<T::Balance> {
|
||||
T::AccountStore::get(&who)
|
||||
T::AccountStore::get(who)
|
||||
}
|
||||
|
||||
/// Handles any steps needed after mutating an account.
|
||||
@@ -988,17 +988,15 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
|
||||
}
|
||||
} else {
|
||||
Locks::<T, I>::insert(who, bounded_locks);
|
||||
if !existed {
|
||||
if system::Pallet::<T>::inc_consumers_without_limit(who).is_err() {
|
||||
// No providers for the locks. This is impossible under normal circumstances
|
||||
// since the funds that are under the lock will themselves be stored in the
|
||||
// account and therefore will need a reference.
|
||||
log::warn!(
|
||||
target: "runtime::balances",
|
||||
"Warning: Attempt to introduce lock consumer reference, yet no providers. \
|
||||
This is unexpected but should be safe."
|
||||
);
|
||||
}
|
||||
if !existed && system::Pallet::<T>::inc_consumers_without_limit(who).is_err() {
|
||||
// No providers for the locks. This is impossible under normal circumstances
|
||||
// since the funds that are under the lock will themselves be stored in the
|
||||
// account and therefore will need a reference.
|
||||
log::warn!(
|
||||
target: "runtime::balances",
|
||||
"Warning: Attempt to introduce lock consumer reference, yet no providers. \
|
||||
This is unexpected but should be safe."
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1107,7 +1105,7 @@ impl<T: Config<I>, I: 'static> fungible::Mutate<T::AccountId> for Pallet<T, I> {
|
||||
return Ok(())
|
||||
}
|
||||
Self::try_mutate_account(who, |account, _is_new| -> DispatchResult {
|
||||
Self::deposit_consequence(who, amount, &account, true).into_result()?;
|
||||
Self::deposit_consequence(who, amount, account, true).into_result()?;
|
||||
account.free += amount;
|
||||
Ok(())
|
||||
})?;
|
||||
@@ -1126,7 +1124,7 @@ impl<T: Config<I>, I: 'static> fungible::Mutate<T::AccountId> for Pallet<T, I> {
|
||||
let actual = Self::try_mutate_account(
|
||||
who,
|
||||
|account, _is_new| -> Result<T::Balance, DispatchError> {
|
||||
let extra = Self::withdraw_consequence(who, amount, &account).into_result()?;
|
||||
let extra = Self::withdraw_consequence(who, amount, account).into_result()?;
|
||||
let actual = amount + extra;
|
||||
account.free -= actual;
|
||||
Ok(actual)
|
||||
@@ -1214,7 +1212,7 @@ impl<T: Config<I>, I: 'static> fungible::MutateHold<T::AccountId> for Pallet<T,
|
||||
ensure!(best_effort || actual == amount, Error::<T, I>::InsufficientBalance);
|
||||
// ^^^ Guaranteed to be <= amount and <= a.reserved
|
||||
a.free = new_free;
|
||||
a.reserved = a.reserved.saturating_sub(actual.clone());
|
||||
a.reserved = a.reserved.saturating_sub(actual);
|
||||
Ok(actual)
|
||||
})
|
||||
}
|
||||
@@ -1318,7 +1316,7 @@ mod imbalances {
|
||||
}
|
||||
}
|
||||
fn peek(&self) -> T::Balance {
|
||||
self.0.clone()
|
||||
self.0
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1377,7 +1375,7 @@ mod imbalances {
|
||||
}
|
||||
}
|
||||
fn peek(&self) -> T::Balance {
|
||||
self.0.clone()
|
||||
self.0
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1560,7 +1558,7 @@ where
|
||||
if value.is_zero() {
|
||||
return (NegativeImbalance::zero(), Zero::zero())
|
||||
}
|
||||
if Self::total_balance(&who).is_zero() {
|
||||
if Self::total_balance(who).is_zero() {
|
||||
return (NegativeImbalance::zero(), value)
|
||||
}
|
||||
|
||||
@@ -1656,7 +1654,7 @@ where
|
||||
return Self::PositiveImbalance::zero()
|
||||
}
|
||||
|
||||
let r = Self::try_mutate_account(
|
||||
Self::try_mutate_account(
|
||||
who,
|
||||
|account, is_new| -> Result<Self::PositiveImbalance, DispatchError> {
|
||||
let ed = T::ExistentialDeposit::get();
|
||||
@@ -1673,9 +1671,7 @@ where
|
||||
Ok(PositiveImbalance::new(value))
|
||||
},
|
||||
)
|
||||
.unwrap_or_else(|_| Self::PositiveImbalance::zero());
|
||||
|
||||
r
|
||||
.unwrap_or_else(|_| Self::PositiveImbalance::zero())
|
||||
}
|
||||
|
||||
/// Withdraw some free balance from an account, respecting existence requirements.
|
||||
@@ -1785,7 +1781,7 @@ where
|
||||
account.free.checked_sub(&value).ok_or(Error::<T, I>::InsufficientBalance)?;
|
||||
account.reserved =
|
||||
account.reserved.checked_add(&value).ok_or(ArithmeticError::Overflow)?;
|
||||
Self::ensure_can_withdraw(&who, value.clone(), WithdrawReasons::RESERVE, account.free)
|
||||
Self::ensure_can_withdraw(&who, value, WithdrawReasons::RESERVE, account.free)
|
||||
})?;
|
||||
|
||||
Self::deposit_event(Event::Reserved { who: who.clone(), amount: value });
|
||||
@@ -1799,7 +1795,7 @@ where
|
||||
if value.is_zero() {
|
||||
return Zero::zero()
|
||||
}
|
||||
if Self::total_balance(&who).is_zero() {
|
||||
if Self::total_balance(who).is_zero() {
|
||||
return value
|
||||
}
|
||||
|
||||
@@ -1820,7 +1816,7 @@ where
|
||||
},
|
||||
};
|
||||
|
||||
Self::deposit_event(Event::Unreserved { who: who.clone(), amount: actual.clone() });
|
||||
Self::deposit_event(Event::Unreserved { who: who.clone(), amount: actual });
|
||||
value - actual
|
||||
}
|
||||
|
||||
@@ -1835,7 +1831,7 @@ where
|
||||
if value.is_zero() {
|
||||
return (NegativeImbalance::zero(), Zero::zero())
|
||||
}
|
||||
if Self::total_balance(&who).is_zero() {
|
||||
if Self::total_balance(who).is_zero() {
|
||||
return (NegativeImbalance::zero(), value)
|
||||
}
|
||||
|
||||
@@ -1925,7 +1921,7 @@ where
|
||||
},
|
||||
Err(index) => {
|
||||
reserves
|
||||
.try_insert(index, ReserveData { id: id.clone(), amount: value })
|
||||
.try_insert(index, ReserveData { id: *id, amount: value })
|
||||
.map_err(|_| Error::<T, I>::TooManyReserves)?;
|
||||
},
|
||||
};
|
||||
@@ -2086,7 +2082,7 @@ where
|
||||
reserves
|
||||
.try_insert(
|
||||
index,
|
||||
ReserveData { id: id.clone(), amount: actual },
|
||||
ReserveData { id: *id, amount: actual },
|
||||
)
|
||||
.map_err(|_| Error::<T, I>::TooManyReserves)?;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user