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

feat: add event SkepticsChosen event in society #13291

Merged
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
10 changes: 7 additions & 3 deletions frame/society/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,8 @@ pub mod pallet {
Unfounded { founder: T::AccountId },
/// Some funds were deposited into the society account.
Deposit { value: BalanceOf<T, I> },
/// A group of members has been choosen as Skeptics
SkepticsChosen { skeptics: Vec<T::AccountId> },
}

/// The first member.
Expand Down Expand Up @@ -1610,12 +1612,14 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {

// Select sqrt(n) random members from the society and make them skeptics.
let pick_member =
|_| pick_item(&mut rng, &members[..]).expect("exited if members empty; qed");
for skeptic in (0..members.len().integer_sqrt()).map(pick_member) {
|_| pick_item(&mut rng, &members[..]).expect("exited if members empty; qed").clone();
let skeptics = (0..members.len().integer_sqrt()).map(pick_member).collect::<Vec<_>>();
skeptics.iter().for_each(|skeptic| {
for Bid { who: c, .. } in candidates.iter() {
<Votes<T, I>>::insert(c, skeptic, Vote::Skeptic);
}
}
});
Self::deposit_event(Event::<T, I>::SkepticsChosen { skeptics });
}

/// Attempt to slash the payout of some member. Return the total amount that was deducted.
Expand Down