Skip to content

Commit 86d4cf4

Browse files
committed
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.
1 parent d052f5e commit 86d4cf4

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/net_processing.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1481,7 +1481,6 @@ void RelayTransaction(const uint256& txid, const uint256& wtxid, const CConnman&
14811481

14821482
static void RelayAddress(const CAddress& addr, bool fReachable, const CConnman& connman)
14831483
{
1484-
unsigned int nRelayNodes = fReachable ? 2 : 1; // limited relaying of addresses outside our network(s)
14851484

14861485
// Relay to a limited number of other nodes
14871486
// 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&
14901489
const CSipHasher hasher = connman.GetDeterministicRandomizer(RANDOMIZER_ID_ADDRESS_RELAY).Write(hashAddr << 32).Write((GetTime() + hashAddr) / (24 * 60 * 60));
14911490
FastRandomContext insecure_rand;
14921491

1492+
// Relay reachable addresses to 2 peers. Unreachable addresses are relayed randomly to 1 or 2 peers.
1493+
unsigned int nRelayNodes = (fReachable || (hasher.Finalize() & 1)) ? 2 : 1;
1494+
14931495
std::array<std::pair<uint64_t, CNode*>,2> best{{{0, nullptr}, {0, nullptr}}};
14941496
assert(nRelayNodes <= best.size());
14951497

0 commit comments

Comments
 (0)