forked from nanocurrency/nano-node
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move inactive_node and node_wrapper into their own files
- Loading branch information
Showing
12 changed files
with
136 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#include <nano/node/active_transactions.hpp> | ||
#include <nano/node/inactive_node.hpp> | ||
#include <nano/node/node.hpp> | ||
|
||
nano::inactive_node::inactive_node (std::filesystem::path const & path_a, std::filesystem::path const & config_path_a, nano::node_flags const & node_flags_a) : | ||
node_wrapper (path_a, config_path_a, node_flags_a), | ||
node (node_wrapper.node) | ||
{ | ||
node_wrapper.node->active.stop (); | ||
} | ||
|
||
nano::inactive_node::inactive_node (std::filesystem::path const & path_a, nano::node_flags const & node_flags_a) : | ||
inactive_node (path_a, path_a, node_flags_a) | ||
{ | ||
} | ||
|
||
nano::node_flags const & nano::inactive_node_flag_defaults () | ||
{ | ||
static nano::node_flags node_flags; | ||
node_flags.inactive_node = true; | ||
node_flags.read_only = true; | ||
node_flags.generate_cache.reps = false; | ||
node_flags.generate_cache.cemented_count = false; | ||
node_flags.generate_cache.unchecked_count = false; | ||
node_flags.generate_cache.account_count = false; | ||
node_flags.disable_bootstrap_listener = true; | ||
node_flags.disable_tcp_realtime = true; | ||
return node_flags; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#pragma once | ||
|
||
#include <nano/node/node_wrapper.hpp> | ||
|
||
#include <boost/program_options/variables_map.hpp> | ||
|
||
#include <filesystem> | ||
|
||
namespace nano | ||
{ | ||
|
||
class node; | ||
class node_flags; | ||
|
||
class inactive_node final | ||
{ | ||
public: | ||
inactive_node (std::filesystem::path const & path_a, nano::node_flags const & node_flags_a); | ||
inactive_node (std::filesystem::path const & path_a, std::filesystem::path const & config_path_a, nano::node_flags const & node_flags_a); | ||
|
||
nano::node_wrapper node_wrapper; | ||
std::shared_ptr<nano::node> node; | ||
}; | ||
|
||
std::unique_ptr<nano::inactive_node> default_inactive_node (std::filesystem::path const &, boost::program_options::variables_map const &); | ||
|
||
} // namespace nano |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#include <nano/node/daemonconfig.hpp> | ||
#include <nano/node/node.hpp> | ||
#include <nano/node/node_wrapper.hpp> | ||
|
||
nano::node_wrapper::node_wrapper (std::filesystem::path const & path_a, std::filesystem::path const & config_path_a, nano::node_flags const & node_flags_a) : | ||
network_params{ nano::network_constants::active_network }, | ||
io_context (std::make_shared<boost::asio::io_context> ()), | ||
work{ network_params.network, 1 } | ||
{ | ||
/* | ||
* @warning May throw a filesystem exception | ||
*/ | ||
std::filesystem::create_directories (path_a); | ||
|
||
boost::system::error_code error_chmod; | ||
nano::set_secure_perm_directory (path_a, error_chmod); | ||
|
||
nano::daemon_config daemon_config{ path_a, network_params }; | ||
auto error = nano::read_node_config_toml (config_path_a, daemon_config, node_flags_a.config_overrides); | ||
if (error) | ||
{ | ||
std::cerr << "Error deserializing config file"; | ||
if (!node_flags_a.config_overrides.empty ()) | ||
{ | ||
std::cerr << " or --config option"; | ||
} | ||
std::cerr << "\n" | ||
<< error.get_message () << std::endl; | ||
std::exit (1); | ||
} | ||
|
||
auto & node_config = daemon_config.node; | ||
node_config.peering_port = 24000; | ||
|
||
node = std::make_shared<nano::node> (io_context, path_a, node_config, work, node_flags_a); | ||
} | ||
|
||
nano::node_wrapper::~node_wrapper () | ||
{ | ||
node->stop (); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#pragma once | ||
|
||
#include <nano/lib/work.hpp> | ||
#include <nano/secure/common.hpp> | ||
|
||
#include <boost/asio/io_context.hpp> | ||
|
||
#include <filesystem> | ||
|
||
namespace nano | ||
{ | ||
|
||
class node; | ||
class node_flags; | ||
|
||
class node_wrapper final | ||
{ | ||
public: | ||
node_wrapper (std::filesystem::path const & path_a, std::filesystem::path const & config_path_a, nano::node_flags const & node_flags_a); | ||
~node_wrapper (); | ||
|
||
nano::network_params network_params; | ||
std::shared_ptr<boost::asio::io_context> io_context; | ||
nano::work_pool work; | ||
std::shared_ptr<nano::node> node; | ||
}; | ||
|
||
} |