Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
FMT
  • Loading branch information
emostov committed Mar 21, 2022
commit 35a3077caa03eae3309e4fe1e1985772e3701d64
9 changes: 3 additions & 6 deletions frame/staking/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -601,12 +601,9 @@ impl<T: Config> StakingLedger<T> {
// Helper to update `target` and the ledgers total after accounting for slashing `target`.
let ratio = Perquintill::from_rational(slash_amount, affected_balance);
let mut slash_out_of = |target: &mut BalanceOf<T>, slash_remaining: &mut BalanceOf<T>| {
let mut slash_from_target = if slash_amount < affected_balance {
ratio * (*target)
} else {
*slash_remaining
}
.min(*target);
let mut slash_from_target =
if slash_amount < affected_balance { ratio * (*target) } else { *slash_remaining }
.min(*target);

// slash out from *target exactly `slash_from_target`.
*target = *target - slash_from_target;
Expand Down