1
// Copyright (C) Moondance Labs Ltd.
2
// This file is part of Tanssi.
3

            
4
// Tanssi is free software: you can redistribute it and/or modify
5
// it under the terms of the GNU General Public License as published by
6
// the Free Software Foundation, either version 3 of the License, or
7
// (at your option) any later version.
8

            
9
// Tanssi is distributed in the hope that it will be useful,
10
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
// GNU General Public License for more details.
13

            
14
// You should have received a copy of the GNU General Public License
15
// along with Tanssi.  If not, see <http://www.gnu.org/licenses/>
16
#![cfg_attr(not(feature = "std"), no_std)]
17
use {
18
    sp_std::{collections::btree_set::BTreeSet, marker::PhantomData},
19
    tp_traits::{GetSessionContainerChains, ParaId, ParathreadHelper},
20
};
21

            
22
// Common implementation of the ParathreadHelper trait for all chains
23
// supporting pallet_session and pallet_registrar.
24
pub struct ExcludeAllParathreadsFilter<Runtime>(PhantomData<Runtime>);
25
impl<Runtime: pallet_session::Config + pallet_registrar::Config> ParathreadHelper
26
    for ExcludeAllParathreadsFilter<Runtime>
27
{
28
2953
    fn get_parathreads_for_session() -> BTreeSet<ParaId> {
29
2953
        pallet_registrar::Pallet::<Runtime>::session_container_chains(
30
2953
            pallet_session::Pallet::<Runtime>::current_index().into(),
31
2953
        )
32
2953
        .parathreads
33
2953
        .iter()
34
2953
        .map(|(id, _)| *id)
35
2953
        .collect()
36
2953
    }
37
}