fix cli: make port Option<u16> again (#14088)

This commit is contained in:
Niklas Adolfsson
2023-05-07 21:11:03 +02:00
committed by GitHub
parent c8b66415bb
commit bd96f00146
8 changed files with 35 additions and 15 deletions
+18 -6
View File
@@ -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,