Separate rpc port for testnet

This commit is contained in:
Zachary Michaels 2014-09-08 13:07:15 -04:00 committed by Riccardo Spagni
parent 98ed9a41f7
commit 658b6690a3
No known key found for this signature in database
GPG key ID: 55432DF31CCD4FCD
5 changed files with 44 additions and 12 deletions

View file

@ -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);
}

View file

@ -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();