Add slashing events to elections-phragmen. (#7543)

* 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>
This commit is contained in:
Kian Paimani
2020-11-18 12:19:22 +01:00
committed by GitHub
parent ede278ca57
commit 22a02d3e7a
@@ -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.
@@ -995,6 +999,7 @@ 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);
}
});
@@ -1002,6 +1007,7 @@ impl<T: Trait> Module<T> {
// 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);
});