Skip to content
Snippets Groups Projects
Commit e309d94f authored by Kian Paimani's avatar Kian Paimani Committed by GitHub
Browse files

Make candidate intake in society configurable (#8445)

* Make candidate intake in society configurable

* Update frame/society/src/lib.rs

* fix fix
parent ab55f9dc
No related merge requests found
...@@ -953,6 +953,7 @@ parameter_types! { ...@@ -953,6 +953,7 @@ parameter_types! {
pub const PeriodSpend: Balance = 500 * DOLLARS; pub const PeriodSpend: Balance = 500 * DOLLARS;
pub const MaxLockDuration: BlockNumber = 36 * 30 * DAYS; pub const MaxLockDuration: BlockNumber = 36 * 30 * DAYS;
pub const ChallengePeriod: BlockNumber = 7 * DAYS; pub const ChallengePeriod: BlockNumber = 7 * DAYS;
pub const MaxCandidateIntake: u32 = 10;
pub const SocietyModuleId: ModuleId = ModuleId(*b"py/socie"); pub const SocietyModuleId: ModuleId = ModuleId(*b"py/socie");
} }
...@@ -970,6 +971,7 @@ impl pallet_society::Config for Runtime { ...@@ -970,6 +971,7 @@ impl pallet_society::Config for Runtime {
type MaxLockDuration = MaxLockDuration; type MaxLockDuration = MaxLockDuration;
type FounderSetOrigin = pallet_collective::EnsureProportionMoreThan<_1, _2, AccountId, CouncilCollective>; type FounderSetOrigin = pallet_collective::EnsureProportionMoreThan<_1, _2, AccountId, CouncilCollective>;
type SuspensionJudgementOrigin = pallet_society::EnsureFounder<Runtime>; type SuspensionJudgementOrigin = pallet_society::EnsureFounder<Runtime>;
type MaxCandidateIntake = MaxCandidateIntake;
type ChallengePeriod = ChallengePeriod; type ChallengePeriod = ChallengePeriod;
} }
......
...@@ -272,7 +272,7 @@ type BalanceOf<T, I> = <<T as Config<I>>::Currency as Currency<<T as system::Con ...@@ -272,7 +272,7 @@ type BalanceOf<T, I> = <<T as Config<I>>::Currency as Currency<<T as system::Con
type NegativeImbalanceOf<T> = <<T as Config>::Currency as Currency<<T as frame_system::Config>::AccountId>>::NegativeImbalance; type NegativeImbalanceOf<T> = <<T as Config>::Currency as Currency<<T as frame_system::Config>::AccountId>>::NegativeImbalance;
/// The module's configuration trait. /// The module's configuration trait.
pub trait Config<I=DefaultInstance>: system::Config { pub trait Config<I = DefaultInstance>: system::Config {
/// The overarching event type. /// The overarching event type.
type Event: From<Event<Self, I>> + Into<<Self as system::Config>::Event>; type Event: From<Event<Self, I>> + Into<<Self as system::Config>::Event>;
...@@ -316,6 +316,9 @@ pub trait Config<I=DefaultInstance>: system::Config { ...@@ -316,6 +316,9 @@ pub trait Config<I=DefaultInstance>: system::Config {
/// The number of blocks between membership challenges. /// The number of blocks between membership challenges.
type ChallengePeriod: Get<Self::BlockNumber>; type ChallengePeriod: Get<Self::BlockNumber>;
/// The maximum number of candidates that we accept per round.
type MaxCandidateIntake: Get<u32>;
} }
/// A vote by a member on a candidate application. /// A vote by a member on a candidate application.
...@@ -497,6 +500,9 @@ decl_module! { ...@@ -497,6 +500,9 @@ decl_module! {
/// The societies's module id /// The societies's module id
const ModuleId: ModuleId = T::ModuleId::get(); const ModuleId: ModuleId = T::ModuleId::get();
/// Maximum candidate intake per round.
const MaxCandidateIntake: u32 = T::MaxCandidateIntake::get();
// Used for handling module events. // Used for handling module events.
fn deposit_event() = default; fn deposit_event() = default;
...@@ -1615,11 +1621,11 @@ impl<T: Config<I>, I: Instance> Module<T, I> { ...@@ -1615,11 +1621,11 @@ impl<T: Config<I>, I: Instance> Module<T, I> {
/// May be empty. /// May be empty.
pub fn take_selected( pub fn take_selected(
members_len: usize, members_len: usize,
pot: BalanceOf<T, I> pot: BalanceOf<T, I>,
) -> Vec<Bid<T::AccountId, BalanceOf<T, I>>> { ) -> Vec<Bid<T::AccountId, BalanceOf<T, I>>> {
let max_members = MaxMembers::<I>::get() as usize; let max_members = MaxMembers::<I>::get() as usize;
// No more than 10 will be returned. let mut max_selections: usize =
let mut max_selections: usize = 10.min(max_members.saturating_sub(members_len)); (T::MaxCandidateIntake::get() as usize).min(max_members.saturating_sub(members_len));
if max_selections > 0 { if max_selections > 0 {
// Get the number of left-most bidders whose bids add up to less than `pot`. // Get the number of left-most bidders whose bids add up to less than `pot`.
......
...@@ -57,6 +57,7 @@ parameter_types! { ...@@ -57,6 +57,7 @@ parameter_types! {
pub const ChallengePeriod: u64 = 8; pub const ChallengePeriod: u64 = 8;
pub const BlockHashCount: u64 = 250; pub const BlockHashCount: u64 = 250;
pub const ExistentialDeposit: u64 = 1; pub const ExistentialDeposit: u64 = 1;
pub const MaxCandidateIntake: u32 = 10;
pub const SocietyModuleId: ModuleId = ModuleId(*b"py/socie"); pub const SocietyModuleId: ModuleId = ModuleId(*b"py/socie");
pub BlockWeights: frame_system::limits::BlockWeights = pub BlockWeights: frame_system::limits::BlockWeights =
frame_system::limits::BlockWeights::simple_max(1024); frame_system::limits::BlockWeights::simple_max(1024);
...@@ -116,6 +117,7 @@ impl Config for Test { ...@@ -116,6 +117,7 @@ impl Config for Test {
type FounderSetOrigin = EnsureSignedBy<FounderSetAccount, u128>; type FounderSetOrigin = EnsureSignedBy<FounderSetAccount, u128>;
type SuspensionJudgementOrigin = EnsureSignedBy<SuspensionJudgementSetAccount, u128>; type SuspensionJudgementOrigin = EnsureSignedBy<SuspensionJudgementSetAccount, u128>;
type ChallengePeriod = ChallengePeriod; type ChallengePeriod = ChallengePeriod;
type MaxCandidateIntake = MaxCandidateIntake;
type ModuleId = SocietyModuleId; type ModuleId = SocietyModuleId;
} }
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment