MCPcopy Create free account
hub / github.com/base/base / create_node_config

Function create_node_config

etc/systems/src/l2/in_process_builder.rs:265–335  ·  view source on GitHub ↗
(
    chain_spec: Arc<BaseChainSpec>,
    data_path: &std::path::Path,
    jwt_path: &std::path::Path,
    config: &InProcessBuilderConfig,
)

Source from the content-addressed store, hash-verified

263}
264
265fn create_node_config(
266 chain_spec: Arc<BaseChainSpec>,
267 data_path: &std::path::Path,
268 jwt_path: &std::path::Path,
269 config: &InProcessBuilderConfig,
270) -> Result<NodeConfig<BaseChainSpec>> {
271 let mut rpc =
272 if config.http_port.is_some() || config.ws_port.is_some() || config.auth_port.is_some() {
273 RpcServerArgs::default().with_http().with_ws()
274 } else {
275 RpcServerArgs::default().with_unused_ports().with_http().with_ws()
276 };
277
278 rpc.http_addr = Ipv4Addr::LOCALHOST.into();
279 rpc.ws_addr = Ipv4Addr::LOCALHOST.into();
280 rpc.auth_jwtsecret = Some(jwt_path.to_path_buf());
281
282 if let Some(port) = config.http_port {
283 rpc.http_port = port;
284 }
285 if let Some(port) = config.ws_port {
286 rpc.ws_port = port;
287 }
288 if let Some(port) = config.auth_port {
289 rpc.auth_port = port;
290 }
291
292 rpc.http_api = Some(
293 "admin,eth,web3,net,rpc,debug,txpool,miner"
294 .parse()
295 .wrap_err("Failed to parse HTTP API modules")?,
296 );
297 rpc.ws_api = Some(
298 "admin,eth,web3,net,rpc,debug,txpool,miner"
299 .parse()
300 .wrap_err("Failed to parse WS API modules")?,
301 );
302
303 let mut network = if config.p2p_port.is_some() {
304 NetworkArgs::default()
305 } else {
306 NetworkArgs::default().with_unused_ports()
307 };
308 network.p2p_secret_key_hex = Some(BUILDER.private_key);
309 network.discovery.disable_discovery = true;
310 if let Some(port) = config.p2p_port {
311 network.port = port;
312 }
313
314 let datadir = DatadirArgs {
315 datadir: MaybePlatformPath::<DataDirPath>::from(data_path.to_path_buf()),
316 static_files_path: None,
317 rocksdb_path: None,
318 pprof_dumps_path: None,
319 };
320
321 let mut node_config = NodeConfig::<BaseChainSpec>::new(chain_spec)
322 .with_datadir_args(datadir)

Callers 1

startMethod · 0.85

Calls 4

is_someMethod · 0.80
with_httpMethod · 0.80
parseMethod · 0.45
with_networkMethod · 0.45

Tested by

no test coverage detected