diff options
author | stoffu <stoffu@protonmail.ch> | 2018-02-16 20:04:04 +0900 |
---|---|---|
committer | stoffu <stoffu@protonmail.ch> | 2018-03-05 11:55:05 +0900 |
commit | af773211cbc620a1be54f517bd60e587d58a7e93 (patch) | |
tree | 40e747cbfc21c7182db27291fb29f9b033de2379 /src/p2p | |
parent | command_line: allow args to depend on more than one args (diff) | |
download | monero-af773211cbc620a1be54f517bd60e587d58a7e93.tar.xz |
Stagenet
Diffstat (limited to '')
-rw-r--r-- | src/p2p/net_node.cpp | 10 | ||||
-rw-r--r-- | src/p2p/net_node.h | 6 | ||||
-rw-r--r-- | src/p2p/net_node.inl | 36 |
3 files changed, 34 insertions, 18 deletions
diff --git a/src/p2p/net_node.cpp b/src/p2p/net_node.cpp index 170b79984..bde6fc88e 100644 --- a/src/p2p/net_node.cpp +++ b/src/p2p/net_node.cpp @@ -34,14 +34,16 @@ namespace nodetool { const command_line::arg_descriptor<std::string> arg_p2p_bind_ip = {"p2p-bind-ip", "Interface for p2p network protocol", "0.0.0.0"}; - const command_line::arg_descriptor<std::string, false, true> arg_p2p_bind_port = { + const command_line::arg_descriptor<std::string, false, true, 2> arg_p2p_bind_port = { "p2p-bind-port" , "Port for p2p network protocol" , std::to_string(config::P2P_DEFAULT_PORT) - , cryptonote::arg_testnet_on - , [](bool testnet, bool defaulted, std::string val) { - if (testnet && defaulted) + , {{ &cryptonote::arg_testnet_on, &cryptonote::arg_stagenet_on }} + , [](std::array<bool, 2> testnet_stagenet, bool defaulted, std::string val) { + if (testnet_stagenet[0] && defaulted) return std::to_string(config::testnet::P2P_DEFAULT_PORT); + else if (testnet_stagenet[1] && defaulted) + return std::to_string(config::stagenet::P2P_DEFAULT_PORT); return val; } }; diff --git a/src/p2p/net_node.h b/src/p2p/net_node.h index 54c474665..3010b43ad 100644 --- a/src/p2p/net_node.h +++ b/src/p2p/net_node.h @@ -223,7 +223,7 @@ namespace nodetool void cache_connect_fail_info(const epee::net_utils::network_address& addr); bool is_addr_recently_failed(const epee::net_utils::network_address& addr); bool is_priority_node(const epee::net_utils::network_address& na); - std::set<std::string> get_seed_nodes(bool testnet) const; + std::set<std::string> get_seed_nodes(cryptonote::network_type nettype) const; bool connect_to_seed(); template <class Container> @@ -331,13 +331,13 @@ namespace nodetool epee::critical_section m_host_fails_score_lock; std::map<std::string, uint64_t> m_host_fails_score; - bool m_testnet; + cryptonote::network_type m_nettype; }; const int64_t default_limit_up = 2048; const int64_t default_limit_down = 8192; extern const command_line::arg_descriptor<std::string> arg_p2p_bind_ip; - extern const command_line::arg_descriptor<std::string, false, true> arg_p2p_bind_port; + extern const command_line::arg_descriptor<std::string, false, true, 2> arg_p2p_bind_port; extern const command_line::arg_descriptor<uint32_t> arg_p2p_external_port; extern const command_line::arg_descriptor<bool> arg_p2p_allow_local_ip; extern const command_line::arg_descriptor<std::vector<std::string> > arg_p2p_add_peer; diff --git a/src/p2p/net_node.inl b/src/p2p/net_node.inl index 59b417d90..8ef240326 100644 --- a/src/p2p/net_node.inl +++ b/src/p2p/net_node.inl @@ -262,7 +262,10 @@ namespace nodetool const boost::program_options::variables_map& vm ) { - m_testnet = command_line::get_arg(vm, cryptonote::arg_testnet_on); + bool testnet = command_line::get_arg(vm, cryptonote::arg_testnet_on); + bool stagenet = command_line::get_arg(vm, cryptonote::arg_stagenet_on); + m_nettype = testnet ? cryptonote::TESTNET : stagenet ? cryptonote::STAGENET : cryptonote::MAINNET; + m_bind_ip = command_line::get_arg(vm, arg_p2p_bind_ip); m_port = command_line::get_arg(vm, arg_p2p_bind_port); m_external_port = command_line::get_arg(vm, arg_p2p_external_port); @@ -277,7 +280,7 @@ namespace nodetool { nodetool::peerlist_entry pe = AUTO_VAL_INIT(pe); pe.id = crypto::rand<uint64_t>(); - const uint16_t default_port = m_testnet ? ::config::testnet::P2P_DEFAULT_PORT : ::config::P2P_DEFAULT_PORT; + const uint16_t default_port = testnet ? ::config::testnet::P2P_DEFAULT_PORT : stagenet ? ::config::stagenet::P2P_DEFAULT_PORT : ::config::P2P_DEFAULT_PORT; bool r = parse_peer_from_string(pe.adr, pr_str, default_port); CHECK_AND_ASSERT_MES(r, false, "Failed to parse address from string: " << pr_str); m_command_line_peers.push_back(pe); @@ -370,10 +373,10 @@ namespace nodetool //----------------------------------------------------------------------------------- template<class t_payload_net_handler> - std::set<std::string> node_server<t_payload_net_handler>::get_seed_nodes(bool testnet) const + std::set<std::string> node_server<t_payload_net_handler>::get_seed_nodes(cryptonote::network_type nettype) const { std::set<std::string> full_addrs; - if (testnet) + if (nettype == cryptonote::TESTNET) { full_addrs.insert("212.83.175.67:28080"); full_addrs.insert("5.9.100.248:28080"); @@ -381,6 +384,11 @@ namespace nodetool full_addrs.insert("195.154.123.123:28080"); full_addrs.insert("212.83.172.165:28080"); } + else if (nettype == cryptonote::STAGENET) + { + full_addrs.insert("162.210.173.150:38080"); + full_addrs.insert("162.210.173.151:38080"); + } else { full_addrs.insert("107.152.130.98:18080"); @@ -404,10 +412,15 @@ namespace nodetool bool res = handle_command_line(vm); CHECK_AND_ASSERT_MES(res, false, "Failed to handle command line"); - if (m_testnet) + if (m_nettype == cryptonote::TESTNET) { memcpy(&m_network_id, &::config::testnet::NETWORK_ID, 16); - full_addrs = get_seed_nodes(true); + full_addrs = get_seed_nodes(cryptonote::TESTNET); + } + else if (m_nettype == cryptonote::STAGENET) + { + memcpy(&m_network_id, &::config::stagenet::NETWORK_ID, 16); + full_addrs = get_seed_nodes(cryptonote::STAGENET); } else if (m_exclusive_peers.empty()) { @@ -488,7 +501,7 @@ namespace nodetool else MINFO("Not enough DNS seed nodes found, using fallback defaults too"); - for (const auto &peer: get_seed_nodes(false)) + for (const auto &peer: get_seed_nodes(cryptonote::MAINNET)) full_addrs.insert(peer); } } @@ -502,8 +515,9 @@ namespace nodetool m_config_folder = command_line::get_arg(vm, cryptonote::arg_data_dir); - if ((!m_testnet && m_port != std::to_string(::config::P2P_DEFAULT_PORT)) - || (m_testnet && m_port != std::to_string(::config::testnet::P2P_DEFAULT_PORT))) { + if ((m_nettype == cryptonote::MAINNET && m_port != std::to_string(::config::P2P_DEFAULT_PORT)) + || (m_nettype == cryptonote::TESTNET && m_port != std::to_string(::config::testnet::P2P_DEFAULT_PORT)) + || (m_nettype == cryptonote::STAGENET && m_port != std::to_string(::config::stagenet::P2P_DEFAULT_PORT))) { m_config_folder = m_config_folder + "/" + m_port; } @@ -1137,7 +1151,7 @@ namespace nodetool if (!fallback_nodes_added) { MWARNING("Failed to connect to any of seed peers, trying fallback seeds"); - for (const auto &peer: get_seed_nodes(m_testnet)) + for (const auto &peer: get_seed_nodes(m_nettype)) { MDEBUG("Fallback seed node: " << peer); append_net_address(m_seed_nodes, peer); @@ -1797,7 +1811,7 @@ namespace nodetool for(const std::string& pr_str: perrs) { epee::net_utils::network_address na = AUTO_VAL_INIT(na); - const uint16_t default_port = m_testnet ? ::config::testnet::P2P_DEFAULT_PORT : ::config::P2P_DEFAULT_PORT; + const uint16_t default_port = m_nettype == cryptonote::TESTNET ? ::config::testnet::P2P_DEFAULT_PORT : m_nettype == cryptonote::STAGENET ? ::config::stagenet::P2P_DEFAULT_PORT : ::config::P2P_DEFAULT_PORT; bool r = parse_peer_from_string(na, pr_str, default_port); CHECK_AND_ASSERT_MES(r, false, "Failed to parse address from string: " << pr_str); container.push_back(na); |