aboutsummaryrefslogtreecommitdiff
path: root/src/net_processing.cpp
diff options
context:
space:
mode:
authorPieter Wuille <pieter@wuille.net>2020-08-14 22:53:51 -0700
committerPieter Wuille <pieter@wuille.net>2020-08-14 23:02:42 -0700
commit86d4cf42d97abf4c436d1eabf29e2ed150f69c1e (patch)
tree6f3ebf08d7a3ff179dc59015c76f4b49e1171737 /src/net_processing.cpp
parentd052f5e6b79b9600f929457e9280b441b772785b (diff)
downloadbitcoin-86d4cf42d97abf4c436d1eabf29e2ed150f69c1e.tar.xz
Increase the ip address relay branching factor for unreachable networks
Onion addresses propagate very badly among the IPv4/IPv6 network, resulting in difficulty for those to find each other. The branching factor 1 is probably so low that propagations die out before they reach another onion peer. Increase it to 1.5 on average.
Diffstat (limited to 'src/net_processing.cpp')
-rw-r--r--src/net_processing.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/net_processing.cpp b/src/net_processing.cpp
index 7b83583e41..d637abcef3 100644
--- a/src/net_processing.cpp
+++ b/src/net_processing.cpp
@@ -1481,7 +1481,6 @@ void RelayTransaction(const uint256& txid, const uint256& wtxid, const CConnman&
static void RelayAddress(const CAddress& addr, bool fReachable, const CConnman& connman)
{
- unsigned int nRelayNodes = fReachable ? 2 : 1; // limited relaying of addresses outside our network(s)
// Relay to a limited number of other nodes
// Use deterministic randomness to send to the same nodes for 24 hours
@@ -1490,6 +1489,9 @@ static void RelayAddress(const CAddress& addr, bool fReachable, const CConnman&
const CSipHasher hasher = connman.GetDeterministicRandomizer(RANDOMIZER_ID_ADDRESS_RELAY).Write(hashAddr << 32).Write((GetTime() + hashAddr) / (24 * 60 * 60));
FastRandomContext insecure_rand;
+ // Relay reachable addresses to 2 peers. Unreachable addresses are relayed randomly to 1 or 2 peers.
+ unsigned int nRelayNodes = (fReachable || (hasher.Finalize() & 1)) ? 2 : 1;
+
std::array<std::pair<uint64_t, CNode*>,2> best{{{0, nullptr}, {0, nullptr}}};
assert(nRelayNodes <= best.size());