mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-19 22:51:03 +00:00
pallet-staking: Converts all math operations to safe (#2435)
This PR converts unsafe math operations to safe in the staking pallet. Closes https://github.com/paritytech/polkadot-sdk/issues/2431 --------- Co-authored-by: Ankan <10196091+Ank4n@users.noreply.github.com>
This commit is contained in:
@@ -1068,7 +1068,9 @@ pub mod pallet {
|
||||
ensure!(ledger.active >= min_active_bond, Error::<T>::InsufficientBond);
|
||||
|
||||
// Note: in case there is no current era it is fine to bond one era more.
|
||||
let era = Self::current_era().unwrap_or(0) + T::BondingDuration::get();
|
||||
let era = Self::current_era()
|
||||
.unwrap_or(0)
|
||||
.defensive_saturating_add(T::BondingDuration::get());
|
||||
if let Some(chunk) = ledger.unlocking.last_mut().filter(|chunk| chunk.era == era) {
|
||||
// To keep the chunk count down, we only keep one chunk per era. Since
|
||||
// `unlocking` is a FiFo queue, if a chunk exists for `era` we know that it will
|
||||
|
||||
Reference in New Issue
Block a user