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

Commit

Permalink
safer end_era
Browse files Browse the repository at this point in the history
  • Loading branch information
gui1117 committed Jan 30, 2020
1 parent c088756 commit 72ff737
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion frame/staking/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1542,7 +1542,14 @@ impl<T: Trait> Module<T> {
}

fn end_session(session_index: SessionIndex) {
if ErasStartSessionIndex::get(Self::active_era() + 1) == session_index + 1 {
let next_era_start = ErasStartSessionIndex::get(Self::active_era() + 1);

if next_era_start < session_index + 1 {
frame_support::print("Error: some era ending has been missed");
}

// This should be a strict equality but better be safe in case ending has been missed.
if next_era_start <= session_index + 1 {
Self::end_era(session_index);
}
}
Expand Down

0 comments on commit 72ff737

Please sign in to comment.