diff options
Diffstat (limited to 'src/cryptonote_core/cryptonote_core.cpp')
| -rw-r--r-- | src/cryptonote_core/cryptonote_core.cpp | 43 |
1 files changed, 29 insertions, 14 deletions
diff --git a/src/cryptonote_core/cryptonote_core.cpp b/src/cryptonote_core/cryptonote_core.cpp index 8b837f2e4..8c0118803 100644 --- a/src/cryptonote_core/cryptonote_core.cpp +++ b/src/cryptonote_core/cryptonote_core.cpp @@ -71,14 +71,21 @@ namespace cryptonote , "Run on testnet. The wallet must be launched with --testnet flag." , false }; - const command_line::arg_descriptor<std::string, false, true> arg_data_dir = { + const command_line::arg_descriptor<bool, false> arg_stagenet_on = { + "stagenet" + , "Run on stagenet. The wallet must be launched with --stagenet flag." + , false + }; + const command_line::arg_descriptor<std::string, false, true, 2> arg_data_dir = { "data-dir" , "Specify data directory" , tools::get_default_data_dir() - , arg_testnet_on - , [](bool testnet, bool defaulted, std::string val) { - if (testnet) + , {{ &arg_testnet_on, &arg_stagenet_on }} + , [](std::array<bool, 2> testnet_stagenet, bool defaulted, std::string val) { + if (testnet_stagenet[0]) return (boost::filesystem::path(val) / "testnet").string(); + else if (testnet_stagenet[1]) + return (boost::filesystem::path(val) / "stagenet").string(); return val; } }; @@ -194,7 +201,7 @@ namespace cryptonote //----------------------------------------------------------------------------------------------- bool core::update_checkpoints() { - if (m_testnet || m_fakechain || m_disable_dns_checkpoints) return true; + if (m_nettype != MAINNET || m_disable_dns_checkpoints) return true; if (m_checkpoints_updating.test_and_set()) return true; @@ -243,6 +250,7 @@ namespace cryptonote command_line::add_arg(desc, arg_test_drop_download_height); command_line::add_arg(desc, arg_testnet_on); + command_line::add_arg(desc, arg_stagenet_on); command_line::add_arg(desc, arg_dns_checkpoints); command_line::add_arg(desc, arg_prep_blocks_threads); command_line::add_arg(desc, arg_fast_block_sync); @@ -262,16 +270,21 @@ namespace cryptonote //----------------------------------------------------------------------------------------------- bool core::handle_command_line(const boost::program_options::variables_map& vm) { - m_testnet = command_line::get_arg(vm, arg_testnet_on); + if (m_nettype != FAKECHAIN) + { + const bool testnet = command_line::get_arg(vm, arg_testnet_on); + const bool stagenet = command_line::get_arg(vm, arg_stagenet_on); + m_nettype = testnet ? TESTNET : stagenet ? STAGENET : MAINNET; + } m_config_folder = command_line::get_arg(vm, arg_data_dir); auto data_dir = boost::filesystem::path(m_config_folder); - if (!m_testnet && !m_fakechain) + if (m_nettype == MAINNET) { cryptonote::checkpoints checkpoints; - if (!checkpoints.init_default_checkpoints(m_testnet)) + if (!checkpoints.init_default_checkpoints(m_nettype)) { throw std::runtime_error("Failed to initialize checkpoints"); } @@ -360,9 +373,11 @@ namespace cryptonote { start_time = std::time(nullptr); - m_fakechain = test_options != NULL; + if (test_options != NULL) + { + m_nettype = FAKECHAIN; + } bool r = handle_command_line(vm); - bool testnet = command_line::get_arg(vm, arg_testnet_on); std::string m_config_folder_mempool = m_config_folder; if (config_subdir) @@ -377,7 +392,7 @@ namespace cryptonote size_t max_txpool_size = command_line::get_arg(vm, arg_max_txpool_size); boost::filesystem::path folder(m_config_folder); - if (m_fakechain) + if (m_nettype == FAKECHAIN) folder /= "fake"; // make sure the data directory exists, and try to lock it @@ -491,7 +506,7 @@ namespace cryptonote m_blockchain_storage.set_user_options(blocks_threads, blocks_per_sync, sync_mode, fast_sync); - r = m_blockchain_storage.init(db.release(), m_testnet, m_offline, test_options); + r = m_blockchain_storage.init(db.release(), m_nettype, m_offline, test_options); r = m_mempool.init(max_txpool_size); CHECK_AND_ASSERT_MES(r, false, "Failed to initialize memory pool"); @@ -526,7 +541,7 @@ namespace cryptonote return false; } - r = m_miner.init(vm, m_testnet); + r = m_miner.init(vm, m_nettype); CHECK_AND_ASSERT_MES(r, false, "Failed to initialize miner instance"); return load_state_data(); @@ -909,7 +924,7 @@ namespace cryptonote //----------------------------------------------------------------------------------------------- size_t core::get_block_sync_size(uint64_t height) const { - static const uint64_t quick_height = m_testnet ? 801219 : 1220516; + static const uint64_t quick_height = m_nettype == TESTNET ? 801219 : m_nettype == MAINNET ? 1220516 : 0; if (block_sync_size > 0) return block_sync_size; if (height >= quick_height) |
