Skip to content

Commit d0abce9

Browse files
committed
net: include the port when deciding a relay destination
In `PeerManagerImpl::RelayAddress()` we used just the hash of the address that is being relayed to decide where to relay it to. Include the port in that hash, so that e.g. `1.1.1.1:5555` and `1.1.1.1:6666` get relayed to different peers. Those are two different, distinct services after all.
1 parent 2e38a0e commit d0abce9

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/net_processing.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1775,8 +1775,10 @@ void PeerManagerImpl::RelayAddress(NodeId originator,
17751775
// Relay to a limited number of other nodes
17761776
// Use deterministic randomness to send to the same nodes for 24 hours
17771777
// at a time so the m_addr_knowns of the chosen nodes prevent repeats
1778-
const uint64_t hashAddr{addr.GetHash()};
1779-
const CSipHasher hasher{m_connman.GetDeterministicRandomizer(RANDOMIZER_ID_ADDRESS_RELAY).Write(hashAddr).Write((GetTime() + hashAddr) / (24 * 60 * 60))};
1778+
const uint64_t hash_addr{CServiceHash(0, 0)(addr)};
1779+
const CSipHasher hasher{m_connman.GetDeterministicRandomizer(RANDOMIZER_ID_ADDRESS_RELAY)
1780+
.Write(hash_addr)
1781+
.Write((GetTime() + hash_addr) / (24 * 60 * 60))};
17801782
FastRandomContext insecure_rand;
17811783

17821784
// Relay reachable addresses to 2 peers. Unreachable addresses are relayed randomly to 1 or 2 peers.

0 commit comments

Comments
 (0)