Skip to content

Commit 416efcb

Browse files
committed
Merge #19728: Increase the ip address relay branching factor for unreachable networks
86d4cf4 Increase the ip address relay branching factor for unreachable networks (Pieter Wuille) Pull request description: 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. ACKs for top commit: practicalswift: ACK 86d4cf4 -- patch looks correct naumenkogs: ACK 86d4cf4 jonatack: ACK 86d4cf4. Code review, built and running with some sanity check logging. `RelayAddress()` is called by `ProcessMessage() ADDR` msg handling, from within the loop while processing each new address to relay it to a limited number of other nodes. According to git blame, the line setting `nRelayNodes` hasn't been touched since 2016 in e736772 *Move network-msg-processing code out of main to its own file*, which moved the line but otherwise did not change it. Running a mixed clearnet/onion node with this patch and the logging below, I'm only seeing values of `fReachable 1, nRelayNodes 2`. IIUC, I need to use the settings in `init.cpp` that call `SetReachable(*, false)`. *Edit:* with `onlynet=onion` am now seeing entries of `fReachable 0` with `nRelayNodes` values of 1 and 2. vasild: ACK 86d4cf4 Tree-SHA512: 22391e16d60bcfdec9a9336728da39d68a24a183b3d1b0e8fbc038d265ca6ddf71d16db018f3678745fd9f3e9281049e42197fa0a29124833c50a9170ed6f793
2 parents 81a19e7 + 86d4cf4 commit 416efcb

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
@@ -1519,7 +1519,6 @@ void RelayTransaction(const uint256& txid, const uint256& wtxid, const CConnman&
15191519

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

15241523
// Relay to a limited number of other nodes
15251524
// Use deterministic randomness to send to the same nodes for 24 hours
@@ -1528,6 +1527,9 @@ static void RelayAddress(const CAddress& addr, bool fReachable, const CConnman&
15281527
const CSipHasher hasher = connman.GetDeterministicRandomizer(RANDOMIZER_ID_ADDRESS_RELAY).Write(hashAddr << 32).Write((GetTime() + hashAddr) / (24 * 60 * 60));
15291528
FastRandomContext insecure_rand;
15301529

1530+
// Relay reachable addresses to 2 peers. Unreachable addresses are relayed randomly to 1 or 2 peers.
1531+
unsigned int nRelayNodes = (fReachable || (hasher.Finalize() & 1)) ? 2 : 1;
1532+
15311533
std::array<std::pair<uint64_t, CNode*>,2> best{{{0, nullptr}, {0, nullptr}}};
15321534
assert(nRelayNodes <= best.size());
15331535

0 commit comments

Comments
 (0)