mirror of
https://github.com/monero-project/monero.git
synced 2025-01-28 18:56:31 +02:00
Replaced old RPC server in daemon with new one. Yet to add RPC handlers.
This commit is contained in:
parent
fedf1eb473
commit
5eb1d32ef7
@ -143,7 +143,7 @@ int main(int argc, char* argv[])
|
||||
command_line::add_arg(desc_cmd_sett, arg_dns_checkpoints);
|
||||
|
||||
cryptonote::core::init_options(desc_cmd_sett);
|
||||
cryptonote::core_rpc_server::init_options(desc_cmd_sett);
|
||||
RPC::init_options(desc_cmd_sett);
|
||||
nodetool::node_server<cryptonote::t_cryptonote_protocol_handler<cryptonote::core> >::init_options(desc_cmd_sett);
|
||||
cryptonote::miner::init_options(desc_cmd_sett);
|
||||
|
||||
@ -232,7 +232,7 @@ int main(int argc, char* argv[])
|
||||
cprotocol
|
||||
, testnet_mode ? std::move(config::testnet::NETWORK_ID) : std::move(config::NETWORK_ID)
|
||||
};
|
||||
cryptonote::core_rpc_server rpc_server {ccore, p2psrv, testnet_mode};
|
||||
|
||||
cprotocol.set_p2p_endpoint(&p2psrv);
|
||||
ccore.set_cryptonote_protocol(&cprotocol);
|
||||
daemon_cmmands_handler dch(p2psrv, testnet_mode);
|
||||
@ -249,9 +249,11 @@ int main(int argc, char* argv[])
|
||||
LOG_PRINT_L0("Protocol initialized OK");
|
||||
|
||||
LOG_PRINT_L0("Initializing core RPC server...");
|
||||
res = rpc_server.init(vm);
|
||||
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);
|
||||
RPC::init(&ccore, &p2psrv, testnet_mode);
|
||||
std::string ip_address, port;
|
||||
RPC::get_address_and_port(vm, ip_address, port);
|
||||
RPC::Json_rpc_http_server rpc_server(ip_address, port, &RPC::ev_handler);
|
||||
LOG_PRINT_GREEN("Core RPC server initialized on port: " << port, LOG_LEVEL_0);
|
||||
|
||||
//initialize core here
|
||||
LOG_PRINT_L0("Initializing core...");
|
||||
@ -266,8 +268,8 @@ int main(int argc, char* argv[])
|
||||
}
|
||||
|
||||
LOG_PRINT_L0("Starting core RPC server...");
|
||||
res = rpc_server.run(2, false);
|
||||
CHECK_AND_ASSERT_MES(res, 1, "Failed to initialize core RPC server.");
|
||||
res = rpc_server.start();
|
||||
CHECK_AND_ASSERT_MES(res, 1, "Failed to start core RPC server.");
|
||||
LOG_PRINT_L0("Core RPC server started ok");
|
||||
|
||||
tools::signal_handler::install([&dch, &p2psrv] {
|
||||
@ -281,14 +283,11 @@ int main(int argc, char* argv[])
|
||||
|
||||
//stop components
|
||||
LOG_PRINT_L0("Stopping core rpc server...");
|
||||
rpc_server.send_stop_signal();
|
||||
rpc_server.timed_wait_server_stop(5000);
|
||||
rpc_server.stop();
|
||||
|
||||
//deinitialize components
|
||||
LOG_PRINT_L0("Deinitializing core...");
|
||||
ccore.deinit();
|
||||
LOG_PRINT_L0("Deinitializing RPC server ...");
|
||||
rpc_server.deinit();
|
||||
LOG_PRINT_L0("Deinitializing protocol...");
|
||||
cprotocol.deinit();
|
||||
LOG_PRINT_L0("Deinitializing P2P...");
|
||||
|
@ -97,7 +97,6 @@ namespace cryptonote
|
||||
const boost::program_options::variables_map& vm
|
||||
)
|
||||
{
|
||||
m_net_server.set_threads_prefix("RPC");
|
||||
bool r = handle_command_line(vm);
|
||||
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);
|
||||
|
@ -1,8 +1,62 @@
|
||||
#include "net_skeleton/net_skeleton.h"
|
||||
#include "common/command_line.h"
|
||||
#include "net/http_server_impl_base.h"
|
||||
#include "cryptonote_core/cryptonote_core.h"
|
||||
#include "p2p/net_node.h"
|
||||
#include "cryptonote_protocol/cryptonote_protocol_handler.h"
|
||||
#include <string>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
namespace RPC
|
||||
{
|
||||
cryptonote::core *core;
|
||||
nodetool::node_server<cryptonote::t_cryptonote_protocol_handler<cryptonote::core> > *p2p;
|
||||
bool testnet;
|
||||
|
||||
const command_line::arg_descriptor<std::string> arg_rpc_bind_ip = {
|
||||
"rpc-bind-ip",
|
||||
"IP for RPC server",
|
||||
"127.0.0.1"
|
||||
};
|
||||
|
||||
const command_line::arg_descriptor<std::string> arg_rpc_bind_port = {
|
||||
"rpc-bind-port",
|
||||
"Port for RPC server",
|
||||
std::to_string(config::RPC_DEFAULT_PORT)
|
||||
};
|
||||
|
||||
const command_line::arg_descriptor<std::string> arg_testnet_rpc_bind_port = {
|
||||
"testnet-rpc-bind-port",
|
||||
"Port for testnet RPC server",
|
||||
std::to_string(config::testnet::RPC_DEFAULT_PORT)
|
||||
};
|
||||
|
||||
void init(cryptonote::core *p_core,
|
||||
nodetool::node_server<cryptonote::t_cryptonote_protocol_handler<cryptonote::core> > *p_p2p,
|
||||
bool p_testnet)
|
||||
{
|
||||
core = p_core;
|
||||
p2p = p_p2p;
|
||||
testnet = p_testnet;
|
||||
}
|
||||
|
||||
void init_options(boost::program_options::options_description& desc)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
void get_address_and_port(const boost::program_options::variables_map& vm,
|
||||
std::string &ip_address, std::string &port)
|
||||
{
|
||||
auto p2p_bind_arg = testnet ? arg_testnet_rpc_bind_port : arg_rpc_bind_port;
|
||||
|
||||
ip_address = command_line::get_arg(vm, arg_rpc_bind_ip);
|
||||
port = command_line::get_arg(vm, p2p_bind_arg);
|
||||
}
|
||||
|
||||
int foo(char *buf, int len, struct ns_rpc_request *req) {
|
||||
std::cout << "Method name: ";
|
||||
std::cout << req->method->ptr << std::endl;
|
||||
|
Loading…
Reference in New Issue
Block a user