Add CNetAddr::IsPrivacyNet() and CNode::IsConnectedThroughPrivacyNet()

Co-authored-by: Vasil Dimov <vd@FreeBSD.org>
pull/28078/head
Jon Atack 1 year ago
parent df488563b2
commit 07f5891588

@ -620,6 +620,11 @@ Network CNode::ConnectedThroughNetwork() const
return m_inbound_onion ? NET_ONION : addr.GetNetClass(); return m_inbound_onion ? NET_ONION : addr.GetNetClass();
} }
bool CNode::IsConnectedThroughPrivacyNet() const
{
return m_inbound_onion || addr.IsPrivacyNet();
}
#undef X #undef X
#define X(name) stats.name = name #define X(name) stats.name = name
void CNode::CopyStats(CNodeStats& stats) void CNode::CopyStats(CNodeStats& stats)

@ -506,6 +506,9 @@ public:
*/ */
Network ConnectedThroughNetwork() const; Network ConnectedThroughNetwork() const;
/** Whether this peer connected through a privacy network. */
[[nodiscard]] bool IsConnectedThroughPrivacyNet() const;
// We selected peer as (compact blocks) high-bandwidth peer (BIP152) // We selected peer as (compact blocks) high-bandwidth peer (BIP152)
std::atomic<bool> m_bip152_highbandwidth_to{false}; std::atomic<bool> m_bip152_highbandwidth_to{false};
// Peer selected us as (compact blocks) high-bandwidth peer (BIP152) // Peer selected us as (compact blocks) high-bandwidth peer (BIP152)

@ -188,6 +188,13 @@ public:
bool IsInternal() const; bool IsInternal() const;
bool IsValid() const; bool IsValid() const;
/**
* Whether this object is a privacy network.
* TODO: consider adding IsCJDNS() here when more peers adopt CJDNS, see:
* https://github.com/bitcoin/bitcoin/pull/27411#issuecomment-1497176155
*/
[[nodiscard]] bool IsPrivacyNet() const { return IsTor() || IsI2P(); }
/** /**
* Check if the current object can be serialized in pre-ADDRv2/BIP155 format. * Check if the current object can be serialized in pre-ADDRv2/BIP155 format.
*/ */

Loading…
Cancel
Save