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