Skip to content
Snippets Groups Projects
Commit 53c2df8c authored by Cédric Moreau's avatar Cédric Moreau
Browse files

feat(smith-members): blacklisting stub

parent 6b575e47
No related branches found
No related tags found
No related merge requests found
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#![allow(clippy::type_complexity)] #![allow(clippy::type_complexity)]
use super::pallet::*; use super::pallet::*;
use crate::OnBlacklistedMember;
use frame_support::pallet_prelude::Weight; use frame_support::pallet_prelude::Weight;
use frame_support::traits::Get; use frame_support::traits::Get;
use pallet_offences::traits::OnOffenceHandler; use pallet_offences::traits::OnOffenceHandler;
...@@ -54,9 +55,9 @@ where ...@@ -54,9 +55,9 @@ where
match strategy { match strategy {
SlashStrategy::Blacklist => { SlashStrategy::Blacklist => {
for offender in offenders { for offender in offenders {
if let Some(member_id) = T::MemberIdOf::convert(offender.offender.0.clone()) {
T::OnBlacklistedMember::on_blacklisted_member(member_id.clone());
Blacklist::<T>::mutate(|blacklist| { Blacklist::<T>::mutate(|blacklist| {
if let Some(member_id) = T::MemberIdOf::convert(offender.offender.0.clone())
{
if !blacklist.contains(&member_id) { if !blacklist.contains(&member_id) {
blacklist.push(member_id); blacklist.push(member_id);
Self::deposit_event(Event::MemberAddedToBlacklist { Self::deposit_event(Event::MemberAddedToBlacklist {
...@@ -66,8 +67,8 @@ where ...@@ -66,8 +67,8 @@ where
} }
Self::insert_out(member_id); Self::insert_out(member_id);
add_db_reads_writes(2, 1); add_db_reads_writes(2, 1);
});
} }
})
} }
} }
SlashStrategy::Disconnect => { SlashStrategy::Disconnect => {
......
...@@ -71,6 +71,7 @@ pub mod pallet { ...@@ -71,6 +71,7 @@ pub mod pallet {
type OnRemovedMember: OnRemovedMember<Self::MemberId>; type OnRemovedMember: OnRemovedMember<Self::MemberId>;
type OnOutgoingMember: OnOutgoingMember<Self::MemberId>; type OnOutgoingMember: OnOutgoingMember<Self::MemberId>;
type OnIncomingMember: OnIncomingMember<Self::MemberId>; type OnIncomingMember: OnIncomingMember<Self::MemberId>;
type OnBlacklistedMember: OnBlacklistedMember<Self::MemberId>;
/// Max number of authorities allowed /// Max number of authorities allowed
#[pallet::constant] #[pallet::constant]
type MaxAuthorities: Get<u32>; type MaxAuthorities: Get<u32>;
......
...@@ -15,9 +15,11 @@ impl<T: Config> pallet_authority_members::OnRemovedMember<T> for Pallet<T> { ...@@ -15,9 +15,11 @@ impl<T: Config> pallet_authority_members::OnRemovedMember<T> for Pallet<T> {
/// We want to remove a Smith when he is removed (blacklisted) from the higher level set of "authorities". /// We want to remove a Smith when he is removed (blacklisted) from the higher level set of "authorities".
/// A blacklisting means the user does not respect the operational conditions for an authority, so /// A blacklisting means the user does not respect the operational conditions for an authority, so
/// he does not deserve the Smith role. /// he does not deserve the Smith role.
impl<T: Config> pallet_authority_members::OnBlacklistedMember<T> for Pallet<T> { impl<T: Config> pallet_authority_members::OnBlacklistedMember<T::MemberId> for Pallet<T> {
fn on_blacklisted_member(member_id: T) { fn on_blacklisted_member(member_id: T::MemberId) {
todo!("Remove smith, he is dangereous") Pallet::<T>::smith_goes_blacklisted(
T::IdtyIdOfAuthorityId::convert(member_id).expect("convertion should be ok"),
);
} }
} }
......
...@@ -392,6 +392,15 @@ impl<T: Config> Pallet<T> { ...@@ -392,6 +392,15 @@ impl<T: Config> Pallet<T> {
} }
} }
} }
// TODO: return what?
fn smith_goes_blacklisted(idty_index: T::IdtyIndex) {
// TODO: for now, just let smith_goes_offline do the job
// if let Some(_) = Smiths::<T>::get(idty_index) {
// Smiths::<T>::remove(idty_index);
// T::OnSmithDelete::on_smith_delete(idty_index, SmithRemovalReason::Blacklisted);
// }
}
} }
impl<T: Config> Pallet<T> { impl<T: Config> Pallet<T> {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment