Skip to content

Commit

Permalink
Add slashing events to elections-phragmen. (paritytech#7543)
Browse files Browse the repository at this point in the history
* Add slashing events to elections-phragmen.

* Fix build

* Apply suggestions from code review

* Update frame/elections-phragmen/src/lib.rs

* Update frame/elections-phragmen/src/lib.rs

Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>

Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>
  • Loading branch information
2 people authored and shamb0 committed Nov 21, 2020
1 parent 385476c commit 272077c
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions frame/elections-phragmen/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,10 @@ decl_event!(
/// A \[member\] has been removed. This should always be followed by either `NewTerm` or
/// `EmptyTerm`.
MemberKicked(AccountId),
/// A candidate was slashed due to failing to obtain a seat as member or runner-up
CandidateSlashed(AccountId, Balance),
/// A seat holder (member or runner-up) was slashed due to failing to retaining their position.
SeatHolderSlashed(AccountId, Balance),
/// A \[member\] has renounced their candidacy.
MemberRenounced(AccountId),
/// A voter was reported with the the report being successful or not.
Expand Down Expand Up @@ -995,13 +999,15 @@ impl<T: Trait> Module<T> {
new_runners_up_ids_sorted.binary_search(&c).is_err()
{
let (imbalance, _) = T::Currency::slash_reserved(&c, T::CandidacyBond::get());
Self::deposit_event(RawEvent::CandidateSlashed(c, T::CandidacyBond::get()));
T::LoserCandidate::on_unbalanced(imbalance);
}
});

// Burn outgoing bonds
to_burn_bond.into_iter().for_each(|x| {
let (imbalance, _) = T::Currency::slash_reserved(&x, T::CandidacyBond::get());
Self::deposit_event(RawEvent::SeatHolderSlashed(x, T::CandidacyBond::get()));
T::LoserCandidate::on_unbalanced(imbalance);
});

Expand Down

0 comments on commit 272077c

Please sign in to comment.