Skip to content

Commit

Permalink
Node flag to disable calling add_initial_peers function
Browse files Browse the repository at this point in the history
The add inital peers function reads the peers table and contacts all
the peers listed in it. It is called at startup.

To disable outgoing connections set:
--disable_rep_crawler and --disable_add_initial_peers
  • Loading branch information
dsiganos committed Sep 27, 2021
1 parent 96f1868 commit 65048c8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions nano/node/cli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ void nano::add_node_flag_options (boost::program_options::options_description &
{
// clang-format off
description_a.add_options()
("disable_add_initial_peers", "Disable contacting the peer in the peers table at startup")
("disable_backup", "Disable wallet automatic backups")
("disable_lazy_bootstrap", "Disables lazy bootstrap")
("disable_legacy_bootstrap", "Disables legacy bootstrap")
Expand Down Expand Up @@ -121,6 +122,7 @@ void nano::add_node_flag_options (boost::program_options::options_description &
std::error_code nano::update_flags (nano::node_flags & flags_a, boost::program_options::variables_map const & vm)
{
std::error_code ec;
flags_a.disable_add_initial_peers = (vm.count ("disable_add_initial_peers") > 0);
flags_a.disable_backup = (vm.count ("disable_backup") > 0);
flags_a.disable_lazy_bootstrap = (vm.count ("disable_lazy_bootstrap") > 0);
flags_a.disable_legacy_bootstrap = (vm.count ("disable_legacy_bootstrap") > 0);
Expand Down
6 changes: 6 additions & 0 deletions nano/node/node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1207,6 +1207,12 @@ boost::optional<uint64_t> nano::node::work_generate_blocking (nano::root const &

void nano::node::add_initial_peers ()
{
if (flags.disable_add_initial_peers)
{
logger.always_log ("Skipping add_initial_peers because disable_add_initial_peers is set");
return;
}

auto transaction (store.tx_begin_read ());
for (auto i (store.peer.begin (transaction)), n (store.peer.end ()); i != n; ++i)
{
Expand Down
1 change: 1 addition & 0 deletions nano/node/nodeconfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ class node_flags final
public:
std::vector<std::string> config_overrides;
std::vector<std::string> rpc_config_overrides;
bool disable_add_initial_peers{ false }; // For testing only
bool disable_backup{ false };
bool disable_lazy_bootstrap{ false };
bool disable_legacy_bootstrap{ false };
Expand Down

0 comments on commit 65048c8

Please sign in to comment.