diff --git a/substrate/bin/node/runtime/src/lib.rs b/substrate/bin/node/runtime/src/lib.rs index 15ae0209a5e25bafb1b9b65b5b8a6ef9f96050cb..f96c30d914ff1ebf5906dea96052a5c960bdcfc8 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<Runtime>; + type MaxCandidateIntake = MaxCandidateIntake; type ChallengePeriod = ChallengePeriod; } diff --git a/substrate/frame/society/src/lib.rs b/substrate/frame/society/src/lib.rs index a5ba2124c8823a21caf3950fec84df9103e52c4f..8e5ce6c867817383a1405ac61ee41718e0dbd73a 100644 --- a/substrate/frame/society/src/lib.rs +++ b/substrate/frame/society/src/lib.rs @@ -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; /// The module's configuration trait. -pub trait Config<I=DefaultInstance>: system::Config { +pub trait Config<I = DefaultInstance>: system::Config { /// The overarching event type. type Event: From<Event<Self, I>> + Into<<Self as system::Config>::Event>; @@ -316,6 +316,9 @@ pub trait Config<I=DefaultInstance>: system::Config { /// The number of blocks between membership challenges. 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. @@ -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<T: Config<I>, I: Instance> Module<T, I> { /// May be empty. pub fn take_selected( members_len: usize, - pot: BalanceOf<T, I> + pot: BalanceOf<T, I>, ) -> Vec<Bid<T::AccountId, BalanceOf<T, I>>> { let max_members = MaxMembers::<I>::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 53d999e37e6287ae830c04025a74650f68cf3541..ff80b50b6d3583239dc1c98f5ab4882db7897b03 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<FounderSetAccount, u128>; type SuspensionJudgementOrigin = EnsureSignedBy<SuspensionJudgementSetAccount, u128>; type ChallengePeriod = ChallengePeriod; + type MaxCandidateIntake = MaxCandidateIntake; type ModuleId = SocietyModuleId; }