File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -134,6 +134,8 @@ static const unsigned int NODE_NETWORK_LIMITED_MIN_BLOCKS = 288;
134
134
static constexpr auto AVG_LOCAL_ADDRESS_BROADCAST_INTERVAL{24h};
135
135
/* * Average delay between peer address broadcasts */
136
136
static constexpr auto AVG_ADDRESS_BROADCAST_INTERVAL{30s};
137
+ /* * Delay between rotating the peers we relay a particular address to */
138
+ static constexpr auto ROTATE_ADDR_RELAY_DEST_INTERVAL{24h};
137
139
/* * Average delay between trickled inventory transmissions for inbound peers.
138
140
* Blocks and peers with NetPermissionFlags::NoBan permission bypass this. */
139
141
static constexpr auto INBOUND_INVENTORY_BROADCAST_INTERVAL{5s};
@@ -1776,9 +1778,12 @@ void PeerManagerImpl::RelayAddress(NodeId originator,
1776
1778
// Use deterministic randomness to send to the same nodes for 24 hours
1777
1779
// at a time so the m_addr_knowns of the chosen nodes prevent repeats
1778
1780
const uint64_t hash_addr{CServiceHash (0 , 0 )(addr)};
1781
+ const auto current_time{GetTime<std::chrono::seconds>()};
1782
+ // Adding address hash makes exact rotation time different per address, while preserving periodicity.
1783
+ const uint64_t time_addr{(static_cast <uint64_t >(count_seconds (current_time)) + hash_addr) / count_seconds (ROTATE_ADDR_RELAY_DEST_INTERVAL)};
1779
1784
const CSipHasher hasher{m_connman.GetDeterministicRandomizer (RANDOMIZER_ID_ADDRESS_RELAY)
1780
1785
.Write (hash_addr)
1781
- .Write (( GetTime () + hash_addr) / ( 24 * 60 * 60 ) )};
1786
+ .Write (time_addr )};
1782
1787
FastRandomContext insecure_rand;
1783
1788
1784
1789
// Relay reachable addresses to 2 peers. Unreachable addresses are relayed randomly to 1 or 2 peers.
You can’t perform that action at this time.
0 commit comments