diff options
Diffstat (limited to 'src/daemon/daemon.cpp')
-rw-r--r-- | src/daemon/daemon.cpp | 64 |
1 files changed, 37 insertions, 27 deletions
diff --git a/src/daemon/daemon.cpp b/src/daemon/daemon.cpp index 113b2c5dc..9102e61e8 100644 --- a/src/daemon/daemon.cpp +++ b/src/daemon/daemon.cpp @@ -63,8 +63,11 @@ namespace const command_line::arg_descriptor<std::string> arg_log_file = {"log-file", "", ""}; const command_line::arg_descriptor<int> arg_log_level = {"log-level", "", LOG_LEVEL_0}; const command_line::arg_descriptor<bool> arg_console = {"no-console", "Disable daemon console commands"}; - const command_line::arg_descriptor<bool> arg_testnet_on = {"testnet", "Used to deploy test nets. Checkpoints and hardcoded seeds are ignored, " - "network id is changed. Use it with --data-dir flag. The wallet must be launched with --testnet flag.", false}; + const command_line::arg_descriptor<bool> arg_testnet_on = { + "testnet" + , "Run on testnet. The wallet must be launched with --testnet flag." + , false + }; } bool command_line_preprocessor(const boost::program_options::variables_map& vm) @@ -113,6 +116,9 @@ int main(int argc, char* argv[]) TRY_ENTRY(); + boost::filesystem::path default_data_path {tools::get_default_data_dir()}; + boost::filesystem::path default_testnet_data_path {default_data_path / "testnet"}; + po::options_description desc_cmd_only("Command line options"); po::options_description desc_cmd_sett("Command line options and settings options"); @@ -120,7 +126,8 @@ int main(int argc, char* argv[]) command_line::add_arg(desc_cmd_only, command_line::arg_version); command_line::add_arg(desc_cmd_only, arg_os_version); // tools::get_default_data_dir() can't be called during static initialization - command_line::add_arg(desc_cmd_only, command_line::arg_data_dir, tools::get_default_data_dir()); + command_line::add_arg(desc_cmd_only, command_line::arg_data_dir, default_data_path.string()); + command_line::add_arg(desc_cmd_only, command_line::arg_testnet_data_dir, default_testnet_data_path.string()); command_line::add_arg(desc_cmd_only, arg_config_file); command_line::add_arg(desc_cmd_sett, arg_log_file); @@ -140,29 +147,6 @@ int main(int argc, char* argv[]) bool r = command_line::handle_error_helper(desc_options, [&]() { po::store(po::parse_command_line(argc, argv, desc_options), vm); - - if (command_line::get_arg(vm, command_line::arg_help)) - { - std::cout << CRYPTONOTE_NAME << " v" << MONERO_VERSION_FULL << ENDL << ENDL; - std::cout << desc_options << std::endl; - return false; - } - - std::string data_dir = command_line::get_arg(vm, command_line::arg_data_dir); - std::string config = command_line::get_arg(vm, arg_config_file); - - boost::filesystem::path data_dir_path(data_dir); - boost::filesystem::path config_path(config); - if (!config_path.has_parent_path()) - { - config_path = data_dir_path / config_path; - } - - boost::system::error_code ec; - if (boost::filesystem::exists(config_path, ec)) - { - po::store(po::parse_config_file<char>(config_path.string<std::string>().c_str(), desc_cmd_sett), vm); - } po::notify(vm); return true; @@ -170,6 +154,33 @@ int main(int argc, char* argv[]) if (!r) return 1; + if (command_line::get_arg(vm, command_line::arg_help)) + { + std::cout << CRYPTONOTE_NAME << " v" << PROJECT_VERSION_LONG << ENDL << ENDL; + std::cout << desc_options << std::endl; + return false; + } + + bool testnet_mode = command_line::get_arg(vm, arg_testnet_on); + + auto data_dir_arg = testnet_mode ? command_line::arg_testnet_data_dir : command_line::arg_data_dir; + + std::string data_dir = command_line::get_arg(vm, data_dir_arg); + std::string config = command_line::get_arg(vm, arg_config_file); + + boost::filesystem::path data_dir_path(data_dir); + boost::filesystem::path config_path(config); + if (!config_path.has_parent_path()) + { + config_path = data_dir_path / config_path; + } + + boost::system::error_code ec; + if (boost::filesystem::exists(config_path, ec)) + { + po::store(po::parse_config_file<char>(config_path.string<std::string>().c_str(), desc_cmd_sett), vm); + } + //set up logging options boost::filesystem::path log_file_path(command_line::get_arg(vm, arg_log_file)); if (log_file_path.empty()) @@ -195,7 +206,6 @@ int main(int argc, char* argv[]) //create objects and link them cryptonote::core ccore(NULL); - bool testnet_mode = command_line::get_arg(vm, arg_testnet_on); if (testnet_mode) { LOG_PRINT_L0("Starting in testnet mode!"); } else { |