diff options
| author | tobtoht <tob@featherwallet.org> | 2026-04-22 20:32:57 +0000 |
|---|---|---|
| committer | tobtoht <tob@featherwallet.org> | 2026-04-22 20:32:57 +0000 |
| commit | 9d0c50fab5bd7373b636bca29611c78cf97f28d3 (patch) | |
| tree | 9588344eb939fd227206fe7829083a2d3b974c14 /src/cryptonote_core | |
| parent | b73668263df04a96c5bc812bbb5ca72f9b392a17 (diff) | |
| parent | 8a20fd2bc84d74917381fb50362b4d1a385256bd (diff) | |
| download | monzero-core-9d0c50fab5bd7373b636bca29611c78cf97f28d3.tar.gz monzero-core-9d0c50fab5bd7373b636bca29611c78cf97f28d3.tar.xz monzero-core-9d0c50fab5bd7373b636bca29611c78cf97f28d3.zip | |
Merge pull request #10444
8a20fd2 blockchain_utilities: fix --data-dir option (jeffro256)
Diffstat (limited to 'src/cryptonote_core')
| -rw-r--r-- | src/cryptonote_core/cryptonote_core.cpp | 14 | ||||
| -rw-r--r-- | src/cryptonote_core/cryptonote_core.h | 9 |
2 files changed, 20 insertions, 3 deletions
diff --git a/src/cryptonote_core/cryptonote_core.cpp b/src/cryptonote_core/cryptonote_core.cpp index 4bada999f..18625de98 100644 --- a/src/cryptonote_core/cryptonote_core.cpp +++ b/src/cryptonote_core/cryptonote_core.cpp @@ -346,13 +346,21 @@ namespace cryptonote BlockchainDB::init_options(desc); } //----------------------------------------------------------------------------------------------- + network_type core::get_network_type_from_args(const boost::program_options::variables_map& vm) + { + const bool testnet = command_line::get_arg(vm, arg_testnet_on); + const bool stagenet = command_line::get_arg(vm, arg_stagenet_on); + const bool regtest = command_line::get_arg(vm, arg_regtest_on); + if (testnet + stagenet + regtest > 1) + throw std::runtime_error("More than one network type argument was specified"); + return testnet ? TESTNET : stagenet ? STAGENET : regtest ? FAKECHAIN : MAINNET; + } + //----------------------------------------------------------------------------------------------- bool core::handle_command_line(const boost::program_options::variables_map& vm) { 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_nettype = get_network_type_from_args(vm); } m_config_folder = command_line::get_arg(vm, arg_data_dir); diff --git a/src/cryptonote_core/cryptonote_core.h b/src/cryptonote_core/cryptonote_core.h index 7806fe495..777de3319 100644 --- a/src/cryptonote_core/cryptonote_core.h +++ b/src/cryptonote_core/cryptonote_core.h @@ -277,6 +277,15 @@ namespace cryptonote static void init_options(boost::program_options::options_description& desc); /** + * @brief resolves the network type based on command line arguments + * @param vm variables map + * @return network type corresponding to arg_{testnet,stagenet,regtest}_on, defaulting to MAINNET + * @throw std::runtime_error if more than 1 of arg_{testnet,stagenet,regtest}_on is present + * @throw boost::bad_any_cast if arg_{testnet,stagenet,regtest}_on weren't added to vm + */ + static network_type get_network_type_from_args(const boost::program_options::variables_map& vm); + + /** * @brief initializes the core as needed * * This function initializes the transaction pool, the Blockchain, and |
