From dd3a24534e37dc334cef54d62e47af8bac17ebf2 Mon Sep 17 00:00:00 2001 From: Shahak Shama Date: Wed, 14 Feb 2024 12:39:51 +0200 Subject: [PATCH] build(node): separate dump config exe to module --- crates/papyrus_node/src/bin/dump_config.rs | 41 +++---------------- .../src/bin/dump_config/with_rpc.rs | 35 ++++++++++++++++ 2 files changed, 40 insertions(+), 36 deletions(-) create mode 100644 crates/papyrus_node/src/bin/dump_config/with_rpc.rs diff --git a/crates/papyrus_node/src/bin/dump_config.rs b/crates/papyrus_node/src/bin/dump_config.rs index 9047229fb6..69faf60e3f 100644 --- a/crates/papyrus_node/src/bin/dump_config.rs +++ b/crates/papyrus_node/src/bin/dump_config.rs @@ -3,47 +3,16 @@ #![cfg_attr(coverage_nightly, feature(coverage_attribute))] #[cfg(feature = "rpc")] -use lazy_static::lazy_static; -#[cfg(feature = "rpc")] -use papyrus_config::dumping::{ser_pointer_target_param, SerializeConfig}; +#[path = "dump_config/with_rpc.rs"] +mod with_rpc; + #[cfg(feature = "rpc")] -use papyrus_config::{ParamPath, SerializedParam}; +use papyrus_config::dumping::SerializeConfig; #[cfg(feature = "rpc")] use papyrus_node::config::{NodeConfig, DEFAULT_CONFIG_PATH}; -#[cfg(feature = "rpc")] -use starknet_api::core::ChainId; #[cfg(feature = "rpc")] -lazy_static! { - /// Returns vector of (pointer target name, pointer target serialized param, vec) - /// to be applied on the dumped node config. - /// The config updates will be performed on the shared pointer targets, and finally, the values - /// will be propagated to the pointer params. - static ref CONFIG_POINTERS: Vec<((ParamPath, SerializedParam), Vec)> = vec![( - ser_pointer_target_param( - "chain_id", - &ChainId("SN_MAIN".to_string()), - "The chain to follow. For more details see https://docs.starknet.io/documentation/architecture_and_concepts/Blocks/transactions/#chain-id.", - ), - vec!["storage.db_config.chain_id".to_owned(), "rpc.chain_id".to_owned()], - ), - ( - ser_pointer_target_param( - "starknet_url", - &"https://alpha-mainnet.starknet.io/".to_string(), - "The URL of a centralized Starknet gateway.", - ), - vec!["rpc.starknet_url".to_owned(), "central.url".to_owned(), "monitoring_gateway.starknet_url".to_owned()], - ), - ( - ser_pointer_target_param( - "collect_metrics", - &false, - "If true, collect metrics for the node.", - ), - vec!["rpc.collect_metrics".to_owned(), "monitoring_gateway.collect_metrics".to_owned()], - )]; -} +use self::with_rpc::CONFIG_POINTERS; /// Updates the default config file by: /// cargo run --bin dump_config -q diff --git a/crates/papyrus_node/src/bin/dump_config/with_rpc.rs b/crates/papyrus_node/src/bin/dump_config/with_rpc.rs new file mode 100644 index 0000000000..7cb0c65526 --- /dev/null +++ b/crates/papyrus_node/src/bin/dump_config/with_rpc.rs @@ -0,0 +1,35 @@ +use lazy_static::lazy_static; +use papyrus_config::dumping::ser_pointer_target_param; +use papyrus_config::{ParamPath, SerializedParam}; +use starknet_api::core::ChainId; + +lazy_static! { + /// Returns vector of (pointer target name, pointer target serialized param, vec) + /// to be applied on the dumped node config. + /// The config updates will be performed on the shared pointer targets, and finally, the values + /// will be propagated to the pointer params. + pub static ref CONFIG_POINTERS: Vec<((ParamPath, SerializedParam), Vec)> = vec![( + ser_pointer_target_param( + "chain_id", + &ChainId("SN_MAIN".to_string()), + "The chain to follow. For more details see https://docs.starknet.io/documentation/architecture_and_concepts/Blocks/transactions/#chain-id.", + ), + vec!["storage.db_config.chain_id".to_owned(), "rpc.chain_id".to_owned()], + ), + ( + ser_pointer_target_param( + "starknet_url", + &"https://alpha-mainnet.starknet.io/".to_string(), + "The URL of a centralized Starknet gateway.", + ), + vec!["rpc.starknet_url".to_owned(), "central.url".to_owned(), "monitoring_gateway.starknet_url".to_owned()], + ), + ( + ser_pointer_target_param( + "collect_metrics", + &false, + "If true, collect metrics for the node.", + ), + vec!["rpc.collect_metrics".to_owned(), "monitoring_gateway.collect_metrics".to_owned()], + )]; +}