diff --git a/nano/node/bootstrap.cpp b/nano/node/bootstrap.cpp index 6232f56761..e596428c1d 100644 --- a/nano/node/bootstrap.cpp +++ b/nano/node/bootstrap.cpp @@ -901,6 +901,7 @@ pulling (0), node (node_a), account_count (0), total_blocks (0), +runs_count (0), stopped (false), mode (nano::bootstrap_mode::legacy), lazy_stopped (0) @@ -1073,6 +1074,7 @@ void nano::bootstrap_attempt::run () { BOOST_LOG (node->log) << "Completed pulls"; request_push (lock); + runs_count++; // Start wallet lazy bootstrap if required if (!wallet_accounts.empty () && !node->flags.disable_wallet_bootstrap) { @@ -1082,7 +1084,7 @@ void nano::bootstrap_attempt::run () lock.lock (); } // Start lazy bootstrap if some lazy keys were inserted - else if (!lazy_finished () && !node->flags.disable_lazy_bootstrap) + else if (runs_count < 3 && !lazy_finished () && !node->flags.disable_lazy_bootstrap) { lock.unlock (); mode = nano::bootstrap_mode::lazy; @@ -1470,6 +1472,7 @@ void nano::bootstrap_attempt::lazy_run () { BOOST_LOG (node->log) << "Completed lazy pulls"; std::unique_lock lazy_lock (lazy_mutex); + runs_count++; // Start wallet lazy bootstrap if required if (!wallet_accounts.empty () && !node->flags.disable_wallet_bootstrap) { @@ -1482,7 +1485,7 @@ void nano::bootstrap_attempt::lazy_run () lock.lock (); } // Fallback to legacy bootstrap - else if (!lazy_keys.empty () && !node->flags.disable_legacy_bootstrap) + else if (runs_count < 3 && !lazy_keys.empty () && !node->flags.disable_legacy_bootstrap) { pulls.clear (); lazy_clear (); @@ -1714,6 +1717,7 @@ void nano::bootstrap_attempt::wallet_run () if (!stopped) { BOOST_LOG (node->log) << "Completed wallet lazy pulls"; + runs_count++; // Start lazy bootstrap if some lazy keys were inserted if (!lazy_finished ()) { diff --git a/nano/node/bootstrap.hpp b/nano/node/bootstrap.hpp index a34d009664..a87a36aba2 100644 --- a/nano/node/bootstrap.hpp +++ b/nano/node/bootstrap.hpp @@ -116,6 +116,7 @@ class bootstrap_attempt : public std::enable_shared_from_this std::shared_ptr node; std::atomic account_count; std::atomic total_blocks; + std::atomic runs_count; std::vector> bulk_push_targets; bool stopped; nano::bootstrap_mode mode; diff --git a/nano/node/rpc.cpp b/nano/node/rpc.cpp index 1f26f29771..f28eaf2a81 100644 --- a/nano/node/rpc.cpp +++ b/nano/node/rpc.cpp @@ -1392,6 +1392,7 @@ void nano::rpc_handler::bootstrap_status () response_l.put ("idle", std::to_string (attempt->idle.size ())); response_l.put ("target_connections", std::to_string (attempt->target_connections (attempt->pulls.size ()))); response_l.put ("total_blocks", std::to_string (attempt->total_blocks)); + response_l.put ("runs_count", std::to_string (attempt->runs_count)); std::string mode_text; if (attempt->mode == nano::bootstrap_mode::legacy) {