Skip to content

Commit 86acc96

Browse files
committed
[net processing] Take NodeId instead of CNode* as originator for RelayAddress()
This makes the following commit easier.
1 parent 539e4ee commit 86acc96

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/net_processing.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1490,13 +1490,13 @@ void PeerManagerImpl::RelayTransaction(const uint256& txid, const uint256& wtxid
14901490
* address. So within 24h we will likely relay a given address once. This is to
14911491
* prevent a peer from unjustly giving their address better propagation by sending
14921492
* it to us repeatedly.
1493-
* @param[in] originator The peer that sent us the address. We don't want to relay it back.
1493+
* @param[in] originator The id of the peer that sent us the address. We don't want to relay it back.
14941494
* @param[in] addr Address to relay.
14951495
* @param[in] fReachable Whether the address' network is reachable. We relay unreachable
14961496
* addresses less.
14971497
* @param[in] connman Connection manager to choose nodes to relay to.
14981498
*/
1499-
static void RelayAddress(const CNode& originator,
1499+
static void RelayAddress(NodeId originator,
15001500
const CAddress& addr,
15011501
bool fReachable,
15021502
const CConnman& connman)
@@ -1516,8 +1516,8 @@ static void RelayAddress(const CNode& originator,
15161516
std::array<std::pair<uint64_t, CNode*>,2> best{{{0, nullptr}, {0, nullptr}}};
15171517
assert(nRelayNodes <= best.size());
15181518

1519-
auto sortfunc = [&best, &hasher, nRelayNodes, &originator, &addr](CNode* pnode) {
1520-
if (pnode->RelayAddrsWithConn() && pnode != &originator && pnode->IsAddrCompatible(addr)) {
1519+
auto sortfunc = [&best, &hasher, nRelayNodes, originator, &addr](CNode* pnode) {
1520+
if (pnode->RelayAddrsWithConn() && pnode->GetId() != originator && pnode->IsAddrCompatible(addr)) {
15211521
uint64_t hashKey = CSipHasher(hasher).Write(pnode->GetId()).Finalize();
15221522
for (unsigned int i = 0; i < nRelayNodes; i++) {
15231523
if (hashKey > best[i].first) {
@@ -2683,7 +2683,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
26832683
if (addr.nTime > nSince && !pfrom.fGetAddr && vAddr.size() <= 10 && addr.IsRoutable())
26842684
{
26852685
// Relay to a limited number of other nodes
2686-
RelayAddress(pfrom, addr, fReachable, m_connman);
2686+
RelayAddress(pfrom.GetId(), addr, fReachable, m_connman);
26872687
}
26882688
// Do not store addresses outside our network
26892689
if (fReachable)

0 commit comments

Comments
 (0)