Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
improve variable name (#9108)
Browse files Browse the repository at this point in the history
  • Loading branch information
gui1117 authored and shawntabrizi committed Jun 17, 2021
1 parent 2bb009a commit c7ca5cb
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions frame/staking/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2823,7 +2823,8 @@ impl<T: Config> frame_election_provider_support::ElectionDataProvider<T::Account
let current_session = Self::current_planned_session();
let current_era_start_session_index =
Self::eras_start_session_index(current_era).unwrap_or(0);
let era_length = current_session
// Number of session in the current era or the maximum session per era if reached.
let era_progress = current_session
.saturating_sub(current_era_start_session_index)
.min(T::SessionsPerEra::get());

Expand All @@ -2837,9 +2838,9 @@ impl<T: Config> frame_election_provider_support::ElectionDataProvider<T::Account
let sessions_left: T::BlockNumber = match ForceEra::<T>::get() {
Forcing::ForceNone => Bounded::max_value(),
Forcing::ForceNew | Forcing::ForceAlways => Zero::zero(),
Forcing::NotForcing if era_length >= T::SessionsPerEra::get() => Zero::zero(),
Forcing::NotForcing if era_progress >= T::SessionsPerEra::get() => Zero::zero(),
Forcing::NotForcing => T::SessionsPerEra::get()
.saturating_sub(era_length)
.saturating_sub(era_progress)
// One session is computed in this_session_end.
.saturating_sub(1)
.into(),
Expand Down

0 comments on commit c7ca5cb

Please sign in to comment.