Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Add slashing events to elections-phragmen. #7543

Merged
merged 5 commits into from
Nov 18, 2020
Merged
Changes from 4 commits
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
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()));
kianenigma marked this conversation as resolved.
Show resolved Hide resolved
T::LoserCandidate::on_unbalanced(imbalance);
});

Expand Down