scripted-diff: rename address relay fields

-BEGIN VERIFY SCRIPT-
ren() { sed -i "s:\<$1\>:$2:g" $(git grep -l "\<$1\>" ./src ./test); }

ren fGetAddr     m_getaddr_sent
ren fSentAddr    m_getaddr_recvd
ren vAddrToSend  m_addrs_to_send
-END VERIFY SCRIPT-
This commit is contained in:
John Newbery committed 2021-04-30 11:29:16 +01:00
1 parent 76568a3351
commit 09cc66c00e
1 file changed
+22 -22
+22 -22
View File
@@ -213,12 +213,12 @@ struct Peer {
std::atomic<bool> m_ping_queued{false}; std::atomic<bool> m_ping_queued{false};
/** A vector of addresses to send to the peer, limited to MAX_ADDR_TO_SEND. */ /** A vector of addresses to send to the peer, limited to MAX_ADDR_TO_SEND. */
std::vector<CAddress> vAddrToSend; std::vector<CAddress> m_addrs_to_send;
/** Probabilistic filter of addresses that this peer already knows. /** Probabilistic filter of addresses that this peer already knows.
* Used to avoid relaying addresses to this peer more than once. */ * Used to avoid relaying addresses to this peer more than once. */
const std::unique_ptr<CRollingBloomFilter> m_addr_known; const std::unique_ptr<CRollingBloomFilter> m_addr_known;
/** Whether a getaddr request to this peer is outstanding. */ /** Whether a getaddr request to this peer is outstanding. */
bool fGetAddr{false}; bool m_getaddr_sent{false};
/** Guards address sending timers. */ /** Guards address sending timers. */
mutable Mutex m_addr_send_times_mutex; mutable Mutex m_addr_send_times_mutex;
/** Time point to send the next ADDR message to this peer. */ /** Time point to send the next ADDR message to this peer. */
@@ -229,7 +229,7 @@ struct Peer {
* messages, indicating a preference to receive ADDRv2 instead of ADDR ones. */ * messages, indicating a preference to receive ADDRv2 instead of ADDR ones. */
std::atomic_bool m_wants_addrv2{false}; std::atomic_bool m_wants_addrv2{false};
/** Whether this peer has already sent us a getaddr message. */ /** Whether this peer has already sent us a getaddr message. */
bool fSentAddr{false}; bool m_getaddr_recvd{false};
/** Set of txids to reconsider once their parent transactions have been accepted **/ /** Set of txids to reconsider once their parent transactions have been accepted **/
std::set<uint256> m_orphan_work_set GUARDED_BY(g_cs_orphans); std::set<uint256> m_orphan_work_set GUARDED_BY(g_cs_orphans);
@@ -678,10 +678,10 @@ static void PushAddress(Peer& peer, const CAddress& addr, FastRandomContext& ins
// added after addresses were pushed. // added after addresses were pushed.
assert(peer.m_addr_known); assert(peer.m_addr_known);
if (addr.IsValid() && !peer.m_addr_known->contains(addr.GetKey()) && IsAddrCompatible(peer, addr)) { if (addr.IsValid() && !peer.m_addr_known->contains(addr.GetKey()) && IsAddrCompatible(peer, addr)) {
if (peer.vAddrToSend.size() >= MAX_ADDR_TO_SEND) { if (peer.m_addrs_to_send.size() >= MAX_ADDR_TO_SEND) {
peer.vAddrToSend[insecure_rand.randrange(peer.vAddrToSend.size())] = addr; peer.m_addrs_to_send[insecure_rand.randrange(peer.m_addrs_to_send.size())] = addr;
} else { } else {
peer.vAddrToSend.push_back(addr); peer.m_addrs_to_send.push_back(addr);
} }
} }
} }
@@ -2527,7 +2527,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
// Get recent addresses // Get recent addresses
m_connman.PushMessage(&pfrom, CNetMsgMaker(greatest_common_version).Make(NetMsgType::GETADDR)); m_connman.PushMessage(&pfrom, CNetMsgMaker(greatest_common_version).Make(NetMsgType::GETADDR));
peer->fGetAddr = true; peer->m_getaddr_sent = true;
} }
if (!pfrom.IsInboundConn()) { if (!pfrom.IsInboundConn()) {
@@ -2741,7 +2741,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
continue; continue;
} }
bool fReachable = IsReachable(addr); bool fReachable = IsReachable(addr);
if (addr.nTime > nSince && !peer->fGetAddr && vAddr.size() <= 10 && addr.IsRoutable()) { if (addr.nTime > nSince && !peer->m_getaddr_sent && vAddr.size() <= 10 && addr.IsRoutable()) {
// Relay to a limited number of other nodes // Relay to a limited number of other nodes
RelayAddress(pfrom.GetId(), addr, fReachable); RelayAddress(pfrom.GetId(), addr, fReachable);
} }
@@ -2750,7 +2750,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
vAddrOk.push_back(addr); vAddrOk.push_back(addr);
} }
m_addrman.Add(vAddrOk, pfrom.addr, 2 * 60 * 60); m_addrman.Add(vAddrOk, pfrom.addr, 2 * 60 * 60);
if (vAddr.size() < 1000) peer->fGetAddr = false; if (vAddr.size() < 1000) peer->m_getaddr_sent = false;
if (pfrom.IsAddrFetchConn()) { if (pfrom.IsAddrFetchConn()) {
LogPrint(BCLog::NET, "addrfetch connection completed peer=%d; disconnecting\n", pfrom.GetId()); LogPrint(BCLog::NET, "addrfetch connection completed peer=%d; disconnecting\n", pfrom.GetId());
pfrom.fDisconnect = true; pfrom.fDisconnect = true;
@@ -3632,13 +3632,13 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
// Only send one GetAddr response per connection to reduce resource waste // Only send one GetAddr response per connection to reduce resource waste
// and discourage addr stamping of INV announcements. // and discourage addr stamping of INV announcements.
if (peer->fSentAddr) { if (peer->m_getaddr_recvd) {
LogPrint(BCLog::NET, "Ignoring repeated \"getaddr\". peer=%d\n", pfrom.GetId()); LogPrint(BCLog::NET, "Ignoring repeated \"getaddr\". peer=%d\n", pfrom.GetId());
return; return;
} }
peer->fSentAddr = true; peer->m_getaddr_recvd = true;
peer->vAddrToSend.clear(); peer->m_addrs_to_send.clear();
std::vector<CAddress> vAddr; std::vector<CAddress> vAddr;
if (pfrom.HasPermission(PF_ADDR)) { if (pfrom.HasPermission(PF_ADDR)) {
vAddr = m_connman.GetAddresses(MAX_ADDR_TO_SEND, MAX_PCT_ADDR_TO_SEND); vAddr = m_connman.GetAddresses(MAX_ADDR_TO_SEND, MAX_PCT_ADDR_TO_SEND);
@@ -4235,10 +4235,10 @@ void PeerManagerImpl::MaybeSendAddr(CNode& node, Peer& peer, std::chrono::micros
peer.m_next_addr_send = PoissonNextSend(current_time, AVG_ADDRESS_BROADCAST_INTERVAL); peer.m_next_addr_send = PoissonNextSend(current_time, AVG_ADDRESS_BROADCAST_INTERVAL);
if (!Assume(peer.vAddrToSend.size() <= MAX_ADDR_TO_SEND)) { if (!Assume(peer.m_addrs_to_send.size() <= MAX_ADDR_TO_SEND)) {
// Should be impossible since we always check size before adding to // Should be impossible since we always check size before adding to
// vAddrToSend. Recover by trimming the vector. // m_addrs_to_send. Recover by trimming the vector.
peer.vAddrToSend.resize(MAX_ADDR_TO_SEND); peer.m_addrs_to_send.resize(MAX_ADDR_TO_SEND);
} }
// Remove addr records that the peer already knows about, and add new // Remove addr records that the peer already knows about, and add new
@@ -4248,11 +4248,11 @@ void PeerManagerImpl::MaybeSendAddr(CNode& node, Peer& peer, std::chrono::micros
if (!ret) peer.m_addr_known->insert(addr.GetKey()); if (!ret) peer.m_addr_known->insert(addr.GetKey());
return ret; return ret;
}; };
peer.vAddrToSend.erase(std::remove_if(peer.vAddrToSend.begin(), peer.vAddrToSend.end(), addr_already_known), peer.m_addrs_to_send.erase(std::remove_if(peer.m_addrs_to_send.begin(), peer.m_addrs_to_send.end(), addr_already_known),
peer.vAddrToSend.end()); peer.m_addrs_to_send.end());
// No addr messages to send // No addr messages to send
if (peer.vAddrToSend.empty()) return; if (peer.m_addrs_to_send.empty()) return;
const char* msg_type; const char* msg_type;
int make_flags; int make_flags;
@@ -4263,12 +4263,12 @@ void PeerManagerImpl::MaybeSendAddr(CNode& node, Peer& peer, std::chrono::micros
msg_type = NetMsgType::ADDR; msg_type = NetMsgType::ADDR;
make_flags = 0; make_flags = 0;
} }
m_connman.PushMessage(&node, CNetMsgMaker(node.GetCommonVersion()).Make(make_flags, msg_type, peer.vAddrToSend)); m_connman.PushMessage(&node, CNetMsgMaker(node.GetCommonVersion()).Make(make_flags, msg_type, peer.m_addrs_to_send));
peer.vAddrToSend.clear(); peer.m_addrs_to_send.clear();
// we only send the big addr message once // we only send the big addr message once
if (peer.vAddrToSend.capacity() > 40) { if (peer.m_addrs_to_send.capacity() > 40) {
peer.vAddrToSend.shrink_to_fit(); peer.m_addrs_to_send.shrink_to_fit();
} }
} }