config/
mod.rs

1// Copyright 2021-2022 Parity Technologies (UK) Ltd.
2// This file is part of Polkadot.
3
4// Polkadot 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// Polkadot 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 Polkadot.  If not, see <http://www.gnu.org/licenses/>.
16
17use strum::{Display as EnumDisplay, EnumString, EnumVariantNames};
18
19pub mod prelude;
20use prelude::*;
21
22#[path = "westend.rs"]
23pub mod westend;
24pub use westend::MinerConfig as Westend;
25
26#[path = "polkadot.rs"]
27pub mod polkadot;
28pub use polkadot::MinerConfig as Polkadot;
29
30#[path = "kusama.rs"]
31pub mod kusama;
32pub use kusama::MinerConfig as Kusama;
33
34#[path = "vara.rs"]
35pub mod vara;
36pub use vara::MinerConfig as Vara;
37
38#[path = "joystream.rs"]
39pub mod joystream;
40pub use joystream::MinerConfig as Joystream;
41
42#[path = "enjin.rs"]
43pub mod enjin;
44pub use enjin::MinerConfig as Enjin;
45
46#[derive(
47  Debug,
48  Default,
49  Clone,
50  Copy,
51  PartialEq,
52  Eq,
53  EnumString,
54  EnumDisplay,
55  EnumVariantNames,
56)]
57pub enum Chain {
58  #[default]
59  #[strum(serialize = "vara")]
60  Vara,
61  #[strum(serialize = "polkadot")]
62  Polkadot,
63  #[strum(serialize = "kusama")]
64  Kusama,
65  #[strum(serialize = "westend")]
66  Westend,
67  #[strum(serialize = "joystream")]
68  Joystream,
69  #[strum(serialize = "enjin")]
70  Enjin,
71}
72
73#[derive(
74  Debug,
75  Default,
76  Copy,
77  Clone,
78  PartialEq,
79  Eq,
80  EnumString,
81  EnumDisplay,
82  EnumVariantNames,
83)]
84pub enum Method {
85  #[default]
86  #[strum(serialize = "seq")]
87  SeqPhragmen,
88  #[strum(serialize = "mms")]
89  PhragMMS,
90}
91
92// A helper to use different MinerConfig depending on chain.
93#[macro_export]
94macro_rules! with_chain {
95  ($chain:expr, $($code:tt)*) => {
96    match $chain {
97      Chain::Vara => {
98        #[allow(unused)]
99        use Vara as Config;
100        $($code)*
101      },
102      Chain::Polkadot => {
103        #[allow(unused)]
104        use Polkadot as Config;
105        $($code)*
106      },
107      Chain::Kusama => {
108        #[allow(unused)]
109        use Kusama as Config;
110        $($code)*
111      },
112      Chain::Westend => {
113        #[allow(unused)]
114        use Westend as Config;
115        $($code)*
116      },
117      Chain::Joystream => {
118        #[allow(unused)]
119        use Joystream as Config;
120        $($code)*
121      },
122      Chain::Enjin => {
123        #[allow(unused)]
124        use Enjin as Config;
125        $($code)*
126      },
127    }
128  };
129}