Navigation Menu

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reinstate preconfigured keepalives #1854

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions nano/node/node.cpp
Expand Up @@ -101,10 +101,10 @@ void nano::network::send_keepalive (nano::transport::channel const & channel_a)
channel_a.send (message);
}

void nano::node::keepalive (std::string const & address_a, uint16_t port_a, bool preconfigured_peer_a)
void nano::node::keepalive (std::string const & address_a, uint16_t port_a)
{
auto node_l (shared_from_this ());
network.resolver.async_resolve (boost::asio::ip::udp::resolver::query (address_a, std::to_string (port_a)), [node_l, address_a, port_a, preconfigured_peer_a](boost::system::error_code const & ec, boost::asio::ip::udp::resolver::iterator i_a) {
network.resolver.async_resolve (boost::asio::ip::udp::resolver::query (address_a, std::to_string (port_a)), [node_l, address_a, port_a](boost::system::error_code const & ec, boost::asio::ip::udp::resolver::iterator i_a) {
if (!ec)
{
for (auto i (i_a), n (boost::asio::ip::udp::resolver::iterator{}); i != n; ++i)
Expand Down Expand Up @@ -1597,7 +1597,7 @@ void nano::node::keepalive_preconfigured (std::vector<std::string> const & peers
{
for (auto i (peers_a.begin ()), n (peers_a.end ()); i != n; ++i)
{
keepalive (*i, network_params.default_node_port, true);
keepalive (*i, network_params.default_node_port);
}
}

Expand Down
2 changes: 1 addition & 1 deletion nano/node/node.hpp
Expand Up @@ -435,7 +435,7 @@ class node : public std::enable_shared_from_this<nano::node>
alarm.io_ctx.post (action_a);
}
bool copy_with_compaction (boost::filesystem::path const &);
void keepalive (std::string const &, uint16_t, bool = false);
void keepalive (std::string const &, uint16_t);
void start ();
void stop ();
std::shared_ptr<nano::node> shared ();
Expand Down
8 changes: 7 additions & 1 deletion nano/node/repcrawler.cpp
Expand Up @@ -36,8 +36,14 @@ void nano::rep_crawler::ongoing_crawl ()
{
auto now (std::chrono::steady_clock::now ());
query (get_crawl_targets ());
auto sufficient_weight (total_weight_internal () > node.config.online_weight_minimum.number ());
// If online weight drops below minimum, reach out to preconfigured peers
if (!sufficient_weight)
{
node.keepalive_preconfigured (node.config.preconfigured_peers);
}
// Reduce crawl frequency when there's enough total peer weight
unsigned next_run_seconds = (total_weight_internal () > node.config.online_weight_minimum.number ()) ? 7 : 3;
unsigned next_run_seconds = sufficient_weight ? 7 : 3;
std::weak_ptr<nano::node> node_w (node.shared ());
node.alarm.add (now + std::chrono::seconds (next_run_seconds), [node_w, this]() {
if (auto node_l = node_w.lock ())
Expand Down