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

Raised nits on #3813 #3844

Merged
merged 1 commit into from
Sep 16, 2021
Merged
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
8 changes: 6 additions & 2 deletions runtime/parachains/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ pub fn make_persisted_validation_data<T: paras::Config + hrmp::Config>(

/// Take an active subset of a set containing all validators.
///
/// First item in pair will be all items in set have indeces found in the `active` indices set (in
/// First item in pair will be all items in set have indices found in the `active` indices set (in
/// the order of the `active` vec, the second item will contain the rest, in the original order.
///
/// ```ignore
/// split_active_subset(active.into_iter().collect(), all).0 == take_active_subset(active, all)
/// split_active_subset(active, all).0 == take_active_subset(active, all)
/// ```
pub fn split_active_subset<T: Clone>(active: &[ValidatorIndex], all: &[T]) -> (Vec<T>, Vec<T>) {
let active_set: BTreeSet<_> = active.iter().cloned().collect();
Expand All @@ -73,6 +73,10 @@ pub fn split_active_subset<T: Clone>(active: &[ValidatorIndex], all: &[T]) -> (V
}

/// Uses `split_active_subset` and concatenates the inactive to the active vec.
///
/// ```ignore
/// split_active_subset(active, all)[0..active.len()]) == take_active_subset(active, all)
/// ```
pub fn take_active_subset_and_inactive<T: Clone>(active: &[ValidatorIndex], all: &[T]) -> Vec<T> {
let (mut a, mut i) = split_active_subset(active, all);
a.append(&mut i);
Expand Down