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 Registrar pallet
18

            
19
#![cfg_attr(not(feature = "std"), no_std)]
20

            
21
pub use dp_container_chain_genesis_data::ContainerChainGenesisData;
22
use {scale_info::prelude::vec::Vec, tp_traits::SlotFrequency};
23

            
24
9664
sp_api::decl_runtime_apis! {
25
9664
    pub trait RegistrarApi<ParaId> where
26
9664
        ParaId: parity_scale_codec::Codec,
27
9664
    {
28
9664
        /// Return the registered para ids
29
9664
        fn registered_paras() -> Vec<ParaId>;
30
9664

            
31
9664
        /// Fetch genesis data for this para id
32
9664
        fn genesis_data(para_id: ParaId) -> Option<ContainerChainGenesisData>;
33
9664

            
34
9664
        /// Fetch boot_nodes for this para id
35
9664
        fn boot_nodes(para_id: ParaId) -> Vec<Vec<u8>>;
36
9664
    }
37
17062
}
38

            
39
618
sp_api::decl_runtime_apis! {
40
618
    pub trait OnDemandBlockProductionApi<ParaId, Slot> where
41
618
        ParaId: parity_scale_codec::Codec,
42
618
        Slot: parity_scale_codec::Codec,
43
618
    {
44
618
        /// Returns slot frequency for particular para thread. Slot frequency specifies amount of slot
45
618
        /// need to be passed between two parathread blocks. It is expressed as `(min, max)` pair where `min`
46
618
        /// indicates amount of slot must pass before we produce another block and `max` indicates amount of
47
618
        /// blocks before this parathread must produce the block.
48
618
        ///
49
618
        /// Simply put, parathread must produce a block after `min`  but before `(min+max)` slots.
50
618
        ///
51
618
        /// # Returns
52
618
        ///
53
618
        /// * `Some(slot_frequency)`.
54
618
        /// * `None` if the `para_id` is not a parathread.
55
618
        fn parathread_slot_frequency(para_id: ParaId) -> Option<SlotFrequency>;
56
618
    }
57
618
}