aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/common/command_line.cpp1
-rw-r--r--src/common/command_line.h1
-rw-r--r--src/cryptonote_core/cryptonote_core.cpp7
-rw-r--r--src/cryptonote_core/cryptonote_core.h2
-rw-r--r--src/daemon/daemon.cpp64
5 files changed, 44 insertions, 31 deletions
diff --git a/src/common/command_line.cpp b/src/common/command_line.cpp
index 6f831af55..a2e7faf9f 100644
--- a/src/common/command_line.cpp
+++ b/src/common/command_line.cpp
@@ -47,4 +47,5 @@ namespace command_line
const arg_descriptor<bool> arg_help = {"help", "Produce help message"};
const arg_descriptor<bool> arg_version = {"version", "Output version information"};
const arg_descriptor<std::string> arg_data_dir = {"data-dir", "Specify data directory"};
+ const arg_descriptor<std::string> arg_testnet_data_dir = {"testnet-data-dir", "Specify testnet data directory"};
}
diff --git a/src/common/command_line.h b/src/common/command_line.h
index ca02c6088..09ae877d3 100644
--- a/src/common/command_line.h
+++ b/src/common/command_line.h
@@ -203,4 +203,5 @@ namespace command_line
extern const arg_descriptor<bool> arg_help;
extern const arg_descriptor<bool> arg_version;
extern const arg_descriptor<std::string> arg_data_dir;
+ extern const arg_descriptor<std::string> arg_testnet_data_dir;
}
diff --git a/src/cryptonote_core/cryptonote_core.cpp b/src/cryptonote_core/cryptonote_core.cpp
index 3ff139c95..72e5ee209 100644
--- a/src/cryptonote_core/cryptonote_core.cpp
+++ b/src/cryptonote_core/cryptonote_core.cpp
@@ -75,9 +75,10 @@ namespace cryptonote
{
}
//-----------------------------------------------------------------------------------------------
- bool core::handle_command_line(const boost::program_options::variables_map& vm)
+ bool core::handle_command_line(const boost::program_options::variables_map& vm, bool testnet)
{
- m_config_folder = command_line::get_arg(vm, command_line::arg_data_dir);
+ auto data_dir_arg = testnet ? command_line::arg_testnet_data_dir : command_line::arg_data_dir;
+ m_config_folder = command_line::get_arg(vm, data_dir_arg);
return true;
}
//-----------------------------------------------------------------------------------------------
@@ -118,7 +119,7 @@ namespace cryptonote
//-----------------------------------------------------------------------------------------------
bool core::init(const boost::program_options::variables_map& vm, bool testnet)
{
- bool r = handle_command_line(vm);
+ bool r = handle_command_line(vm, testnet);
r = m_mempool.init(m_config_folder);
CHECK_AND_ASSERT_MES(r, false, "Failed to initialize memory pool");
diff --git a/src/cryptonote_core/cryptonote_core.h b/src/cryptonote_core/cryptonote_core.h
index f050431ef..ba2aed015 100644
--- a/src/cryptonote_core/cryptonote_core.h
+++ b/src/cryptonote_core/cryptonote_core.h
@@ -136,7 +136,7 @@ namespace cryptonote
bool check_tx_ring_signature(const txin_to_key& tx, const crypto::hash& tx_prefix_hash, const std::vector<crypto::signature>& sig);
bool is_tx_spendtime_unlocked(uint64_t unlock_time);
bool update_miner_block_template();
- bool handle_command_line(const boost::program_options::variables_map& vm);
+ bool handle_command_line(const boost::program_options::variables_map& vm, bool testnet);
bool on_update_blocktemplate_interval();
bool check_tx_inputs_keyimages_diff(const transaction& tx);
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 {