Skip to content

Commit

Permalink
Revert "WIP"
Browse files Browse the repository at this point in the history
  • Loading branch information
pwojcikdev committed Jan 15, 2024
1 parent 293ab36 commit acc1eca
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 30 deletions.
12 changes: 4 additions & 8 deletions nano/nano_node/daemon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ void nano::daemon::run (std::filesystem::path const & data_path, nano::node_flag
install_abort_signal_handler ();

std::filesystem::create_directories (data_path);

boost::system::error_code error_chmod;
nano::set_secure_perm_directory (data_path, error_chmod);

Expand All @@ -84,13 +83,10 @@ void nano::daemon::run (std::filesystem::path const & data_path, nano::node_flag
nano::nlogger nlogger{ log_config };

std::unique_ptr<nano::thread_runner> runner;

nano::network_params network_params{ nano::network_constants::active_network };
nano::daemon_config config{ data_path, network_params };
auto error = nano::read_node_config_toml (data_path, config, flags.config_overrides);

nano::set_use_memory_pools (config.node.use_memory_pools);

if (!error)
{
error = nano::flags_config_conflicts (flags, config.node);
Expand Down Expand Up @@ -139,7 +135,7 @@ void nano::daemon::run (std::filesystem::path const & data_path, nano::node_flag
config.node.peering_port = network_params.network.default_node_port;
}

auto node (std::make_shared<nano::node> (nlogger, io_ctx, data_path, config.node, opencl_work, flags));
auto node (std::make_shared<nano::node> (io_ctx, data_path, config.node, opencl_work, flags));
if (!node->init_error ())
{
auto network_label = node->network_params.network.get_current_network_as_string ();
Expand Down Expand Up @@ -178,7 +174,7 @@ void nano::daemon::run (std::filesystem::path const & data_path, nano::node_flag
io_ctx.stop ();
});
});
rpc = nano::get_rpc (nlogger, io_ctx, rpc_config, *rpc_handler);
rpc = nano::get_rpc (io_ctx, rpc_config, *rpc_handler);
rpc->start ();
}
else
Expand All @@ -196,7 +192,7 @@ void nano::daemon::run (std::filesystem::path const & data_path, nano::node_flag
}

debug_assert (!nano::signal_handler_impl);
nano::signal_handler_impl = [this, &io_ctx, &nlogger] () {
nano::signal_handler_impl = [this, &io_ctx] () {
nlogger.warn (nano::log::type::daemon, "Interrupt signal received, stopping...");

io_ctx.stop ();
Expand Down Expand Up @@ -240,7 +236,7 @@ void nano::daemon::run (std::filesystem::path const & data_path, nano::node_flag
}
else
{
nlogger.critical (nano::log::type::daemon, "Error deserializing node config: {}", error.get_message ());
nlogger.critical (nano::log::type::daemon, "Error deserializing config: {}", error.get_message ());
}

nano::log::info ("Daemon exiting...");
Expand Down
2 changes: 2 additions & 0 deletions nano/nano_node/daemon.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ class node_flags;

class daemon
{
nano::nlogger nlogger;

public:
void run (std::filesystem::path const &, nano::node_flags const & flags);
};
Expand Down
8 changes: 4 additions & 4 deletions nano/nano_node/entry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class address_library_pair
int main (int argc, char * const * argv)
{
nano::set_umask (); // Make sure the process umask is set before any files are created
nano::initialize_logging ();
nano::logging::initialize (nano::logging::config::cli_default ());

nano::node_singleton_memory_pool_purge_guard memory_pool_cleanup_guard;

Expand Down Expand Up @@ -613,7 +613,7 @@ int main (int argc, char * const * argv)
error |= device >= environment.platforms[platform].devices.size ();
if (!error)
{
nano::nlogger & nlogger = nano::default_logger ();
nano::nlogger nlogger;
nano::opencl_config config (platform, device, threads);
auto opencl (nano::opencl_work::create (true, config, nlogger, network_params.work));
nano::work_pool work_pool{ network_params.network, 0, std::chrono::nanoseconds (0), opencl ? [&opencl] (nano::work_version const version_a, nano::root const & root_a, uint64_t difficulty_a, std::atomic<int> &) {
Expand Down Expand Up @@ -1144,7 +1144,7 @@ int main (int argc, char * const * argv)
flags.disable_legacy_bootstrap = true;
flags.disable_wallet_bootstrap = true;
flags.disable_bootstrap_listener = true;
auto node1 (std::make_shared<nano::node> (nano::default_logger (), io_ctx1, path1, config1, work, flags, 0));
auto node1 (std::make_shared<nano::node> (io_ctx1, path1, config1, work, flags, 0));
nano::block_hash genesis_latest (node1->latest (nano::dev::genesis_key.pub));
nano::uint128_t genesis_balance (std::numeric_limits<nano::uint128_t>::max ());
// Generating blocks
Expand Down Expand Up @@ -1230,7 +1230,7 @@ int main (int argc, char * const * argv)
config2.active_elections_size = daemon_config.node.active_elections_size;
}

auto node2 (std::make_shared<nano::node> (nano::default_logger (), io_ctx2, path2, config2, work, flags, 1));
auto node2 (std::make_shared<nano::node> (io_ctx2, path2, config2, work, flags, 1));
node2->start ();
nano::thread_runner runner2 (io_ctx2, node2->config.io_threads);
std::cout << boost::str (boost::format ("Processing %1% blocks (test node)\n") % (count * 2));
Expand Down
10 changes: 5 additions & 5 deletions nano/node/node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,18 +133,18 @@ nano::keypair nano::load_or_create_node_id (std::filesystem::path const & applic
}
}

nano::node::node (nano::nlogger & nlogger_a, boost::asio::io_context & io_ctx_a, uint16_t peering_port_a, std::filesystem::path const & application_path_a, nano::work_pool & work_a, nano::node_flags flags_a, unsigned seq) :
node (nlogger_a, io_ctx_a, application_path_a, nano::node_config (peering_port_a), work_a, flags_a, seq)
nano::node::node (boost::asio::io_context & io_ctx_a, uint16_t peering_port_a, std::filesystem::path const & application_path_a, nano::work_pool & work_a, nano::node_flags flags_a, unsigned seq) :
node (io_ctx_a, application_path_a, nano::node_config (peering_port_a), work_a, flags_a, seq)
{
}

nano::node::node (nano::nlogger & nlogger_a, boost::asio::io_context & io_ctx_a, std::filesystem::path const & application_path_a, nano::node_config const & config_a, nano::work_pool & work_a, nano::node_flags flags_a, unsigned seq) :
nano::node::node (boost::asio::io_context & io_ctx_a, std::filesystem::path const & application_path_a, nano::node_config const & config_a, nano::work_pool & work_a, nano::node_flags flags_a, unsigned seq) :
write_database_queue (!flags_a.force_use_write_database_queue && (config_a.rocksdb_config.enable)),
nlogger{ nlogger_a },
io_ctx (io_ctx_a),
node_initialized_latch (1),
config (config_a),
network_params{ config.network_params },
nlogger{ config.logging },
stats (config.stats_config),
workers{ config.background_threads, nano::thread_role::name::worker },
bootstrap_workers{ config.bootstrap_serving_threads, nano::thread_role::name::bootstrap_worker },
Expand Down Expand Up @@ -1522,7 +1522,7 @@ nano::node_wrapper::node_wrapper (std::filesystem::path const & path_a, std::fil
auto & node_config = daemon_config.node;
node_config.peering_port = 24000;

node = std::make_shared<nano::node> (*nlogger, *io_context, path_a, node_config, work, node_flags_a);
node = std::make_shared<nano::node> (*io_context, path_a, node_config, work, node_flags_a);
}

nano::node_wrapper::~node_wrapper ()
Expand Down
7 changes: 3 additions & 4 deletions nano/node/node.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ outbound_bandwidth_limiter::config outbound_bandwidth_limiter_config (node_confi
class node final : public std::enable_shared_from_this<nano::node>
{
public:
node (nano::nlogger &, boost::asio::io_context &, uint16_t, std::filesystem::path const &, nano::work_pool &, nano::node_flags = nano::node_flags (), unsigned seq = 0);
node (nano::nlogger &, boost::asio::io_context &, std::filesystem::path const &, nano::node_config const &, nano::work_pool &, nano::node_flags = nano::node_flags (), unsigned seq = 0);
node (boost::asio::io_context &, uint16_t, std::filesystem::path const &, nano::work_pool &, nano::node_flags = nano::node_flags (), unsigned seq = 0);
node (boost::asio::io_context &, std::filesystem::path const &, nano::node_config const &, nano::work_pool &, nano::node_flags = nano::node_flags (), unsigned seq = 0);
~node ();

public:
Expand Down Expand Up @@ -141,11 +141,11 @@ class node final : public std::enable_shared_from_this<nano::node>

public:
nano::write_database_queue write_database_queue;
nano::nlogger & nlogger;
boost::asio::io_context & io_ctx;
boost::latch node_initialized_latch;
nano::node_config config;
nano::network_params & network_params;
nano::nlogger nlogger;
nano::stats stats;
nano::thread_pool workers;
nano::thread_pool bootstrap_workers;
Expand Down Expand Up @@ -243,7 +243,6 @@ class node_wrapper final

nano::network_params network_params;
std::shared_ptr<boost::asio::io_context> io_context;
std::shared_ptr<nano::nlogger> nlogger;
nano::work_pool work;
std::shared_ptr<nano::node> node;
};
Expand Down
7 changes: 3 additions & 4 deletions nano/rpc/rpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
#include <nano/rpc/rpc_secure.hpp>
#endif

nano::rpc::rpc (nano::nlogger & nlogger_a, boost::asio::io_context & io_ctx_a, nano::rpc_config config_a, nano::rpc_handler_interface & rpc_handler_interface_a) :
nlogger{ nlogger_a },
nano::rpc::rpc (boost::asio::io_context & io_ctx_a, nano::rpc_config config_a, nano::rpc_handler_interface & rpc_handler_interface_a) :
config (std::move (config_a)),
acceptor (io_ctx_a),
io_ctx (io_ctx_a),
Expand Down Expand Up @@ -79,7 +78,7 @@ void nano::rpc::stop ()
acceptor.close ();
}

std::unique_ptr<nano::rpc> nano::get_rpc (nano::nlogger & nlogger_a, boost::asio::io_context & io_ctx_a, nano::rpc_config const & config_a, nano::rpc_handler_interface & rpc_handler_interface_a)
std::unique_ptr<nano::rpc> nano::get_rpc (boost::asio::io_context & io_ctx_a, nano::rpc_config const & config_a, nano::rpc_handler_interface & rpc_handler_interface_a)
{
std::unique_ptr<rpc> impl;

Expand All @@ -91,7 +90,7 @@ std::unique_ptr<nano::rpc> nano::get_rpc (nano::nlogger & nlogger_a, boost::asio
}
else
{
impl = std::make_unique<rpc> (nlogger_a, io_ctx_a, config_a, rpc_handler_interface_a);
impl = std::make_unique<rpc> (io_ctx_a, config_a, rpc_handler_interface_a);
}

return impl;
Expand Down
7 changes: 3 additions & 4 deletions nano/rpc/rpc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class rpc_handler_interface;
class rpc
{
public:
rpc (nano::nlogger &, boost::asio::io_context & io_ctx_a, nano::rpc_config config_a, nano::rpc_handler_interface & rpc_handler_interface_a);
rpc (boost::asio::io_context & io_ctx_a, nano::rpc_config config_a, nano::rpc_handler_interface & rpc_handler_interface_a);
virtual ~rpc ();
void start ();
virtual void accept ();
Expand All @@ -31,8 +31,7 @@ class rpc
return acceptor.local_endpoint ().port ();
}

public:
nano::nlogger & nlogger;
nano::nlogger nlogger;
nano::rpc_config config;
boost::asio::ip::tcp::acceptor acceptor;
boost::asio::io_context & io_ctx;
Expand All @@ -41,5 +40,5 @@ class rpc
};

/** Returns the correct RPC implementation based on TLS configuration */
std::unique_ptr<nano::rpc> get_rpc (nano::nlogger &, boost::asio::io_context & io_ctx_a, nano::rpc_config const & config_a, nano::rpc_handler_interface & rpc_handler_interface_a);
std::unique_ptr<nano::rpc> get_rpc (boost::asio::io_context & io_ctx_a, nano::rpc_config const & config_a, nano::rpc_handler_interface & rpc_handler_interface_a);
}
3 changes: 2 additions & 1 deletion nano/secure/ledger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1559,12 +1559,13 @@ bool nano::ledger::migrate_lmdb_to_rocksdb (std::filesystem::path const & data_p
auto rockdb_data_path = data_path_a / "rocksdb";
std::filesystem::remove_all (rockdb_data_path);

nano::nlogger nlogger;
auto error (false);

// Open rocksdb database
nano::rocksdb_config rocksdb_config;
rocksdb_config.enable = true;
auto rocksdb_store = nano::make_store (nano::default_logger (), data_path_a, nano::dev::constants, false, true, rocksdb_config);
auto rocksdb_store = nano::make_store (nlogger, data_path_a, nano::dev::constants, false, true, rocksdb_config);

if (!rocksdb_store->init_error ())
{
Expand Down

0 comments on commit acc1eca

Please sign in to comment.