Skip to content

Commit

Permalink
Increase the ip address relay branching factor for unreachable networks
Browse files Browse the repository at this point in the history
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.

Github-Pull: bitcoin#19728
Rebased-From: 86d4cf4
  • Loading branch information
sipa authored and luke-jr committed Aug 15, 2020
1 parent 9828f9a commit 3116771
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/net_processing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -930,7 +930,6 @@ static void RelayTransaction(const CTransaction& tx, CConnman& connman)

static void RelayAddress(const CAddress& addr, bool fReachable, 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
Expand All @@ -939,6 +938,9 @@ static void RelayAddress(const CAddress& addr, bool fReachable, CConnman& connma
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());

Expand Down

0 comments on commit 3116771

Please sign in to comment.