Changeset View
Changeset View
Standalone View
Standalone View
src/net.h
Show First 20 Lines • Show All 862 Lines • ▼ Show 20 Lines | public: | ||||
} | } | ||||
// This boolean is unusued in actual processing, only present for backward | // This boolean is unusued in actual processing, only present for backward | ||||
// compatibility at RPC/QT level | // compatibility at RPC/QT level | ||||
bool m_legacyWhitelisted{false}; | bool m_legacyWhitelisted{false}; | ||||
// set by version message | // set by version message | ||||
bool fClient{false}; | bool fClient{false}; | ||||
// after BIP159, set by version message | // after BIP159, set by version message | ||||
bool m_limited_node{false}; | bool m_limited_node{false}; | ||||
/** | |||||
* Whether the peer has signaled support for receiving ADDRv2 (BIP155) | |||||
* messages, implying a preference to receive ADDRv2 instead of ADDR ones. | |||||
*/ | |||||
std::atomic_bool m_wants_addrv2{false}; | |||||
std::atomic_bool fSuccessfullyConnected{false}; | std::atomic_bool fSuccessfullyConnected{false}; | ||||
// Setting fDisconnect to true will cause the node to be disconnected the | // Setting fDisconnect to true will cause the node to be disconnected the | ||||
// next time DisconnectNodes() runs | // next time DisconnectNodes() runs | ||||
std::atomic_bool fDisconnect{false}; | std::atomic_bool fDisconnect{false}; | ||||
bool fSentAddr{false}; | bool fSentAddr{false}; | ||||
CSemaphoreGrant grantOutbound; | CSemaphoreGrant grantOutbound; | ||||
std::atomic<int> nRefCount{0}; | std::atomic<int> nRefCount{0}; | ||||
▲ Show 20 Lines • Show All 219 Lines • ▼ Show 20 Lines | public: | ||||
void Release() { nRefCount--; } | void Release() { nRefCount--; } | ||||
void AddAddressKnown(const CAddress &_addr) { | void AddAddressKnown(const CAddress &_addr) { | ||||
assert(m_addr_known); | assert(m_addr_known); | ||||
m_addr_known->insert(_addr.GetKey()); | m_addr_known->insert(_addr.GetKey()); | ||||
} | } | ||||
void PushAddress(const CAddress &_addr, FastRandomContext &insecure_rand) { | void PushAddress(const CAddress &_addr, FastRandomContext &insecure_rand) { | ||||
// Whether the peer supports the address in `_addr`. For example, | |||||
// nodes that do not implement BIP155 cannot receive Tor v3 addresses | |||||
// because they require ADDRv2 (BIP155) encoding. | |||||
const bool addr_format_supported = | |||||
m_wants_addrv2 || _addr.IsAddrV1Compatible(); | |||||
// Known checking here is only to save space from duplicates. | // Known checking here is only to save space from duplicates. | ||||
// SendMessages will filter it again for knowns that were added | // SendMessages will filter it again for knowns that were added | ||||
// after addresses were pushed. | // after addresses were pushed. | ||||
assert(m_addr_known); | assert(m_addr_known); | ||||
if (_addr.IsValid() && !m_addr_known->contains(_addr.GetKey())) { | if (_addr.IsValid() && !m_addr_known->contains(_addr.GetKey()) && | ||||
addr_format_supported) { | |||||
if (vAddrToSend.size() >= MAX_ADDR_TO_SEND) { | if (vAddrToSend.size() >= MAX_ADDR_TO_SEND) { | ||||
vAddrToSend[insecure_rand.randrange(vAddrToSend.size())] = | vAddrToSend[insecure_rand.randrange(vAddrToSend.size())] = | ||||
_addr; | _addr; | ||||
} else { | } else { | ||||
vAddrToSend.push_back(_addr); | vAddrToSend.push_back(_addr); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
▲ Show 20 Lines • Show All 57 Lines • Show Last 20 Lines |