Skip to content

Commit 2e8c7ef

Browse files
committed
refactor: simplify (non-)mainnet port check condition
1 parent 78ebaeb commit 2e8c7ef

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

src/evo/netinfo.cpp

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,9 @@ NetInfoStatus MnNetInfo::ValidateService(const CService& service)
3636
return NetInfoStatus::BadInput;
3737
}
3838

39-
const auto default_port_main = MainParams().GetDefaultPort();
40-
if (IsNodeOnMainnet()) {
41-
if (service.GetPort() != default_port_main) {
42-
// Must use mainnet port on mainnet
43-
return NetInfoStatus::BadPort;
44-
}
45-
} else if (service.GetPort() == default_port_main) {
46-
// Using mainnet port prohibited outside of mainnet
39+
if (IsNodeOnMainnet() != (service.GetPort() == MainParams().GetDefaultPort())) {
40+
// Must use mainnet port on mainnet.
41+
// Must NOT use mainnet port on other networks.
4742
return NetInfoStatus::BadPort;
4843
}
4944

0 commit comments

Comments
 (0)