diff --git a/src/net_processing.cpp b/src/net_processing.cpp index 0c3911e6fbbb7..73566e18e28d5 100644 --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -822,6 +822,7 @@ static void RelayTransaction(const CTransaction& tx, CConnman* connman) static void RelayAddress(const CAddress& addr, bool fReachable, CConnman* connman) { + if (!fReachable && !addr.IsRelayable()) return; int nRelayNodes = fReachable ? 2 : 1; // limited relaying of addresses outside our network(s) // Relay to a limited number of other nodes diff --git a/src/netaddress.h b/src/netaddress.h index 7c0c19a5e5fbe..7c5fbd26166ea 100644 --- a/src/netaddress.h +++ b/src/netaddress.h @@ -211,6 +211,14 @@ class CNetAddr friend bool operator!=(const CNetAddr& a, const CNetAddr& b); friend bool operator<(const CNetAddr& a, const CNetAddr& b); + /** + * Whether this address should be relayed to other peers even if we can't reach it ourselves. + */ + bool IsRelayable() const + { + return IsIPv4() || IsIPv6() || IsTor(); + } + /** * Serialize to a stream. */