aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVasil Dimov <vd@FreeBSD.org>2021-11-29 12:05:05 +0100
committerVasil Dimov <vd@FreeBSD.org>2022-02-11 15:21:51 +0100
commitd0abce9a50dd4f507e3a30348eabffb7552471d5 (patch)
tree829da0c97825148d7ff925c84179b29a4791fd63
parent2e38a0e6865187d1f0d0f016d3df7cce414a7c4f (diff)
downloadbitcoin-d0abce9a50dd4f507e3a30348eabffb7552471d5.tar.xz
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.
-rw-r--r--src/net_processing.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/net_processing.cpp b/src/net_processing.cpp
index 3cebca1a77..f05b4fd8e2 100644
--- a/src/net_processing.cpp
+++ b/src/net_processing.cpp
@@ -1775,8 +1775,10 @@ void PeerManagerImpl::RelayAddress(NodeId originator,
// Relay to a limited number of other nodes
// Use deterministic randomness to send to the same nodes for 24 hours
// at a time so the m_addr_knowns of the chosen nodes prevent repeats
- const uint64_t hashAddr{addr.GetHash()};
- const CSipHasher hasher{m_connman.GetDeterministicRandomizer(RANDOMIZER_ID_ADDRESS_RELAY).Write(hashAddr).Write((GetTime() + hashAddr) / (24 * 60 * 60))};
+ const uint64_t hash_addr{CServiceHash(0, 0)(addr)};
+ const CSipHasher hasher{m_connman.GetDeterministicRandomizer(RANDOMIZER_ID_ADDRESS_RELAY)
+ .Write(hash_addr)
+ .Write((GetTime() + hash_addr) / (24 * 60 * 60))};
FastRandomContext insecure_rand;
// Relay reachable addresses to 2 peers. Unreachable addresses are relayed randomly to 1 or 2 peers.