Skip to content
Snippets Groups Projects
Commit 22a02d3e authored by Kian Paimani's avatar Kian Paimani Committed by GitHub
Browse files

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: default avatarGuillaume Thiolliere <gui.thiolliere@gmail.com>

Co-authored-by: default avatarGuillaume Thiolliere <gui.thiolliere@gmail.com>
parent ede278ca
Branches
No related merge requests found
......@@ -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);
});
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment