miden_node_utils/
config.rs

1use std::path::Path;
2
3use figment::Figment;
4use figment::providers::{Format, Toml};
5use serde::Deserialize;
6
7pub const DEFAULT_NODE_RPC_PORT: u16 = 57291;
8pub const DEFAULT_BLOCK_PRODUCER_PORT: u16 = 48046;
9pub const DEFAULT_STORE_PORT: u16 = 28943;
10pub const DEFAULT_FAUCET_SERVER_PORT: u16 = 8080;
11
12/// Loads the user configuration.
13///
14/// This function will look for the configuration file at the provided path. If the path is
15/// relative, searches in parent directories all the way to the root as well.
16///
17/// The above configuration options are indented to support easy of packaging and deployment.
18#[allow(clippy::result_large_err, reason = "This error crashes the node")]
19pub fn load_config<T: for<'a> Deserialize<'a>>(
20    config_file: impl AsRef<Path>,
21) -> figment::Result<T> {
22    Figment::from(Toml::file(config_file.as_ref())).extract()
23}