mirror of
https://github.com/monero-project/monero.git
synced 2026-01-09 03:41:14 -08:00
json serialization for rpc-relevant monero types
Structured {de-,}serialization methods for (many new) types
which are used for requests or responses in the RPC.
New types include RPC requests and responses, and structs which compose
types within those.
# Conflicts:
# src/cryptonote_core/blockchain.cpp
This commit is contained in:
@@ -32,6 +32,8 @@
|
||||
#include <stdexcept>
|
||||
#include "misc_log_ex.h"
|
||||
#include "daemon/daemon.h"
|
||||
#include "rpc/daemon_handler.h"
|
||||
#include "rpc/zmq_server.h"
|
||||
|
||||
#include "common/password.h"
|
||||
#include "common/util.h"
|
||||
@@ -85,7 +87,18 @@ t_daemon::t_daemon(
|
||||
boost::program_options::variables_map const & vm
|
||||
)
|
||||
: mp_internals{new t_internals{vm}}
|
||||
{}
|
||||
{
|
||||
bool testnet = command_line::get_arg(vm, command_line::arg_testnet_on);
|
||||
if (testnet)
|
||||
{
|
||||
zmq_rpc_bind_port = command_line::get_arg(vm, daemon_args::arg_zmq_testnet_rpc_bind_port);
|
||||
}
|
||||
else
|
||||
{
|
||||
zmq_rpc_bind_port = command_line::get_arg(vm, daemon_args::arg_zmq_rpc_bind_port);
|
||||
}
|
||||
zmq_rpc_bind_address = command_line::get_arg(vm, daemon_args::arg_zmq_rpc_bind_ip);
|
||||
}
|
||||
|
||||
t_daemon::~t_daemon() = default;
|
||||
|
||||
@@ -133,6 +146,30 @@ bool t_daemon::run(bool interactive)
|
||||
rpc_commands->start_handling(std::bind(&daemonize::t_daemon::stop_p2p, this));
|
||||
}
|
||||
|
||||
cryptonote::rpc::DaemonHandler rpc_daemon_handler(mp_internals->core.get(), mp_internals->p2p.get());
|
||||
cryptonote::rpc::ZmqServer zmq_server(rpc_daemon_handler);
|
||||
|
||||
if (!zmq_server.addTCPSocket(zmq_rpc_bind_address, zmq_rpc_bind_port))
|
||||
{
|
||||
LOG_ERROR(std::string("Failed to add TCP Socket (") + zmq_rpc_bind_address
|
||||
+ ":" + zmq_rpc_bind_port + ") to ZMQ RPC Server");
|
||||
|
||||
if (interactive)
|
||||
{
|
||||
rpc_commands->stop_handling();
|
||||
}
|
||||
|
||||
mp_internals->rpc.stop();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
MINFO("Starting ZMQ server...");
|
||||
zmq_server.run();
|
||||
|
||||
MINFO(std::string("ZMQ server started at ") + zmq_rpc_bind_address
|
||||
+ ":" + zmq_rpc_bind_port + ".");
|
||||
|
||||
mp_internals->p2p.run(); // blocks until p2p goes down
|
||||
|
||||
if (rpc_commands)
|
||||
@@ -140,6 +177,8 @@ bool t_daemon::run(bool interactive)
|
||||
rpc_commands->stop_handling();
|
||||
}
|
||||
|
||||
zmq_server.stop();
|
||||
|
||||
mp_internals->rpc.stop();
|
||||
mp_internals->core.get().get_miner().stop();
|
||||
MGINFO("Node stopped.");
|
||||
|
||||
Reference in New Issue
Block a user