diff --git a/substrate/bin/node/runtime/src/lib.rs b/substrate/bin/node/runtime/src/lib.rs index 15ae0209a5..f96c30d914 100644 --- a/substrate/bin/node/runtime/src/lib.rs +++ b/substrate/bin/node/runtime/src/lib.rs @@ -953,6 +953,7 @@ parameter_types! { pub const PeriodSpend: Balance = 500 * DOLLARS; pub const MaxLockDuration: BlockNumber = 36 * 30 * DAYS; pub const ChallengePeriod: BlockNumber = 7 * DAYS; + pub const MaxCandidateIntake: u32 = 10; pub const SocietyModuleId: ModuleId = ModuleId(*b"py/socie"); } @@ -970,6 +971,7 @@ impl pallet_society::Config for Runtime { type MaxLockDuration = MaxLockDuration; type FounderSetOrigin = pallet_collective::EnsureProportionMoreThan<_1, _2, AccountId, CouncilCollective>; type SuspensionJudgementOrigin = pallet_society::EnsureFounder; + type MaxCandidateIntake = MaxCandidateIntake; type ChallengePeriod = ChallengePeriod; } diff --git a/substrate/frame/society/src/lib.rs b/substrate/frame/society/src/lib.rs index a5ba2124c8..8e5ce6c867 100644 --- a/substrate/frame/society/src/lib.rs +++ b/substrate/frame/society/src/lib.rs @@ -272,7 +272,7 @@ type BalanceOf = <>::Currency as Currency< = <::Currency as Currency<::AccountId>>::NegativeImbalance; /// The module's configuration trait. -pub trait Config: system::Config { +pub trait Config: system::Config { /// The overarching event type. type Event: From> + Into<::Event>; @@ -316,6 +316,9 @@ pub trait Config: system::Config { /// The number of blocks between membership challenges. type ChallengePeriod: Get; + + /// The maximum number of candidates that we accept per round. + type MaxCandidateIntake: Get; } /// A vote by a member on a candidate application. @@ -497,6 +500,9 @@ decl_module! { /// The societies's module id const ModuleId: ModuleId = T::ModuleId::get(); + /// Maximum candidate intake per round. + const MaxCandidateIntake: u32 = T::MaxCandidateIntake::get(); + // Used for handling module events. fn deposit_event() = default; @@ -1615,11 +1621,11 @@ impl, I: Instance> Module { /// May be empty. pub fn take_selected( members_len: usize, - pot: BalanceOf + pot: BalanceOf, ) -> Vec>> { let max_members = MaxMembers::::get() as usize; - // No more than 10 will be returned. - let mut max_selections: usize = 10.min(max_members.saturating_sub(members_len)); + let mut max_selections: usize = + (T::MaxCandidateIntake::get() as usize).min(max_members.saturating_sub(members_len)); if max_selections > 0 { // Get the number of left-most bidders whose bids add up to less than `pot`. diff --git a/substrate/frame/society/src/mock.rs b/substrate/frame/society/src/mock.rs index 53d999e37e..ff80b50b6d 100644 --- a/substrate/frame/society/src/mock.rs +++ b/substrate/frame/society/src/mock.rs @@ -57,6 +57,7 @@ parameter_types! { pub const ChallengePeriod: u64 = 8; pub const BlockHashCount: u64 = 250; pub const ExistentialDeposit: u64 = 1; + pub const MaxCandidateIntake: u32 = 10; pub const SocietyModuleId: ModuleId = ModuleId(*b"py/socie"); pub BlockWeights: frame_system::limits::BlockWeights = frame_system::limits::BlockWeights::simple_max(1024); @@ -116,6 +117,7 @@ impl Config for Test { type FounderSetOrigin = EnsureSignedBy; type SuspensionJudgementOrigin = EnsureSignedBy; type ChallengePeriod = ChallengePeriod; + type MaxCandidateIntake = MaxCandidateIntake; type ModuleId = SocietyModuleId; }