aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorZachary Michaels <mikezackles@gmail.com>2014-09-08 13:07:15 -0400
committerRiccardo Spagni <ric@spagni.net>2014-09-15 15:53:46 +0200
commit658b6690a36f6f0b3b06dca5b85021b2b344c059 (patch)
tree97c9b51aeb1dbfa759f1c6458c2e8dc57e0a55d8 /src
parentSeparate p2p port for testnet (diff)
downloadmonero-658b6690a36f6f0b3b06dca5b85021b2b344c059.tar.xz
Separate rpc port for testnet
Diffstat (limited to 'src')
-rw-r--r--src/daemon/daemon.cpp2
-rw-r--r--src/rpc/core_rpc_server.cpp28
-rw-r--r--src/rpc/core_rpc_server.h10
-rw-r--r--src/simplewallet/simplewallet.cpp10
-rw-r--r--src/wallet/wallet2.cpp6
5 files changed, 44 insertions, 12 deletions
diff --git a/src/daemon/daemon.cpp b/src/daemon/daemon.cpp
index 1041aa439..04f6db4fa 100644
--- a/src/daemon/daemon.cpp
+++ b/src/daemon/daemon.cpp
@@ -220,7 +220,7 @@ int main(int argc, char* argv[])
LOG_PRINT_L0("Protocol initialized OK");
LOG_PRINT_L0("Initializing core RPC server...");
- res = rpc_server.init(vm);
+ res = rpc_server.init(vm, testnet_mode);
CHECK_AND_ASSERT_MES(res, 1, "Failed to initialize core RPC server.");
LOG_PRINT_GREEN("Core RPC server initialized OK on port: " << rpc_server.get_binded_port(), LOG_LEVEL_0);
diff --git a/src/rpc/core_rpc_server.cpp b/src/rpc/core_rpc_server.cpp
index e99f44929..197e4ff83 100644
--- a/src/rpc/core_rpc_server.cpp
+++ b/src/rpc/core_rpc_server.cpp
@@ -46,7 +46,16 @@ namespace cryptonote
namespace
{
const command_line::arg_descriptor<std::string> arg_rpc_bind_ip = {"rpc-bind-ip", "", "127.0.0.1"};
- const command_line::arg_descriptor<std::string> arg_rpc_bind_port = {"rpc-bind-port", "", std::to_string(config::RPC_DEFAULT_PORT)};
+ const command_line::arg_descriptor<std::string> arg_rpc_bind_port = {
+ "rpc-bind-port"
+ , ""
+ , std::to_string(config::RPC_DEFAULT_PORT)
+ };
+ const command_line::arg_descriptor<std::string> arg_testnet_rpc_bind_port = {
+ "testnet-rpc-bind-port"
+ , ""
+ , std::to_string(config::testnet::RPC_DEFAULT_PORT)
+ };
}
//-----------------------------------------------------------------------------------
@@ -54,22 +63,31 @@ namespace cryptonote
{
command_line::add_arg(desc, arg_rpc_bind_ip);
command_line::add_arg(desc, arg_rpc_bind_port);
+ command_line::add_arg(desc, arg_testnet_rpc_bind_port);
}
//------------------------------------------------------------------------------------------------------------------------------
core_rpc_server::core_rpc_server(core& cr, nodetool::node_server<cryptonote::t_cryptonote_protocol_handler<cryptonote::core> >& p2p):m_core(cr), m_p2p(p2p)
{}
//------------------------------------------------------------------------------------------------------------------------------
- bool core_rpc_server::handle_command_line(const boost::program_options::variables_map& vm)
+ bool core_rpc_server::handle_command_line(
+ const boost::program_options::variables_map& vm
+ , bool testnet
+ )
{
+ auto p2p_bind_arg = testnet ? arg_testnet_rpc_bind_port : arg_rpc_bind_port;
+
m_bind_ip = command_line::get_arg(vm, arg_rpc_bind_ip);
- m_port = command_line::get_arg(vm, arg_rpc_bind_port);
+ m_port = command_line::get_arg(vm, p2p_bind_arg);
return true;
}
//------------------------------------------------------------------------------------------------------------------------------
- bool core_rpc_server::init(const boost::program_options::variables_map& vm)
+ bool core_rpc_server::init(
+ const boost::program_options::variables_map& vm
+ , bool testnet
+ )
{
m_net_server.set_threads_prefix("RPC");
- bool r = handle_command_line(vm);
+ bool r = handle_command_line(vm, testnet);
CHECK_AND_ASSERT_MES(r, false, "Failed to process command line in core_rpc_server");
return epee::http_server_impl_base<core_rpc_server, connection_context>::init(m_port, m_bind_ip);
}
diff --git a/src/rpc/core_rpc_server.h b/src/rpc/core_rpc_server.h
index 2e3f553ce..3f3d23f51 100644
--- a/src/rpc/core_rpc_server.h
+++ b/src/rpc/core_rpc_server.h
@@ -52,7 +52,10 @@ namespace cryptonote
core_rpc_server(core& cr, nodetool::node_server<cryptonote::t_cryptonote_protocol_handler<cryptonote::core> >& p2p);
static void init_options(boost::program_options::options_description& desc);
- bool init(const boost::program_options::variables_map& vm);
+ bool init(
+ const boost::program_options::variables_map& vm
+ , bool testnet
+ );
private:
CHAIN_HTTP_TO_MAP2(connection_context); //forward http requests to uri map
@@ -105,7 +108,10 @@ namespace cryptonote
bool on_get_connections(const COMMAND_RPC_GET_CONNECTIONS::request& req, COMMAND_RPC_GET_CONNECTIONS::response& res, epee::json_rpc::error& error_resp, connection_context& cntx);
bool on_get_info_json(const COMMAND_RPC_GET_INFO::request& req, COMMAND_RPC_GET_INFO::response& res, epee::json_rpc::error& error_resp, connection_context& cntx);
//-----------------------
- 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 check_core_busy();
bool check_core_ready();
diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp
index 45bc6f847..6c97dc807 100644
--- a/src/simplewallet/simplewallet.cpp
+++ b/src/simplewallet/simplewallet.cpp
@@ -328,15 +328,19 @@ bool simple_wallet::init(const boost::program_options::variables_map& vm)
if(!ask_wallet_create_if_needed()) return false;
}
+ bool testnet = command_line::get_arg(vm, arg_testnet);
+
if (m_daemon_host.empty())
m_daemon_host = "localhost";
+
if (!m_daemon_port)
- m_daemon_port = config::RPC_DEFAULT_PORT;
+ {
+ m_daemon_port = testnet ? config::testnet::RPC_DEFAULT_PORT : config::RPC_DEFAULT_PORT;
+ }
+
if (m_daemon_address.empty())
m_daemon_address = std::string("http://") + m_daemon_host + ":" + std::to_string(m_daemon_port);
- bool testnet = command_line::get_arg(vm, arg_testnet);
-
tools::password_container pwd_container;
if (command_line::has_arg(vm, arg_password))
{
diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp
index bbf5bab61..b8b728425 100644
--- a/src/wallet/wallet2.cpp
+++ b/src/wallet/wallet2.cpp
@@ -542,8 +542,12 @@ bool wallet2::check_connection()
net_utils::http::url_content u;
net_utils::parse_url(m_daemon_address, u);
+
if(!u.port)
- u.port = config::RPC_DEFAULT_PORT;
+ {
+ u.port = m_testnet ? config::testnet::RPC_DEFAULT_PORT : config::RPC_DEFAULT_PORT;
+ }
+
return m_http_client.connect(u.host, std::to_string(u.port), WALLET_RCP_CONNECTION_TIMEOUT);
}
//----------------------------------------------------------------------------------------------------