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

Commit

Permalink
Raised nits on #3813
Browse files Browse the repository at this point in the history
  • Loading branch information
eskimor committed Sep 14, 2021
1 parent 143a308 commit 1000550
Showing 1 changed file with 6 additions and 2 deletions.
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

0 comments on commit 1000550

Please sign in to comment.