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

refac(smith-members): SmithInactivityMaxDuration

parent e7892bc4
No related branches found
No related tags found
No related merge requests found
......@@ -99,7 +99,7 @@ fn get_parameters(_: &Option<GenesisParameters>) -> CommonParameters {
distance_min_accessible_referees: Perbill::from_percent(80), // TODO: generalize
distance_max_depth: 5, // TODO: generalize
smith_sub_wot_min_cert_for_membership: parameters::SmithWotMinCertForMembership::get(),
smith_inactivity_max_duration: parameters::InactivityMaxDuration::get(),
smith_inactivity_max_duration: parameters::SmithInactivityMaxDuration::get(),
smith_cert_max_by_issuer: parameters::SmithMaxByIssuer::get(),
cert_cert_period: parameters::CertPeriod::get(),
treasury_spend_period: <Runtime as pallet_treasury::Config>::SpendPeriod::get(),
......
......@@ -112,7 +112,7 @@ pub mod pallet {
type MinCertForMembership: Get<u32>;
/// Maximum duration of inactivity before a smith is removed
#[pallet::constant]
type InactivityMaxDuration: Get<u32>;
type SmithInactivityMaxDuration: Get<u32>;
}
/// Events type.
......@@ -188,14 +188,14 @@ pub mod pallet {
expires_on: if *is_online {
None
} else {
Some(CurrentSession::<T>::get() + T::InactivityMaxDuration::get())
Some(CurrentSession::<T>::get() + T::SmithInactivityMaxDuration::get())
},
issued_certs: vec![],
received_certs: issuers_,
},
);
ExpiresOn::<T>::append(
CurrentSession::<T>::get() + T::InactivityMaxDuration::get(),
CurrentSession::<T>::get() + T::SmithInactivityMaxDuration::get(),
receiver,
);
}
......@@ -335,7 +335,7 @@ impl<T: Config> Pallet<T> {
}
fn do_invite_smith(issuer: T::IdtyIndex, receiver: T::IdtyIndex) {
let new_expires_on = CurrentSession::<T>::get() + T::InactivityMaxDuration::get();
let new_expires_on = CurrentSession::<T>::get() + T::SmithInactivityMaxDuration::get();
// TODO: another way to write this?
if Smiths::<T>::get(receiver).is_some() {
Smiths::<T>::mutate(receiver, |maybe_smith_meta| {
......@@ -439,7 +439,7 @@ impl<T: Config> Pallet<T> {
SmithStatus::Pending
};
// expiry postponed
let new_expires_on = CurrentSession::<T>::get() + T::InactivityMaxDuration::get();
let new_expires_on = CurrentSession::<T>::get() + T::SmithInactivityMaxDuration::get();
maybe_smith_meta.expires_on = Some(new_expires_on);
Self::deposit_event(Event::<T>::CertificationReceived {
idty_index: receiver,
......@@ -523,7 +523,7 @@ impl<T: Config> Pallet<T> {
let maybe_smith_meta = maybe_smith_meta.as_mut().expect("checked earlier");
// As long as the smith is online, it cannot expire
let new_expires_on =
CurrentSession::<T>::get() + T::InactivityMaxDuration::get();
CurrentSession::<T>::get() + T::SmithInactivityMaxDuration::get();
maybe_smith_meta.expires_on = Some(new_expires_on);
ExpiresOn::<T>::append(new_expires_on, idty_index);
});
......
......@@ -91,7 +91,7 @@ impl pallet_smith_members::Config for Runtime {
type IdtyIdOf = ConvertInto;
type MinCertForMembership = ConstU32<2>;
type MaxByIssuer = ConstU32<3>;
type InactivityMaxDuration = ConstU32<5>;
type SmithInactivityMaxDuration = ConstU32<5>;
type OnSmithDelete = ();
type IdtyIdOfAuthorityId = ConvertInto;
type MemberId = u64;
......
......@@ -531,7 +531,7 @@ macro_rules! pallets_config {
type IdtyIdOf = common_runtime::providers::IdentityIndexOf<Self>;
type MinCertForMembership = SmithWotMinCertForMembership;
type MaxByIssuer = SmithMaxByIssuer;
type InactivityMaxDuration = InactivityMaxDuration;
type SmithInactivityMaxDuration = SmithInactivityMaxDuration;
type OnSmithDelete = OnSmithDeletedHandler<Runtime>;
type IdtyIdOfAuthorityId = sp_runtime::traits::ConvertInto;
type MemberId = IdtyIndex;
......
......@@ -123,7 +123,7 @@ parameter_types! {
parameter_types! {
pub const SmithWotMinCertForMembership: u32 = 3;
pub const SmithMaxByIssuer: u32 = 12;
pub const InactivityMaxDuration: u32 = 48;
pub const SmithInactivityMaxDuration: u32 = 48;
}
/*************/
......
......@@ -267,8 +267,7 @@ common_runtime::pallets_config! {
pub type SmithMaxByIssuer = pallet_duniter_test_parameters::SmithCertMaxByIssuer<Runtime>;
pub type SmithWotMinCertForMembership =
pallet_duniter_test_parameters::SmithWotMinCertForMembership<Runtime>;
// TODO: prefix with "Smith"
pub type InactivityMaxDuration =
pub type SmithInactivityMaxDuration =
pallet_duniter_test_parameters::SmithInactivityMaxDuration<Runtime>;
impl pallet_duniter_test_parameters::Config for Runtime {
......
......@@ -124,7 +124,7 @@ parameter_types! {
parameter_types! {
pub const SmithWotMinCertForMembership: u32 = 3;
pub const SmithMaxByIssuer: u32 = 100;
pub const InactivityMaxDuration: u32 = 48;
pub const SmithInactivityMaxDuration: u32 = 48;
}
/*************/
......
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