Skip to content
Snippets Groups Projects

Fix weight accounting

Merged Benjamin Gallois requested to merge 167-fix-remove-member-weight into master
Compare and Show latest version
6 files
+ 16
46
Compare changes
  • Side-by-side
  • Inline
Files
6
@@ -17,7 +17,6 @@
use crate::*;
use frame_support::pallet_prelude::*;
use frame_support::weights::Weight;
use impl_trait_for_tuples::impl_for_tuples;
/// A trait defining operations for checking if identity-related calls are allowed.
pub trait CheckIdtyCallAllowed<T: Config> {
@@ -25,10 +24,8 @@ pub trait CheckIdtyCallAllowed<T: Config> {
fn check_create_identity(creator: T::IdtyIndex) -> Result<(), DispatchError>;
}
#[impl_for_tuples(5)]
impl<T: Config> CheckIdtyCallAllowed<T> for Tuple {
fn check_create_identity(creator: T::IdtyIndex) -> Result<(), DispatchError> {
for_tuples!( #( Tuple::check_create_identity(creator)?; )* );
impl<T: Config> CheckIdtyCallAllowed<T> for () {
fn check_create_identity(_creator: T::IdtyIndex) -> Result<(), DispatchError> {
Ok(())
}
}
@@ -55,27 +52,17 @@ pub trait OnRemoveIdty<T: Config> {
fn on_revoked(idty_index: &T::IdtyIndex) -> Weight;
}
#[impl_for_tuples(5)]
#[allow(clippy::let_and_return)]
impl<T: Config> OnNewIdty<T> for Tuple {
fn on_created(idty_index: &T::IdtyIndex, creator: &T::IdtyIndex) {
for_tuples!( #( Tuple::on_created(idty_index, creator); )* );
}
impl<T: Config> OnNewIdty<T> for () {
fn on_created(_idty_index: &T::IdtyIndex, _creator: &T::IdtyIndex) {}
}
#[impl_for_tuples(5)]
#[allow(clippy::let_and_return)]
impl<T: Config> OnRemoveIdty<T> for Tuple {
fn on_removed(idty_index: &T::IdtyIndex) -> Weight {
let mut weight = Weight::zero();
for_tuples!( #( weight = weight.saturating_add(Tuple::on_removed(idty_index)); )* );
weight
impl<T: Config> OnRemoveIdty<T> for () {
fn on_removed(_idty_index: &T::IdtyIndex) -> Weight {
Weight::zero()
}
fn on_revoked(idty_index: &T::IdtyIndex) -> Weight {
let mut weight = Weight::zero();
for_tuples!( #( weight = weight.saturating_add(Tuple::on_revoked(idty_index)); )* );
weight
fn on_revoked(_idty_index: &T::IdtyIndex) -> Weight {
Weight::zero()
}
}
@@ -84,6 +71,7 @@ pub trait LinkIdty<AccountId, IdtyIndex> {
/// Links an identity to an account.
fn link_identity(account_id: &AccountId, idty_index: IdtyIndex) -> Result<(), DispatchError>;
}
impl<AccountId, IdtyIndex> LinkIdty<AccountId, IdtyIndex> for () {
fn link_identity(_: &AccountId, _: IdtyIndex) -> Result<(), DispatchError> {
Ok(())
Loading