Skip to content
Snippets Groups Projects
Select Git revision
  • master default protected
  • network/gdev-800 protected
  • cgeek/issue-297-cpu
  • gdev-800-tests
  • update-docker-compose-rpc-squid-names
  • fix-252
  • 1000i100-test
  • hugo/tmp-0.9.1
  • network/gdev-803 protected
  • hugo/endpoint-gossip
  • network/gdev-802 protected
  • hugo/distance-precompute
  • network/gdev-900 protected
  • tuxmain/anonymous-tx
  • debug/podman
  • hugo/195-doc
  • hugo/195-graphql-schema
  • hugo-tmp-dockerfile-cache
  • release/client-800.2 protected
  • release/runtime-800 protected
  • gdev-900-0.10.1 protected
  • gdev-900-0.10.0 protected
  • gdev-900-0.9.2 protected
  • gdev-800-0.8.0 protected
  • gdev-900-0.9.1 protected
  • gdev-900-0.9.0 protected
  • gdev-803 protected
  • gdev-802 protected
  • runtime-801 protected
  • gdev-800 protected
  • runtime-800-bis protected
  • runtime-800 protected
  • runtime-800-backup protected
  • runtime-701 protected
  • runtime-700 protected
  • runtime-600 protected
  • runtime-500 protected
  • v0.4.1 protected
  • runtime-401 protected
  • v0.4.0 protected
40 results

impls.rs

Blame
  • impls.rs 2.51 KiB
    use crate::{Config, CurrentSession, Pallet};
    use frame_support::Parameter;
    use pallet_authority_members::SessionIndex;
    use pallet_identity::IdtyEvent;
    use sp_runtime::traits::Convert;
    
    /// We want to remove a Smith when he is removed from the higher level set of "authorities".
    impl<T: Config> pallet_authority_members::OnRemovedMember<T> for Pallet<T> {
        fn on_removed_member(_: T) {
            todo!("Remove smith as well")
            // TODO: not sure if we should listen authority-members or rather the initial pallet that called the removal
        }
    }
    
    // TODO: /// or //! ?
    /// 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
    /// he does not deserve the Smith role.
    impl<T: Config> pallet_authority_members::OnBlacklistedMember<T::MemberId> for Pallet<T> {
        fn on_blacklisted_member(member_id: T::MemberId) {
            Pallet::<T>::smith_goes_blacklisted(
                T::IdtyIdOfAuthorityId::convert(member_id).expect("convertion should be ok"),
            );
        }
    }
    
    ///
    impl<T: Config> pallet_authority_members::OnOutgoingMember<T::MemberId> for Pallet<T> {
        fn on_outgoing_member(member_id: T::MemberId) {
            Pallet::<T>::smith_goes_offline(
                T::IdtyIdOfAuthorityId::convert(member_id).expect("convertion should be ok"),
            );
        }
    }
    
    /// As long as a Smith is in the authority set, he will not expire.
    impl<T: Config> pallet_authority_members::OnIncomingMember<T::MemberId> for Pallet<T> {
        fn on_incoming_member(member_id: T::MemberId) {
            Pallet::<T>::smith_goes_online(
                T::IdtyIdOfAuthorityId::convert(member_id).expect("convertion should be ok"),
            );
        }
    }
    
    ///
    impl<T: Config> pallet_authority_members::OnNewSession for Pallet<T> {
        fn on_new_session(index: SessionIndex) {
            CurrentSession::<T>::put(index);
            Pallet::<T>::do_exclude_expired_smiths(index);
        }
    }
    
    // implement identity event handler
    impl<
            IdtyIndex: Copy + Parameter,
            T: Config<IdtyIndex = IdtyIndex> + pallet_identity::Config<IdtyIndex = IdtyIndex>,
        > pallet_identity::traits::OnIdtyChange<T> for Pallet<T>
    {
        fn on_idty_change(idty_id: IdtyIndex, idty_event: &IdtyEvent<T>) {
            match idty_event {
                // initialize quota on identity creation
                IdtyEvent::Created { .. } => {}
                IdtyEvent::Removed { .. } => {
                    Pallet::<T>::do_exclude_removed_wot_member(idty_id);
                }
            }
        }
    }