fn slash_validator(stash: &T::AccountId, slash: BalanceOf<T>) {
		// The exposure (backing stake) information of the validator to be slashed.
		let exposure = Self::stakers(stash);
		// The amount we are actually going to slash (can't be bigger than their total exposure)
		let slash = slash.min(exposure.total);
		// The amount we'll slash from the validator's stash directly.
		let own_slash = exposure.own.min(slash);
		let (mut imbalance, missing) = T::Currency::slash(stash, own_slash);
		let own_slash = own_slash - missing;
		// The amount remaining that we can't slash from the validator, that must be taken from the nominators.
		let rest_slash = slash - own_slash;
		if !rest_slash.is_zero() {
			// The total to be slashed from the nominators.
			let total = exposure.total - exposure.own;
			if !total.is_zero() {
				let safe_mul_rational = |b| b * rest_slash / total;// FIXME #1572 avoid overflow
				for i in exposure.others.iter() {
					// best effort - not much that can be done on fail.
					imbalance.subsume(T::Currency::slash(&i.who, safe_mul_rational(i.value)).0)
				}
			}
		}
		T::Slash::on_unbalanced(imbalance);
	}
/// Slash a given validator by a specific amount. Removes the slash from their balance by preference,
/// and reduces the nominators' balance if needed.
Slash a given validator by a specific amount. Removes the slash from their balance by preference,
and reduces the nominators' balance if needed.
Slash a given validator by a specific amount . Removes the slash from their balance by preference and reduces the nominators ' balance if needed .
fn slash_validator(stash: &T::AccountId, slash: BalanceOf<T>) {
		// The exposure (backing stake) information of the validator to be slashed.
		let exposure = Self::stakers(stash);
		// The amount we are actually going to slash (can't be bigger than their total exposure)
		let slash = slash.min(exposure.total);
		// The amount we'll slash from the validator's stash directly.
		let own_slash = exposure.own.min(slash);
		let (mut imbalance, missing) = T::Currency::slash(stash, own_slash);
		let own_slash = own_slash - missing;
		// The amount remaining that we can't slash from the validator, that must be taken from the nominators.
		let rest_slash = slash - own_slash;
		if !rest_slash.is_zero() {
			// The total to be slashed from the nominators.
			let total = exposure.total - exposure.own;
			if !total.is_zero() {
				let safe_mul_rational = |b| b * rest_slash / total;// FIXME #1572 avoid overflow
				for i in exposure.others.iter() {
					// best effort - not much that can be done on fail.
					imbalance.subsume(T::Currency::slash(&i.who, safe_mul_rational(i.value)).0)
				}
			}
		}
		T::Slash::on_unbalanced(imbalance);
	}
fn slash_validator ( stash : & T :: AccountId , slash : BalanceOf < T > ) { // The exposure (backing stake) information of the validator to be slashed. let exposure = Self :: stakers ( stash ) ; // The amount we are actually going to slash (can't be bigger than their total exposure) let slash = slash . min ( exposure . total ) ; // The amount we'll slash from the validator's stash directly. let own_slash = exposure . own . min ( slash ) ; let ( mut imbalance , missing ) = T :: Currency :: slash ( stash , own_slash ) ; let own_slash = own_slash - missing ; // The amount remaining that we can't slash from the validator, that must be taken from the nominators. let rest_slash = slash - own_slash ; if ! rest_slash . is_zero ( ) { // The total to be slashed from the nominators. let total = exposure . total - exposure . own ; if ! total . is_zero ( ) { let safe_mul_rational = | b | b * rest_slash / total ; // FIXME #1572 avoid overflow for i in exposure . others . iter ( ) { // best effort - not much that can be done on fail. imbalance . subsume ( T :: Currency :: slash ( & i . who , safe_mul_rational ( i . value ) ) . 0 ) } } } T :: Slash :: on_unbalanced ( imbalance ) ; }
Slash a given validator by a specific amount.
Slash a given validator by a specific amount .
stash
&T::AccountId
slash
BalanceOf<T>
stash
&T::AccountId
slash
BalanceOf<T>