Forcing-aware offchain Phragmén. (#5580)

* Make it force-aware

* Fix merge issues
This commit is contained in:
Kian Paimani
2020-04-09 11:30:33 +02:00
committed by GitHub
parent e7e7e89e71
commit 7da995214e
2 changed files with 32 additions and 2 deletions
+11 -2
View File
@@ -1010,7 +1010,8 @@ decl_storage! {
/// solutions to be submitted.
pub EraElectionStatus get(fn era_election_status): ElectionStatus<T::BlockNumber>;
/// True if the current planned session is final.
/// True if the current **planned** session is final. Note that this does not take era
/// forcing into account.
pub IsCurrentSessionFinal get(fn is_current_session_final): bool = false;
/// True if network has been upgraded to this version.
@@ -1166,7 +1167,8 @@ decl_module! {
if
// if we don't have any ongoing offchain compute.
Self::era_election_status().is_closed() &&
Self::is_current_session_final()
// either current session final based on the plan, or we're forcing.
(Self::is_current_session_final() || Self::will_era_be_forced())
{
if let Some(next_session_change) = T::NextNewSession::estimate_next_new_session(now){
if let Some(remaining) = next_session_change.checked_sub(&now) {
@@ -2895,6 +2897,13 @@ impl<T: Trait> Module<T> {
}
}
fn will_era_be_forced() -> bool {
match ForceEra::get() {
Forcing::ForceAlways | Forcing::ForceNew => true,
Forcing::ForceNone | Forcing::NotForcing => false,
}
}
#[cfg(feature = "runtime-benchmarks")]
pub fn add_era_stakers(current_era: EraIndex, controller: T::AccountId, exposure: Exposure<T::AccountId, BalanceOf<T>>) {
<ErasStakers<T>>::insert(&current_era, &controller, &exposure);