mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 05:51:02 +00:00
fix cli: make port Option<u16> again (#14088)
This commit is contained in:
@@ -24,6 +24,8 @@ use crate::{
|
||||
TransactionPoolParams,
|
||||
},
|
||||
CliConfiguration, PrometheusParams, RuntimeParams, TelemetryParams,
|
||||
RPC_DEFAULT_MAX_CONNECTIONS, RPC_DEFAULT_MAX_REQUEST_SIZE_MB, RPC_DEFAULT_MAX_RESPONSE_SIZE_MB,
|
||||
RPC_DEFAULT_MAX_SUBS_PER_CONN,
|
||||
};
|
||||
use clap::Parser;
|
||||
use regex::Regex;
|
||||
@@ -78,23 +80,23 @@ pub struct RunCmd {
|
||||
pub rpc_methods: RpcMethods,
|
||||
|
||||
/// Set the the maximum RPC request payload size for both HTTP and WS in megabytes.
|
||||
#[arg(long, default_value_t = 15)]
|
||||
#[arg(long, default_value_t = RPC_DEFAULT_MAX_REQUEST_SIZE_MB)]
|
||||
pub rpc_max_request_size: u32,
|
||||
|
||||
/// Set the the maximum RPC response payload size for both HTTP and WS in megabytes.
|
||||
#[arg(long, default_value_t = 15)]
|
||||
#[arg(long, default_value_t = RPC_DEFAULT_MAX_RESPONSE_SIZE_MB)]
|
||||
pub rpc_max_response_size: u32,
|
||||
|
||||
/// Set the the maximum concurrent subscriptions per connection.
|
||||
#[arg(long, default_value_t = 1024)]
|
||||
#[arg(long, default_value_t = RPC_DEFAULT_MAX_SUBS_PER_CONN)]
|
||||
pub rpc_max_subscriptions_per_connection: u32,
|
||||
|
||||
/// Specify JSON-RPC server TCP port.
|
||||
#[arg(long, value_name = "PORT", default_value_t = 9944)]
|
||||
pub rpc_port: u16,
|
||||
#[arg(long, value_name = "PORT")]
|
||||
pub rpc_port: Option<u16>,
|
||||
|
||||
/// Maximum number of RPC server connections.
|
||||
#[arg(long, value_name = "COUNT", default_value_t = 100)]
|
||||
#[arg(long, value_name = "COUNT", default_value_t = RPC_DEFAULT_MAX_CONNECTIONS)]
|
||||
pub rpc_max_connections: u32,
|
||||
|
||||
/// Specify browser Origins allowed to access the HTTP & WS RPC servers.
|
||||
@@ -336,7 +338,7 @@ impl CliConfiguration for RunCmd {
|
||||
.into())
|
||||
}
|
||||
|
||||
fn rpc_addr(&self, _default_listen_port: u16) -> Result<Option<SocketAddr>> {
|
||||
fn rpc_addr(&self, default_listen_port: u16) -> Result<Option<SocketAddr>> {
|
||||
let interface = rpc_interface(
|
||||
self.rpc_external,
|
||||
self.unsafe_rpc_external,
|
||||
@@ -344,7 +346,7 @@ impl CliConfiguration for RunCmd {
|
||||
self.validator,
|
||||
)?;
|
||||
|
||||
Ok(Some(SocketAddr::new(interface, self.rpc_port)))
|
||||
Ok(Some(SocketAddr::new(interface, self.rpc_port.unwrap_or(default_listen_port))))
|
||||
}
|
||||
|
||||
fn rpc_methods(&self) -> Result<sc_service::config::RpcMethods> {
|
||||
|
||||
@@ -45,6 +45,17 @@ pub(crate) const DEFAULT_NETWORK_CONFIG_PATH: &str = "network";
|
||||
/// The recommended open file descriptor limit to be configured for the process.
|
||||
const RECOMMENDED_OPEN_FILE_DESCRIPTOR_LIMIT: u64 = 10_000;
|
||||
|
||||
/// The default port.
|
||||
pub const RPC_DEFAULT_PORT: u16 = 9944;
|
||||
/// The default max number of subscriptions per connection.
|
||||
pub const RPC_DEFAULT_MAX_SUBS_PER_CONN: u32 = 1024;
|
||||
/// The default max request size in MB.
|
||||
pub const RPC_DEFAULT_MAX_REQUEST_SIZE_MB: u32 = 15;
|
||||
/// The default max response size in MB.
|
||||
pub const RPC_DEFAULT_MAX_RESPONSE_SIZE_MB: u32 = 15;
|
||||
/// The default number of connection..
|
||||
pub const RPC_DEFAULT_MAX_CONNECTIONS: u32 = 100;
|
||||
|
||||
/// Default configuration values used by Substrate
|
||||
///
|
||||
/// These values will be used by [`CliConfiguration`] to set
|
||||
@@ -61,7 +72,7 @@ pub trait DefaultConfigurationValues {
|
||||
///
|
||||
/// By default this is `9944`.
|
||||
fn rpc_listen_port() -> u16 {
|
||||
9944
|
||||
RPC_DEFAULT_PORT
|
||||
}
|
||||
|
||||
/// The port Substrate should listen on for prometheus connections.
|
||||
@@ -303,14 +314,14 @@ pub trait CliConfiguration<DCV: DefaultConfigurationValues = ()>: Sized {
|
||||
/// Returns the RPC method set to expose.
|
||||
///
|
||||
/// By default this is `RpcMethods::Auto` (unsafe RPCs are denied iff
|
||||
/// `{rpc,ws}_external` returns true, respectively).
|
||||
/// `rpc_external` returns true, respectively).
|
||||
fn rpc_methods(&self) -> Result<RpcMethods> {
|
||||
Ok(Default::default())
|
||||
}
|
||||
|
||||
/// Get the maximum number of RPC server connections.
|
||||
fn rpc_max_connections(&self) -> Result<u32> {
|
||||
Ok(Default::default())
|
||||
Ok(RPC_DEFAULT_MAX_CONNECTIONS)
|
||||
}
|
||||
|
||||
/// Get the RPC cors (`None` if disabled)
|
||||
@@ -322,17 +333,17 @@ pub trait CliConfiguration<DCV: DefaultConfigurationValues = ()>: Sized {
|
||||
|
||||
/// Get maximum RPC request payload size.
|
||||
fn rpc_max_request_size(&self) -> Result<u32> {
|
||||
Ok(Default::default())
|
||||
Ok(RPC_DEFAULT_MAX_REQUEST_SIZE_MB)
|
||||
}
|
||||
|
||||
/// Get maximum RPC response payload size.
|
||||
fn rpc_max_response_size(&self) -> Result<u32> {
|
||||
Ok(Default::default())
|
||||
Ok(RPC_DEFAULT_MAX_RESPONSE_SIZE_MB)
|
||||
}
|
||||
|
||||
/// Get maximum number of subscriptions per connection.
|
||||
fn rpc_max_subscriptions_per_connection(&self) -> Result<u32> {
|
||||
Ok(Default::default())
|
||||
Ok(RPC_DEFAULT_MAX_SUBS_PER_CONN)
|
||||
}
|
||||
|
||||
/// Get the prometheus configuration (`None` if disabled)
|
||||
@@ -506,6 +517,7 @@ pub trait CliConfiguration<DCV: DefaultConfigurationValues = ()>: Sized {
|
||||
rpc_max_response_size: self.rpc_max_response_size()?,
|
||||
rpc_id_provider: None,
|
||||
rpc_max_subs_per_conn: self.rpc_max_subscriptions_per_connection()?,
|
||||
rpc_port: DCV::rpc_listen_port(),
|
||||
prometheus_config: self
|
||||
.prometheus_config(DCV::prometheus_listen_port(), &chain_spec)?,
|
||||
telemetry_endpoints,
|
||||
|
||||
@@ -296,6 +296,7 @@ mod tests {
|
||||
rpc_max_response_size: Default::default(),
|
||||
rpc_id_provider: Default::default(),
|
||||
rpc_max_subs_per_conn: Default::default(),
|
||||
rpc_port: 9944,
|
||||
prometheus_config: None,
|
||||
telemetry_endpoints: None,
|
||||
default_heap_pages: None,
|
||||
|
||||
Reference in New Issue
Block a user