Skip to content
Snippets Groups Projects
Unverified Commit 37fec7e9 authored by bgallois's avatar bgallois
Browse files

unify handlers implementation in runtime

parent 4bb71f5b
No related branches found
No related tags found
1 merge request!246Fix weight accounting
...@@ -33,6 +33,37 @@ where ...@@ -33,6 +33,37 @@ where
} }
} }
/// Runtime handler for OnNewIdty, calling all implementations of
/// OnNewIdty and implementing logic at the runtime level.
pub struct OnNewIdtyHandler<Runtime>(core::marker::PhantomData<Runtime>);
impl<Runtime: pallet_duniter_wot::Config + pallet_quota::Config>
pallet_identity::traits::OnNewIdty<Runtime> for OnNewIdtyHandler<Runtime>
{
fn on_created(idty_index: &IdtyIndex, creator: &IdtyIndex) {
pallet_duniter_wot::Pallet::<Runtime>::on_created(idty_index, creator);
pallet_quota::Pallet::<Runtime>::on_created(idty_index, creator);
}
}
/// Runtime handler for OnRemoveIdty, calling all implementations of
/// OnRemoveIdty and implementing logic at the runtime level.
pub struct OnRemoveIdtyHandler<Runtime>(core::marker::PhantomData<Runtime>);
impl<Runtime: pallet_duniter_wot::Config + pallet_quota::Config>
pallet_identity::traits::OnRemoveIdty<Runtime> for OnRemoveIdtyHandler<Runtime>
{
fn on_removed(idty_index: &IdtyIndex) -> Weight {
let mut weight = pallet_duniter_wot::Pallet::<Runtime>::on_removed(idty_index);
weight += pallet_quota::Pallet::<Runtime>::on_removed(idty_index);
weight
}
fn on_revoked(idty_index: &IdtyIndex) -> Weight {
let mut weight = pallet_duniter_wot::Pallet::<Runtime>::on_revoked(idty_index);
weight += pallet_quota::Pallet::<Runtime>::on_revoked(idty_index);
weight
}
}
/// Runtime handler for OnNewMembership, calling all implementations of /// Runtime handler for OnNewMembership, calling all implementations of
/// OnNewMembership and implementing logic at the runtime level. /// OnNewMembership and implementing logic at the runtime level.
pub struct OnNewMembershipHandler<Runtime>(core::marker::PhantomData<Runtime>); pub struct OnNewMembershipHandler<Runtime>(core::marker::PhantomData<Runtime>);
......
...@@ -481,8 +481,8 @@ type RuntimeFreezeReason = (); ...@@ -481,8 +481,8 @@ type RuntimeFreezeReason = ();
type IdtyNameValidator = IdtyNameValidatorImpl; type IdtyNameValidator = IdtyNameValidatorImpl;
type Signer = <Signature as sp_runtime::traits::Verify>::Signer; type Signer = <Signature as sp_runtime::traits::Verify>::Signer;
type Signature = Signature; type Signature = Signature;
type OnNewIdty = (Wot, Quota); type OnNewIdty = OnNewIdtyHandler<Runtime>;
type OnRemoveIdty = (Wot, Quota); type OnRemoveIdty = OnRemoveIdtyHandler<Runtime>;
type RuntimeEvent = RuntimeEvent; type RuntimeEvent = RuntimeEvent;
type WeightInfo = common_runtime::weights::pallet_identity::WeightInfo<Runtime>; type WeightInfo = common_runtime::weights::pallet_identity::WeightInfo<Runtime>;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment