mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-04-30 03:01:58 -04:00
feat: make instance argument optional (#14389)
Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
This commit is contained in:
@@ -61,8 +61,9 @@ pub struct NodeCommand<
|
||||
/// - `AUTH_PORT`: default + `instance` * 100 - 100
|
||||
/// - `HTTP_RPC_PORT`: default - `instance` + 1
|
||||
/// - `WS_RPC_PORT`: default + `instance` * 2 - 2
|
||||
#[arg(long, value_name = "INSTANCE", global = true, default_value_t = 1, value_parser = value_parser!(u16).range(..=200))]
|
||||
pub instance: u16,
|
||||
/// - `IPC_PATH`: default + `-instance`
|
||||
#[arg(long, value_name = "INSTANCE", global = true, value_parser = value_parser!(u16).range(..=200))]
|
||||
pub instance: Option<u16>,
|
||||
|
||||
/// Sets all ports to unused, allowing the OS to choose random unused ports when sockets are
|
||||
/// bound.
|
||||
@@ -324,7 +325,7 @@ mod tests {
|
||||
fn parse_instance() {
|
||||
let mut cmd: NodeCommand = NodeCommand::parse_from(["reth"]);
|
||||
cmd.rpc.adjust_instance_ports(cmd.instance);
|
||||
cmd.network.port = DEFAULT_DISCOVERY_PORT + cmd.instance - 1;
|
||||
cmd.network.port = DEFAULT_DISCOVERY_PORT;
|
||||
// check rpc port numbers
|
||||
assert_eq!(cmd.rpc.auth_port, 8551);
|
||||
assert_eq!(cmd.rpc.http_port, 8545);
|
||||
@@ -334,7 +335,7 @@ mod tests {
|
||||
|
||||
let mut cmd: NodeCommand = NodeCommand::parse_from(["reth", "--instance", "2"]);
|
||||
cmd.rpc.adjust_instance_ports(cmd.instance);
|
||||
cmd.network.port = DEFAULT_DISCOVERY_PORT + cmd.instance - 1;
|
||||
cmd.network.port = DEFAULT_DISCOVERY_PORT + 2 - 1;
|
||||
// check rpc port numbers
|
||||
assert_eq!(cmd.rpc.auth_port, 8651);
|
||||
assert_eq!(cmd.rpc.http_port, 8544);
|
||||
@@ -344,7 +345,7 @@ mod tests {
|
||||
|
||||
let mut cmd: NodeCommand = NodeCommand::parse_from(["reth", "--instance", "3"]);
|
||||
cmd.rpc.adjust_instance_ports(cmd.instance);
|
||||
cmd.network.port = DEFAULT_DISCOVERY_PORT + cmd.instance - 1;
|
||||
cmd.network.port = DEFAULT_DISCOVERY_PORT + 3 - 1;
|
||||
// check rpc port numbers
|
||||
assert_eq!(cmd.rpc.auth_port, 8751);
|
||||
assert_eq!(cmd.rpc.http_port, 8543);
|
||||
|
||||
Reference in New Issue
Block a user