ckb_app_config/configs/
rpc.rs1use ckb_jsonrpc_types::Script;
2use serde::{Deserialize, Serialize};
3
4#[derive(Clone, Debug, Copy, Eq, PartialEq, Serialize, Deserialize)]
6#[allow(missing_docs)]
7pub enum Module {
8 Net,
9 Chain,
10 Miner,
11 Pool,
12 Experiment,
13 Stats,
14 IntegrationTest,
15 Alert,
16 Subscription,
17 Debug,
18 Indexer,
19 RichIndexer,
20 Terminal,
21}
22
23#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, Eq)]
25#[serde(deny_unknown_fields)]
26pub struct Config {
27 pub listen_address: String,
29 #[serde(default)]
33 pub tcp_listen_address: Option<String>,
34 #[serde(default)]
38 pub ws_listen_address: Option<String>,
39 pub max_request_body_size: usize,
41 pub threads: Option<usize>,
43 pub rpc_batch_limit: Option<usize>,
45 pub modules: Vec<Module>,
47 #[serde(default)]
49 pub reject_ill_transactions: bool,
50 #[serde(default)]
54 pub enable_deprecated_rpc: bool,
55 #[serde(default)]
57 pub extra_well_known_lock_scripts: Vec<Script>,
58 #[serde(default)]
60 pub extra_well_known_type_scripts: Vec<Script>,
61}
62
63impl Config {
64 pub fn net_enable(&self) -> bool {
66 self.modules.contains(&Module::Net)
67 }
68
69 pub fn chain_enable(&self) -> bool {
71 self.modules.contains(&Module::Chain)
72 }
73
74 pub fn miner_enable(&self) -> bool {
76 self.modules.contains(&Module::Miner)
77 }
78
79 pub fn pool_enable(&self) -> bool {
81 self.modules.contains(&Module::Pool)
82 }
83
84 pub fn experiment_enable(&self) -> bool {
86 self.modules.contains(&Module::Experiment)
87 }
88
89 pub fn stats_enable(&self) -> bool {
91 self.modules.contains(&Module::Stats)
92 }
93
94 pub fn subscription_enable(&self) -> bool {
96 self.modules.contains(&Module::Subscription)
97 }
98
99 pub fn integration_test_enable(&self) -> bool {
101 self.modules.contains(&Module::IntegrationTest)
102 }
103
104 pub fn alert_enable(&self) -> bool {
106 self.modules.contains(&Module::Alert)
107 }
108
109 pub fn debug_enable(&self) -> bool {
111 self.modules.contains(&Module::Debug)
112 }
113
114 pub fn terminal_enable(&self) -> bool {
116 self.modules.contains(&Module::Terminal)
117 }
118
119 pub fn indexer_enable(&self) -> bool {
121 self.modules.contains(&Module::Indexer)
122 }
123
124 pub fn rich_indexer_enable(&self) -> bool {
126 self.modules.contains(&Module::RichIndexer)
127 }
128}