mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 23:21:06 +00:00
Forcing-aware offchain Phragmén. (#5580)
* Make it force-aware * Fix merge issues
This commit is contained in:
@@ -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(¤t_era, &controller, &exposure);
|
||||
|
||||
Reference in New Issue
Block a user