From f545f934e699d471e620fe3108f2081f71273fab Mon Sep 17 00:00:00 2001 From: Stefan Bratanov Date: Mon, 1 Jul 2024 10:48:59 -0700 Subject: [PATCH] change to cli option --- .../p2p/discovery/DiscoveryConfig.java | 20 +++++++++---------- .../p2p/network/config/NetworkConfig.java | 12 +++++------ 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/networking/p2p/src/main/java/tech/pegasys/teku/networking/p2p/discovery/DiscoveryConfig.java b/networking/p2p/src/main/java/tech/pegasys/teku/networking/p2p/discovery/DiscoveryConfig.java index a242d7ddad1..aaf52c88e64 100644 --- a/networking/p2p/src/main/java/tech/pegasys/teku/networking/p2p/discovery/DiscoveryConfig.java +++ b/networking/p2p/src/main/java/tech/pegasys/teku/networking/p2p/discovery/DiscoveryConfig.java @@ -170,13 +170,13 @@ public Builder isDiscoveryEnabled(final Boolean discoveryEnabled) { } public Builder listenUdpPort(final int listenUdpPort) { - validatePort(listenUdpPort, "listenUdpPort"); + validatePort(listenUdpPort, "--p2p-udp-port"); this.listenUdpPort = OptionalInt.of(listenUdpPort); return this; } public Builder listenUdpPortDefault(final int listenUdpPort) { - validatePort(listenUdpPort, "listenUdpPortDefault"); + validatePort(listenUdpPort, "--p2p-udp-port"); if (this.listenUdpPort.isEmpty()) { this.listenUdpPort = OptionalInt.of(listenUdpPort); } @@ -184,13 +184,13 @@ public Builder listenUdpPortDefault(final int listenUdpPort) { } public Builder listenUdpPortIpv6(final int listenUdpPortIpv6) { - validatePort(listenUdpPortIpv6, "listenUdpPortIpv6"); + validatePort(listenUdpPortIpv6, "--Xp2p-udp-port-ipv6"); this.listenUdpPortIpv6 = OptionalInt.of(listenUdpPortIpv6); return this; } public Builder listenUdpPortIpv6Default(final int listenUdpPortIpv6) { - validatePort(listenUdpPortIpv6, "listenUdpPortIpv6Default"); + validatePort(listenUdpPortIpv6, "--Xp2p-udp-port-ipv6"); if (this.listenUdpPortIpv6.isEmpty()) { this.listenUdpPortIpv6 = OptionalInt.of(listenUdpPortIpv6); } @@ -200,7 +200,7 @@ public Builder listenUdpPortIpv6Default(final int listenUdpPortIpv6) { public Builder advertisedUdpPort(final OptionalInt advertisedUdpPort) { checkNotNull(advertisedUdpPort); if (advertisedUdpPort.isPresent()) { - validatePort(advertisedUdpPort.getAsInt(), "advertisedUdpPort"); + validatePort(advertisedUdpPort.getAsInt(), "--p2p-advertised-udp-port"); } this.advertisedUdpPort = advertisedUdpPort; return this; @@ -209,7 +209,7 @@ public Builder advertisedUdpPort(final OptionalInt advertisedUdpPort) { public Builder advertisedUdpPortDefault(final OptionalInt advertisedUdpPort) { checkNotNull(advertisedUdpPort); if (advertisedUdpPort.isPresent()) { - validatePort(advertisedUdpPort.getAsInt(), "advertisedUdpPortDefault"); + validatePort(advertisedUdpPort.getAsInt(), "--p2p-advertised-udp-port"); } if (this.advertisedUdpPort.isEmpty()) { this.advertisedUdpPort = advertisedUdpPort; @@ -220,7 +220,7 @@ public Builder advertisedUdpPortDefault(final OptionalInt advertisedUdpPort) { public Builder advertisedUdpPortIpv6(final OptionalInt advertisedUdpPortIpv6) { checkNotNull(advertisedUdpPortIpv6); if (advertisedUdpPortIpv6.isPresent()) { - validatePort(advertisedUdpPortIpv6.getAsInt(), "advertisedUdpPortIpv6"); + validatePort(advertisedUdpPortIpv6.getAsInt(), "--Xp2p-advertised-udp-port-ipv6"); } this.advertisedUdpPortIpv6 = advertisedUdpPortIpv6; return this; @@ -229,7 +229,7 @@ public Builder advertisedUdpPortIpv6(final OptionalInt advertisedUdpPortIpv6) { public Builder advertisedUdpPortIpv6Default(final OptionalInt advertisedUdpPortIpv6) { checkNotNull(advertisedUdpPortIpv6); if (advertisedUdpPortIpv6.isPresent()) { - validatePort(advertisedUdpPortIpv6.getAsInt(), "advertisedUdpPortIpv6Default"); + validatePort(advertisedUdpPortIpv6.getAsInt(), "--Xp2p-advertised-udp-port-ipv6"); } if (this.advertisedUdpPortIpv6.isEmpty()) { this.advertisedUdpPortIpv6 = advertisedUdpPortIpv6; @@ -290,9 +290,9 @@ public Builder siteLocalAddressesEnabled(final boolean siteLocalAddressesEnabled return this; } - private void validatePort(final int port, final String parameter) { + private void validatePort(final int port, final String cliOption) { if (!PortAvailability.isPortValid(port)) { - throw new InvalidConfigurationException(String.format("Invalid %s: %d", parameter, port)); + throw new InvalidConfigurationException(String.format("Invalid %s: %d", cliOption, port)); } } } diff --git a/networking/p2p/src/main/java/tech/pegasys/teku/networking/p2p/network/config/NetworkConfig.java b/networking/p2p/src/main/java/tech/pegasys/teku/networking/p2p/network/config/NetworkConfig.java index af65e1cd043..7f506cd9e57 100644 --- a/networking/p2p/src/main/java/tech/pegasys/teku/networking/p2p/network/config/NetworkConfig.java +++ b/networking/p2p/src/main/java/tech/pegasys/teku/networking/p2p/network/config/NetworkConfig.java @@ -307,27 +307,27 @@ public Builder advertisedIps(final Optional> advertisedIps) { } public Builder listenPort(final int listenPort) { - validatePort(listenPort, "listenPort"); + validatePort(listenPort, "--p2p-port"); this.listenPort = listenPort; return this; } public Builder listenPortIpv6(final int listenPortIpv6) { - validatePort(listenPortIpv6, "listenPortIpv6"); + validatePort(listenPortIpv6, "-Xp2p-port-ipv6"); this.listenPortIpv6 = listenPortIpv6; return this; } public Builder advertisedPort(final OptionalInt advertisedPort) { checkNotNull(advertisedPort); - advertisedPort.ifPresent(port -> validatePort(port, "advertisedPort")); + advertisedPort.ifPresent(port -> validatePort(port, "--p2p-advertised-ip")); this.advertisedPort = advertisedPort; return this; } public Builder advertisedPortIpv6(final OptionalInt advertisedPortIpv6) { checkNotNull(advertisedPortIpv6); - advertisedPortIpv6.ifPresent(port -> validatePort(port, "advertisedPortIpv6")); + advertisedPortIpv6.ifPresent(port -> validatePort(port, "--Xp2p-advertised-port-ipv6")); this.advertisedPortIpv6 = advertisedPortIpv6; return this; } @@ -362,9 +362,9 @@ private void validateAddresses(final List addresses, final String cliOpt } } - private void validatePort(final int port, final String parameter) { + private void validatePort(final int port, final String cliOption) { if (!PortAvailability.isPortValid(port)) { - throw new InvalidConfigurationException(String.format("Invalid %s: %d", parameter, port)); + throw new InvalidConfigurationException(String.format("Invalid %s: %d", cliOption, port)); } } }