fn select_validators() -> BalanceOf<T> {
		let maybe_elected_candidates = elect::<T, _, _, _>(
			Self::validator_count() as usize,
			Self::minimum_validator_count().max(1) as usize,
			<Validators<T>>::enumerate(),
			<Nominators<T>>::enumerate(),
			Self::slashable_balance_of,
			ElectionConfig::<BalanceOf<T>> {
				equalize: false,
				tolerance: <BalanceOf<T>>::sa(10 as u64),
				iterations: 10,
			}
		);

		if let Some(elected_candidates) = maybe_elected_candidates {
			// Clear Stakers and reduce their slash_count.
			for v in Self::current_elected().iter() {
				<Stakers<T>>::remove(v);
				let slash_count = <SlashCount<T>>::take(v);
				if slash_count > 1 {
					<SlashCount<T>>::insert(v, slash_count - 1);
				}
			}

			// Populate Stakers and figure out the minimum stake behind a slot.
			let mut slot_stake = elected_candidates[0].exposure.total;
			for c in &elected_candidates {
				if c.exposure.total < slot_stake {
					slot_stake = c.exposure.total;
				}
				<Stakers<T>>::insert(c.who.clone(), c.exposure.clone());
			}
			<SlotStake<T>>::put(&slot_stake);

			// Set the new validator set.
			let elected_stashes = elected_candidates.into_iter().map(|i| i.who).collect::<Vec<_>>();
			<CurrentElected<T>>::put(&elected_stashes);
			<session::Module<T>>::set_validators(
				&elected_stashes.into_iter().map(|s| Self::bonded(s).unwrap_or_default()).collect::<Vec<_>>()
			);

			slot_stake
		} else {
			// There were not enough candidates for even our minimal level of functionality.
			// This is bad.
			// We should probably disable all functionality except for block production
			// and let the chain keep producing blocks until we can decide on a sufficiently
			// substantial set.
			Self::slot_stake()
		}
	}
/// Select a new validator set from the assembled stakers and their role preferences.
///
/// Returns the new SlotStake value.
Select a new validator set from the assembled stakers and their role preferences.
Returns the new SlotStake value.
Select a new validator set from the assembled stakers and their role preferences . Returns the new SlotStake value .
fn select_validators() -> BalanceOf<T> {
		let maybe_elected_candidates = elect::<T, _, _, _>(
			Self::validator_count() as usize,
			Self::minimum_validator_count().max(1) as usize,
			<Validators<T>>::enumerate(),
			<Nominators<T>>::enumerate(),
			Self::slashable_balance_of,
			ElectionConfig::<BalanceOf<T>> {
				equalize: false,
				tolerance: <BalanceOf<T>>::sa(10 as u64),
				iterations: 10,
			}
		);
		if let Some(elected_candidates) = maybe_elected_candidates {
			// Clear Stakers and reduce their slash_count.
			for v in Self::current_elected().iter() {
				<Stakers<T>>::remove(v);
				let slash_count = <SlashCount<T>>::take(v);
				if slash_count > 1 {
					<SlashCount<T>>::insert(v, slash_count - 1);
				}
			}
			// Populate Stakers and figure out the minimum stake behind a slot.
			let mut slot_stake = elected_candidates[0].exposure.total;
			for c in &elected_candidates {
				if c.exposure.total < slot_stake {
					slot_stake = c.exposure.total;
				}
				<Stakers<T>>::insert(c.who.clone(), c.exposure.clone());
			}
			<SlotStake<T>>::put(&slot_stake);
			// Set the new validator set.
			let elected_stashes = elected_candidates.into_iter().map(|i| i.who).collect::<Vec<_>>();
			<CurrentElected<T>>::put(&elected_stashes);
			<session::Module<T>>::set_validators(
				&elected_stashes.into_iter().map(|s| Self::bonded(s).unwrap_or_default()).collect::<Vec<_>>()
			);
			slot_stake
		} else {
			// There were not enough candidates for even our minimal level of functionality.
			// This is bad.
			// We should probably disable all functionality except for block production
			// and let the chain keep producing blocks until we can decide on a sufficiently
			// substantial set.
			Self::slot_stake()
		}
	}
fn select_validators ( ) -> BalanceOf < T > { let maybe_elected_candidates = elect :: < T , _ , _ , _ > ( Self :: validator_count ( ) as usize , Self :: minimum_validator_count ( ) . max ( 1 ) as usize , < Validators < T > > :: enumerate ( ) , < Nominators < T > > :: enumerate ( ) , Self :: slashable_balance_of , ElectionConfig :: < BalanceOf < T > > { equalize : false , tolerance : < BalanceOf < T > > :: sa ( 10 as u64 ) , iterations : 10 , } ) ; if let Some ( elected_candidates ) = maybe_elected_candidates { // Clear Stakers and reduce their slash_count. for v in Self :: current_elected ( ) . iter ( ) { < Stakers < T > > :: remove ( v ) ; let slash_count = < SlashCount < T > > :: take ( v ) ; if slash_count > 1 { < SlashCount < T > > :: insert ( v , slash_count - 1 ) ; } } // Populate Stakers and figure out the minimum stake behind a slot. let mut slot_stake = elected_candidates [ 0 ] . exposure . total ; for c in & elected_candidates { if c . exposure . total < slot_stake { slot_stake = c . exposure . total ; } < Stakers < T > > :: insert ( c . who . clone ( ) , c . exposure . clone ( ) ) ; } < SlotStake < T > > :: put ( & slot_stake ) ; // Set the new validator set. let elected_stashes = elected_candidates . into_iter ( ) . map ( | i | i . who ) . collect :: < Vec < _ > > ( ) ; < CurrentElected < T > > :: put ( & elected_stashes ) ; < session :: Module < T > > :: set_validators ( & elected_stashes . into_iter ( ) . map ( | s | Self :: bonded ( s ) . unwrap_or_default ( ) ) . collect :: < Vec < _ > > ( ) ) ; slot_stake } else { // There were not enough candidates for even our minimal level of functionality. // This is bad. // We should probably disable all functionality except for block production // and let the chain keep producing blocks until we can decide on a sufficiently // substantial set. Self :: slot_stake ( ) } }
Select a new validator set from the assembled stakers and their role preferences.
Select a new validator set from the assembled stakers and their role preferences .