mirror of
https://github.com/logos-co/nomos-node.git
synced 2026-08-27 17:41:11 +00:00
fix(ffi): Config parameters (#2949)
Co-authored-by: Daniel Sanchez <sanchez.quiros.daniel@gmail.com>
This commit is contained in:
@@ -4,7 +4,7 @@ pub mod keys;
|
||||
pub mod participate;
|
||||
|
||||
use std::{
|
||||
net::{IpAddr, Ipv4Addr, SocketAddr},
|
||||
net::{Ipv4Addr, SocketAddr},
|
||||
path::{Path, PathBuf},
|
||||
};
|
||||
|
||||
@@ -20,8 +20,10 @@ use crate::{
|
||||
},
|
||||
config::{
|
||||
ApiArgs, BlendArgs, CryptarchiaArgs, DeploymentArgs, DeploymentSettings, DeploymentType,
|
||||
LogArgs, NetworkArgs, RunConfig, SdpArgs, StateArgs, UserConfig, update_api, update_blend,
|
||||
update_cryptarchia, update_network, update_sdp, update_state, update_tracing,
|
||||
LogArgs, NetworkArgs, RunConfig, SdpArgs, StateArgs, UserConfig,
|
||||
api::serde::AxumBackendSettings, blend::serde::core::BackendConfig as BlendCoreConfig,
|
||||
network::serde::SwarmConfig, update_api, update_blend, update_cryptarchia, update_network,
|
||||
update_sdp, update_state, update_tracing,
|
||||
},
|
||||
};
|
||||
|
||||
@@ -223,11 +225,8 @@ impl From<EmbeddedInitArgs> for InitArgs {
|
||||
.clone_from(&args.external_address);
|
||||
init_args.network.initial_peers = Some(args.initial_peers.clone());
|
||||
|
||||
init_args.blend.blend_addr = Some(
|
||||
format!("/ip4/0.0.0.0/tcp/{}", args.blend_port)
|
||||
.parse()
|
||||
.expect("Valid multiaddr structure"),
|
||||
);
|
||||
init_args.blend.blend_addr =
|
||||
Some(BlendCoreConfig::default_listening_address(args.blend_port));
|
||||
|
||||
init_args.cryptarchia.ibd = args.ibd;
|
||||
init_args.api.addr = Some(args.http_addr);
|
||||
@@ -242,9 +241,11 @@ impl Default for EmbeddedInitArgs {
|
||||
Self {
|
||||
initial_peers: Vec::new(),
|
||||
output: PathBuf::from("user_config.yaml"),
|
||||
net_port: 3000,
|
||||
blend_port: 3400,
|
||||
http_addr: SocketAddr::new(IpAddr::V4(Ipv4Addr::LOCALHOST), 3000),
|
||||
net_port: SwarmConfig::default_port(),
|
||||
blend_port: BlendCoreConfig::default_port(),
|
||||
http_addr: AxumBackendSettings::default_listening_address(
|
||||
AxumBackendSettings::default_port(),
|
||||
),
|
||||
external_address: None,
|
||||
state_path: None,
|
||||
ibd: false,
|
||||
|
||||
@@ -18,7 +18,7 @@ pub struct Config {
|
||||
pub struct AxumBackendSettings {
|
||||
/// Listening address.
|
||||
pub listen_address: core::net::SocketAddr,
|
||||
/// Allowed origins for this server deployment requests.
|
||||
/// Allowed origins for these server deployment requests.
|
||||
pub cors_origins: Vec<String>,
|
||||
/// Timeout for API requests in seconds.
|
||||
#[serde_as(as = "serde_with::DurationSeconds<u64>")]
|
||||
@@ -29,10 +29,22 @@ pub struct AxumBackendSettings {
|
||||
pub max_concurrent_requests: u64,
|
||||
}
|
||||
|
||||
impl AxumBackendSettings {
|
||||
#[must_use]
|
||||
pub const fn default_port() -> u16 {
|
||||
8080
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn default_listening_address(port: u16) -> core::net::SocketAddr {
|
||||
SocketAddrV4::new(Ipv4Addr::LOCALHOST, port).into()
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for AxumBackendSettings {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
listen_address: SocketAddrV4::new(Ipv4Addr::LOCALHOST, 8080).into(),
|
||||
listen_address: Self::default_listening_address(Self::default_port()),
|
||||
cors_origins: Vec::default(),
|
||||
timeout: Duration::from_secs(30),
|
||||
max_body_size: 10 * 1024 * 1024,
|
||||
|
||||
@@ -26,10 +26,27 @@ pub struct BackendConfig {
|
||||
pub max_dial_attempts_per_peer: NonZeroU64,
|
||||
}
|
||||
|
||||
impl BackendConfig {
|
||||
#[must_use]
|
||||
pub const fn default_port() -> u16 {
|
||||
3400
|
||||
}
|
||||
|
||||
/// # Panics
|
||||
///
|
||||
/// This function will panic if the constructed multiaddr string is invalid.
|
||||
#[must_use]
|
||||
pub fn default_listening_address(port: u16) -> Multiaddr {
|
||||
format!("/ip4/0.0.0.0/udp/{port}/quic-v1")
|
||||
.parse()
|
||||
.expect("Valid multiaddr structure")
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for BackendConfig {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
listening_address: "/ip4/0.0.0.0/udp/3400/quic-v1".parse().unwrap(),
|
||||
listening_address: Self::default_listening_address(Self::default_port()),
|
||||
core_peering_degree: 3..=5,
|
||||
edge_node_connection_timeout: Duration::from_secs(1),
|
||||
max_edge_node_incoming_connections: 300,
|
||||
|
||||
@@ -52,11 +52,18 @@ pub struct SwarmConfig {
|
||||
pub nat: nat::Config,
|
||||
}
|
||||
|
||||
impl SwarmConfig {
|
||||
#[must_use]
|
||||
pub const fn default_port() -> u16 {
|
||||
3000
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for SwarmConfig {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
host: Ipv4Addr::UNSPECIFIED,
|
||||
port: 3000,
|
||||
port: Self::default_port(),
|
||||
node_key: SecretKey::generate(),
|
||||
gossipsub: gossipsub::Config::default(),
|
||||
kademlia: kademlia::Config::default(),
|
||||
|
||||
Reference in New Issue
Block a user