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

            
17
//! Runtime API for CollatorAssignment pallet. Can be used by collators to check
18
//! which parachain will they be collating, as well as the current assignment of
19
//! collators to parachains and parachains to collators.
20

            
21
#![cfg_attr(not(feature = "std"), no_std)]
22

            
23
use scale_info::prelude::vec::Vec;
24

            
25
2472
sp_api::decl_runtime_apis! {
26
2472
    #[api_version(2)]
27
2472
    pub trait CollatorAssignmentApi<AccountId, ParaId> where
28
2472
        AccountId: parity_scale_codec::Codec,
29
2472
        ParaId: parity_scale_codec::Codec,
30
2472
    {
31
2472
        /// Return the parachain that the given `AccountId` is collating for.
32
2472
        /// Returns `None` if the `AccountId` is not collating.
33
2472
        fn current_collator_parachain_assignment(account: AccountId) -> Option<ParaId>;
34
2472
        /// Return the parachain that the given `AccountId` will be collating for
35
2472
        /// in the next session change.
36
2472
        /// Returns `None` if the `AccountId` will not be collating.
37
2472
        fn future_collator_parachain_assignment(account: AccountId) -> Option<ParaId>;
38
2472
        /// Return the list of collators of the given `ParaId`.
39
2472
        /// Returns `None` if the `ParaId` is not in the registrar.
40
2472
        fn parachain_collators(para_id: ParaId) -> Option<Vec<AccountId>>;
41
2472

            
42
2472
        /// Returns the list of `ParaId` of registered chains with at least some
43
2472
        /// collators. This filters out parachains with no assigned collators.
44
2472
        #[api_version(2)]
45
2472
        fn parachains_with_some_collators() -> Vec<ParaId>;
46
2472
    }
47
2472
}