Skip to content

Commit ec7ba72

Browse files
Increase the number of addresses to share when responding to peers.
Start sending peer addresses from a randomized starting offset instead of the start of our known addresses.
1 parent fb8b041 commit ec7ba72

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

src/hosts.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,14 +104,17 @@ code hosts::fetch(address::list& out) const
104104
return error::not_found;
105105

106106
const auto out_count = std::min(buffer_.size(), capacity_) /
107-
static_cast<size_t>(pseudo_random::next(1, 20));
107+
static_cast<size_t>(pseudo_random::next(5, 10));
108108

109109
if (out_count == 0)
110110
return error::success;
111111

112+
const auto limit = buffer_.size() - 1;
113+
auto index = static_cast<size_t>(pseudo_random::next(0, limit));
114+
112115
out.reserve(out_count);
113-
for (size_t index = 0; index < out_count; ++index)
114-
out.push_back(buffer_[index]);
116+
for (size_t count = 0; count < out_count; ++count)
117+
out.push_back(buffer_[index++ % limit]);
115118
}
116119
///////////////////////////////////////////////////////////////////////////
117120

0 commit comments

Comments
 (0)