Skip to content

Commit f334644

Browse files
Fix bug that limits host_pool_capacity configuration to the protocol
defined max_address value of 1000. Instead we should honor the configuration setting and ensure that we do not send more than max_address at a time.
1 parent ec7ba72 commit f334644

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

src/hosts.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ using namespace bc::config;
3434

3535
// TODO: change to network_address bimap hash table with services and age.
3636
hosts::hosts(const settings& settings)
37-
: capacity_(std::min(max_address, static_cast<size_t>(
38-
settings.host_pool_capacity))),
37+
: capacity_(static_cast<size_t>(settings.host_pool_capacity)),
3938
buffer_(std::max(capacity_, static_cast<size_t>(1u))),
4039
stopped_(true),
4140
file_path_(settings.hosts_file),
@@ -103,8 +102,8 @@ code hosts::fetch(address::list& out) const
103102
if (buffer_.empty())
104103
return error::not_found;
105104

106-
const auto out_count = std::min(buffer_.size(), capacity_) /
107-
static_cast<size_t>(pseudo_random::next(5, 10));
105+
const auto out_count = std::min(max_address, std::min(buffer_.size(),
106+
capacity_) / static_cast<size_t>(pseudo_random::next(5, 10)));
108107

109108
if (out_count == 0)
110109
return error::success;

0 commit comments

Comments
 (0)