Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Implement Contains for pallet-membership #6518

Merged
merged 2 commits into from
Jun 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bin/node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
// implementation changes and behavior does not, then leave spec_version as
// is and increment impl_version.
spec_version: 254,
impl_version: 0,
impl_version: 1,
apis: RUNTIME_API_VERSIONS,
transaction_version: 1,
};
Expand Down
12 changes: 11 additions & 1 deletion frame/membership/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
use sp_std::prelude::*;
use frame_support::{
decl_module, decl_storage, decl_event, decl_error,
traits::{ChangeMembers, InitializeMembers, EnsureOrigin},
traits::{ChangeMembers, InitializeMembers, EnsureOrigin, Contains},
};
use frame_system::{self as system, ensure_signed};

Expand Down Expand Up @@ -264,6 +264,16 @@ impl<T: Trait<I>, I: Instance> Module<T, I> {
}
}

impl<T: Trait<I>, I: Instance> Contains<T::AccountId> for Module<T, I> {
fn sorted_members() -> Vec<T::AccountId> {
Self::members()
}

fn count() -> usize {
Members::<T, I>::decode_len().unwrap_or(0)
}
}

#[cfg(test)]
mod tests {
use super::*;
Expand Down