diff --git a/src/net_processing.cpp b/src/net_processing.cpp index 328a0cf04bb0d4..94404776dbfedf 100644 --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -1400,7 +1400,6 @@ bool static AlreadyHave(const CInv& inv) EXCLUSIVE_LOCKS_REQUIRED(cs_main) 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 @@ -1409,6 +1408,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,2> best{{{0, nullptr}, {0, nullptr}}}; assert(nRelayNodes <= best.size());