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