Skip to content

Commit f1304db

Browse files
committed
Use higher-level CNetAddr and CNode helpers in net.cpp
rather than low-level comparisons with Network enum values.
1 parent 07f5891 commit f1304db

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

src/net.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -158,11 +158,8 @@ uint16_t GetListenPort()
158158
// For privacy reasons, don't advertise our privacy-network address
159159
// to other networks and don't advertise our other-network address
160160
// to privacy networks.
161-
const Network our_net{local_addr.GetNetwork()};
162-
const Network peers_net{peer.ConnectedThroughNetwork()};
163-
if (our_net != peers_net &&
164-
(our_net == NET_ONION || our_net == NET_I2P ||
165-
peers_net == NET_ONION || peers_net == NET_I2P)) {
161+
if (local_addr.GetNetwork() != peer.ConnectedThroughNetwork()
162+
&& (local_addr.IsPrivacyNet() || peer.IsConnectedThroughPrivacyNet())) {
166163
continue;
167164
}
168165
const int nScore{local_service_info.nScore};
@@ -272,7 +269,7 @@ std::optional<CService> GetLocalAddrForPeer(CNode& node)
272269
CService MaybeFlipIPv6toCJDNS(const CService& service)
273270
{
274271
CService ret{service};
275-
if (ret.m_net == NET_IPV6 && ret.HasCJDNSPrefix() && IsReachable(NET_CJDNS)) {
272+
if (ret.IsIPv6() && ret.HasCJDNSPrefix() && IsReachable(NET_CJDNS)) {
276273
ret.m_net = NET_CJDNS;
277274
}
278275
return ret;
@@ -488,7 +485,7 @@ CNode* CConnman::ConnectNode(CAddress addrConnect, const char *pszDest, bool fCo
488485
const bool use_proxy{GetProxy(addrConnect.GetNetwork(), proxy)};
489486
bool proxyConnectionFailed = false;
490487

491-
if (addrConnect.GetNetwork() == NET_I2P && use_proxy) {
488+
if (addrConnect.IsI2P() && use_proxy) {
492489
i2p::Connection conn;
493490

494491
if (m_i2p_sam_session) {

0 commit comments

Comments
 (0)