Skip to content

Commit c061599

Browse files
committed
[net_processing] Remove RelayAddrsWithPeer function
Now that we have a simple boolean stored on the field, the wrapper function is no longer necessary.
1 parent 201e496 commit c061599

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

src/net_processing.cpp

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -761,11 +761,6 @@ static CNodeState *State(NodeId pnode) EXCLUSIVE_LOCKS_REQUIRED(cs_main) {
761761
return &it->second;
762762
}
763763

764-
static bool RelayAddrsWithPeer(const Peer& peer)
765-
{
766-
return peer.m_addr_relay_enabled;
767-
}
768-
769764
/**
770765
* Whether the peer supports the address. For example, a peer that does not
771766
* implement BIP155 cannot receive Tor v3 addresses because it requires
@@ -1708,7 +1703,7 @@ void PeerManagerImpl::RelayAddress(NodeId originator,
17081703
LOCK(m_peer_mutex);
17091704

17101705
for (auto& [id, peer] : m_peer_map) {
1711-
if (RelayAddrsWithPeer(*peer) && id != originator && IsAddrCompatible(*peer, addr)) {
1706+
if (peer->m_addr_relay_enabled && id != originator && IsAddrCompatible(*peer, addr)) {
17121707
uint64_t hashKey = CSipHasher(hasher).Write(id).Finalize();
17131708
for (unsigned int i = 0; i < nRelayNodes; i++) {
17141709
if (hashKey > best[i].first) {
@@ -4327,7 +4322,7 @@ void PeerManagerImpl::MaybeSendPing(CNode& node_to, Peer& peer, std::chrono::mic
43274322
void PeerManagerImpl::MaybeSendAddr(CNode& node, Peer& peer, std::chrono::microseconds current_time)
43284323
{
43294324
// Nothing to do for non-address-relay peers
4330-
if (!RelayAddrsWithPeer(peer)) return;
4325+
if (!peer.m_addr_relay_enabled) return;
43314326

43324327
LOCK(peer.m_addr_send_times_mutex);
43334328
// Periodically advertise our local address to the peer.
@@ -4462,11 +4457,10 @@ bool PeerManagerImpl::SetupAddressRelay(CNode& node, Peer& peer)
44624457
// information of addr traffic to infer the link.
44634458
if (node.IsBlockOnlyConn()) return false;
44644459

4465-
if (!RelayAddrsWithPeer(peer)) {
4460+
if (!peer.m_addr_relay_enabled.exchange(true)) {
44664461
// First addr message we have received from the peer, initialize
44674462
// m_addr_known
44684463
peer.m_addr_known = std::make_unique<CRollingBloomFilter>(5000, 0.001);
4469-
peer.m_addr_relay_enabled = true;
44704464
}
44714465

44724466
return true;

0 commit comments

Comments
 (0)