mirror of
https://github.com/monero-project/monero.git
synced 2025-01-28 18:56:31 +02:00
get_block_count, start_save_graph, stop_save_graph IPC
This commit is contained in:
parent
65c98639e7
commit
26f7c3d5a9
@ -473,5 +473,15 @@ namespace IPC
|
|||||||
wap_proto_set_status(message, STATUS_OK);
|
wap_proto_set_status(message, STATUS_OK);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void start_save_graph(wap_proto_t *message) {
|
||||||
|
p2p->set_save_graph(true);
|
||||||
|
wap_proto_set_status(message, STATUS_OK);
|
||||||
|
}
|
||||||
|
|
||||||
|
void stop_save_graph(wap_proto_t *message) {
|
||||||
|
p2p->set_save_graph(false);
|
||||||
|
wap_proto_set_status(message, STATUS_OK);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -83,6 +83,8 @@ namespace IPC
|
|||||||
void get_mining_status(wap_proto_t *message);
|
void get_mining_status(wap_proto_t *message);
|
||||||
void set_log_hash_rate(wap_proto_t *message);
|
void set_log_hash_rate(wap_proto_t *message);
|
||||||
void set_log_level(wap_proto_t *message);
|
void set_log_level(wap_proto_t *message);
|
||||||
|
void start_save_graph(wap_proto_t *message);
|
||||||
|
void stop_save_graph(wap_proto_t *message);
|
||||||
void init(cryptonote::core &p_core,
|
void init(cryptonote::core &p_core,
|
||||||
nodetool::node_server<cryptonote::t_cryptonote_protocol_handler<cryptonote::core> > &p_p2p,
|
nodetool::node_server<cryptonote::t_cryptonote_protocol_handler<cryptonote::core> > &p_p2p,
|
||||||
bool p_testnet);
|
bool p_testnet);
|
||||||
|
@ -137,6 +137,16 @@ WAP_EXPORT int
|
|||||||
WAP_EXPORT int
|
WAP_EXPORT int
|
||||||
wap_client_set_log_level (wap_client_t *self, uint8_t level);
|
wap_client_set_log_level (wap_client_t *self, uint8_t level);
|
||||||
|
|
||||||
|
// Start save graph
|
||||||
|
// Returns >= 0 if successful, -1 if interrupted.
|
||||||
|
WAP_EXPORT int
|
||||||
|
wap_client_start_save_graph (wap_client_t *self);
|
||||||
|
|
||||||
|
// Stop save graph
|
||||||
|
// Returns >= 0 if successful, -1 if interrupted.
|
||||||
|
WAP_EXPORT int
|
||||||
|
wap_client_stop_save_graph (wap_client_t *self);
|
||||||
|
|
||||||
// Return last received status
|
// Return last received status
|
||||||
WAP_EXPORT int
|
WAP_EXPORT int
|
||||||
wap_client_status (wap_client_t *self);
|
wap_client_status (wap_client_t *self);
|
||||||
|
@ -38,10 +38,12 @@ typedef enum {
|
|||||||
expect_get_mining_status_ok_state = 15,
|
expect_get_mining_status_ok_state = 15,
|
||||||
expect_set_log_hash_rate_ok_state = 16,
|
expect_set_log_hash_rate_ok_state = 16,
|
||||||
expect_set_log_level_ok_state = 17,
|
expect_set_log_level_ok_state = 17,
|
||||||
expect_close_ok_state = 18,
|
expect_start_save_graph_ok_state = 18,
|
||||||
defaults_state = 19,
|
expect_stop_save_graph_ok_state = 19,
|
||||||
have_error_state = 20,
|
expect_close_ok_state = 20,
|
||||||
reexpect_open_ok_state = 21
|
defaults_state = 21,
|
||||||
|
have_error_state = 22,
|
||||||
|
reexpect_open_ok_state = 23
|
||||||
} state_t;
|
} state_t;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
@ -64,27 +66,31 @@ typedef enum {
|
|||||||
get_mining_status_event = 16,
|
get_mining_status_event = 16,
|
||||||
set_log_hash_rate_event = 17,
|
set_log_hash_rate_event = 17,
|
||||||
set_log_level_event = 18,
|
set_log_level_event = 18,
|
||||||
destructor_event = 19,
|
start_save_graph_event = 19,
|
||||||
blocks_ok_event = 20,
|
stop_save_graph_event = 20,
|
||||||
get_ok_event = 21,
|
destructor_event = 21,
|
||||||
put_ok_event = 22,
|
blocks_ok_event = 22,
|
||||||
save_bc_ok_event = 23,
|
get_ok_event = 23,
|
||||||
start_ok_event = 24,
|
put_ok_event = 24,
|
||||||
stop_ok_event = 25,
|
save_bc_ok_event = 25,
|
||||||
output_indexes_ok_event = 26,
|
start_ok_event = 26,
|
||||||
random_outs_ok_event = 27,
|
stop_ok_event = 27,
|
||||||
get_height_ok_event = 28,
|
output_indexes_ok_event = 28,
|
||||||
get_info_ok_event = 29,
|
random_outs_ok_event = 29,
|
||||||
get_peer_list_ok_event = 30,
|
get_height_ok_event = 30,
|
||||||
get_mining_status_ok_event = 31,
|
get_info_ok_event = 31,
|
||||||
set_log_hash_rate_ok_event = 32,
|
get_peer_list_ok_event = 32,
|
||||||
set_log_level_ok_event = 33,
|
get_mining_status_ok_event = 33,
|
||||||
close_ok_event = 34,
|
set_log_hash_rate_ok_event = 34,
|
||||||
ping_ok_event = 35,
|
set_log_level_ok_event = 35,
|
||||||
error_event = 36,
|
start_save_graph_ok_event = 36,
|
||||||
exception_event = 37,
|
stop_save_graph_ok_event = 37,
|
||||||
command_invalid_event = 38,
|
close_ok_event = 38,
|
||||||
other_event = 39
|
ping_ok_event = 39,
|
||||||
|
error_event = 40,
|
||||||
|
exception_event = 41,
|
||||||
|
command_invalid_event = 42,
|
||||||
|
other_event = 43
|
||||||
} event_t;
|
} event_t;
|
||||||
|
|
||||||
// Names for state machine logging and error reporting
|
// Names for state machine logging and error reporting
|
||||||
@ -108,6 +114,8 @@ s_state_name [] = {
|
|||||||
"expect get mining status ok",
|
"expect get mining status ok",
|
||||||
"expect set log hash rate ok",
|
"expect set log hash rate ok",
|
||||||
"expect set log level ok",
|
"expect set log level ok",
|
||||||
|
"expect start save graph ok",
|
||||||
|
"expect stop save graph ok",
|
||||||
"expect close ok",
|
"expect close ok",
|
||||||
"defaults",
|
"defaults",
|
||||||
"have error",
|
"have error",
|
||||||
@ -135,6 +143,8 @@ s_event_name [] = {
|
|||||||
"GET_MINING_STATUS",
|
"GET_MINING_STATUS",
|
||||||
"SET_LOG_HASH_RATE",
|
"SET_LOG_HASH_RATE",
|
||||||
"SET_LOG_LEVEL",
|
"SET_LOG_LEVEL",
|
||||||
|
"START_SAVE_GRAPH",
|
||||||
|
"STOP_SAVE_GRAPH",
|
||||||
"destructor",
|
"destructor",
|
||||||
"BLOCKS_OK",
|
"BLOCKS_OK",
|
||||||
"GET_OK",
|
"GET_OK",
|
||||||
@ -150,6 +160,8 @@ s_event_name [] = {
|
|||||||
"GET_MINING_STATUS_OK",
|
"GET_MINING_STATUS_OK",
|
||||||
"SET_LOG_HASH_RATE_OK",
|
"SET_LOG_HASH_RATE_OK",
|
||||||
"SET_LOG_LEVEL_OK",
|
"SET_LOG_LEVEL_OK",
|
||||||
|
"START_SAVE_GRAPH_OK",
|
||||||
|
"STOP_SAVE_GRAPH_OK",
|
||||||
"CLOSE_OK",
|
"CLOSE_OK",
|
||||||
"PING_OK",
|
"PING_OK",
|
||||||
"ERROR",
|
"ERROR",
|
||||||
@ -276,6 +288,10 @@ static void
|
|||||||
signal_have_set_log_hash_rate_ok (client_t *self);
|
signal_have_set_log_hash_rate_ok (client_t *self);
|
||||||
static void
|
static void
|
||||||
signal_have_set_log_level_ok (client_t *self);
|
signal_have_set_log_level_ok (client_t *self);
|
||||||
|
static void
|
||||||
|
signal_have_start_save_graph_ok (client_t *self);
|
||||||
|
static void
|
||||||
|
signal_have_stop_save_graph_ok (client_t *self);
|
||||||
static void
|
static void
|
||||||
signal_failure (client_t *self);
|
signal_failure (client_t *self);
|
||||||
static void
|
static void
|
||||||
@ -549,6 +565,18 @@ s_protocol_event (s_client_t *self, wap_proto_t *message)
|
|||||||
case WAP_PROTO_SET_LOG_LEVEL_OK:
|
case WAP_PROTO_SET_LOG_LEVEL_OK:
|
||||||
return set_log_level_ok_event;
|
return set_log_level_ok_event;
|
||||||
break;
|
break;
|
||||||
|
case WAP_PROTO_START_SAVE_GRAPH:
|
||||||
|
return start_save_graph_event;
|
||||||
|
break;
|
||||||
|
case WAP_PROTO_START_SAVE_GRAPH_OK:
|
||||||
|
return start_save_graph_ok_event;
|
||||||
|
break;
|
||||||
|
case WAP_PROTO_STOP_SAVE_GRAPH:
|
||||||
|
return stop_save_graph_event;
|
||||||
|
break;
|
||||||
|
case WAP_PROTO_STOP_SAVE_GRAPH_OK:
|
||||||
|
return stop_save_graph_ok_event;
|
||||||
|
break;
|
||||||
case WAP_PROTO_STOP:
|
case WAP_PROTO_STOP:
|
||||||
return stop_event;
|
return stop_event;
|
||||||
break;
|
break;
|
||||||
@ -931,6 +959,30 @@ s_client_execute (s_client_t *self, event_t event)
|
|||||||
self->state = expect_set_log_level_ok_state;
|
self->state = expect_set_log_level_ok_state;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
if (self->event == start_save_graph_event) {
|
||||||
|
if (!self->exception) {
|
||||||
|
// send START_SAVE_GRAPH
|
||||||
|
if (wap_client_verbose)
|
||||||
|
zsys_debug ("wap_client: $ send START_SAVE_GRAPH");
|
||||||
|
wap_proto_set_id (self->message, WAP_PROTO_START_SAVE_GRAPH);
|
||||||
|
wap_proto_send (self->message, self->dealer);
|
||||||
|
}
|
||||||
|
if (!self->exception)
|
||||||
|
self->state = expect_start_save_graph_ok_state;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
if (self->event == stop_save_graph_event) {
|
||||||
|
if (!self->exception) {
|
||||||
|
// send STOP_SAVE_GRAPH
|
||||||
|
if (wap_client_verbose)
|
||||||
|
zsys_debug ("wap_client: $ send STOP_SAVE_GRAPH");
|
||||||
|
wap_proto_set_id (self->message, WAP_PROTO_STOP_SAVE_GRAPH);
|
||||||
|
wap_proto_send (self->message, self->dealer);
|
||||||
|
}
|
||||||
|
if (!self->exception)
|
||||||
|
self->state = expect_stop_save_graph_ok_state;
|
||||||
|
}
|
||||||
|
else
|
||||||
if (self->event == destructor_event) {
|
if (self->event == destructor_event) {
|
||||||
if (!self->exception) {
|
if (!self->exception) {
|
||||||
// send CLOSE
|
// send CLOSE
|
||||||
@ -1622,6 +1674,96 @@ s_client_execute (s_client_t *self, event_t event)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case expect_start_save_graph_ok_state:
|
||||||
|
if (self->event == start_save_graph_ok_event) {
|
||||||
|
if (!self->exception) {
|
||||||
|
// signal have start save graph ok
|
||||||
|
if (wap_client_verbose)
|
||||||
|
zsys_debug ("wap_client: $ signal have start save graph ok");
|
||||||
|
signal_have_start_save_graph_ok (&self->client);
|
||||||
|
}
|
||||||
|
if (!self->exception)
|
||||||
|
self->state = connected_state;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
if (self->event == ping_ok_event) {
|
||||||
|
if (!self->exception) {
|
||||||
|
// client is connected
|
||||||
|
if (wap_client_verbose)
|
||||||
|
zsys_debug ("wap_client: $ client is connected");
|
||||||
|
client_is_connected (&self->client);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
if (self->event == error_event) {
|
||||||
|
if (!self->exception) {
|
||||||
|
// check status code
|
||||||
|
if (wap_client_verbose)
|
||||||
|
zsys_debug ("wap_client: $ check status code");
|
||||||
|
check_status_code (&self->client);
|
||||||
|
}
|
||||||
|
if (!self->exception)
|
||||||
|
self->state = have_error_state;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
if (self->event == exception_event) {
|
||||||
|
// No action - just logging
|
||||||
|
if (wap_client_verbose)
|
||||||
|
zsys_debug ("wap_client: $ exception");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// Handle unexpected protocol events
|
||||||
|
// No action - just logging
|
||||||
|
if (wap_client_verbose)
|
||||||
|
zsys_debug ("wap_client: $ *");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case expect_stop_save_graph_ok_state:
|
||||||
|
if (self->event == stop_save_graph_ok_event) {
|
||||||
|
if (!self->exception) {
|
||||||
|
// signal have stop save graph ok
|
||||||
|
if (wap_client_verbose)
|
||||||
|
zsys_debug ("wap_client: $ signal have stop save graph ok");
|
||||||
|
signal_have_stop_save_graph_ok (&self->client);
|
||||||
|
}
|
||||||
|
if (!self->exception)
|
||||||
|
self->state = connected_state;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
if (self->event == ping_ok_event) {
|
||||||
|
if (!self->exception) {
|
||||||
|
// client is connected
|
||||||
|
if (wap_client_verbose)
|
||||||
|
zsys_debug ("wap_client: $ client is connected");
|
||||||
|
client_is_connected (&self->client);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
if (self->event == error_event) {
|
||||||
|
if (!self->exception) {
|
||||||
|
// check status code
|
||||||
|
if (wap_client_verbose)
|
||||||
|
zsys_debug ("wap_client: $ check status code");
|
||||||
|
check_status_code (&self->client);
|
||||||
|
}
|
||||||
|
if (!self->exception)
|
||||||
|
self->state = have_error_state;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
if (self->event == exception_event) {
|
||||||
|
// No action - just logging
|
||||||
|
if (wap_client_verbose)
|
||||||
|
zsys_debug ("wap_client: $ exception");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// Handle unexpected protocol events
|
||||||
|
// No action - just logging
|
||||||
|
if (wap_client_verbose)
|
||||||
|
zsys_debug ("wap_client: $ *");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case expect_close_ok_state:
|
case expect_close_ok_state:
|
||||||
if (self->event == close_ok_event) {
|
if (self->event == close_ok_event) {
|
||||||
if (!self->exception) {
|
if (!self->exception) {
|
||||||
@ -1943,6 +2085,14 @@ s_client_handle_cmdpipe (zloop_t *loop, zsock_t *reader, void *argument)
|
|||||||
zsock_recv (self->cmdpipe, "1", &self->args.level);
|
zsock_recv (self->cmdpipe, "1", &self->args.level);
|
||||||
s_client_execute (self, set_log_level_event);
|
s_client_execute (self, set_log_level_event);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
if (streq (method, "START SAVE GRAPH")) {
|
||||||
|
s_client_execute (self, start_save_graph_event);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
if (streq (method, "STOP SAVE GRAPH")) {
|
||||||
|
s_client_execute (self, stop_save_graph_event);
|
||||||
|
}
|
||||||
// Cleanup pipe if any argument frames are still waiting to be eaten
|
// Cleanup pipe if any argument frames are still waiting to be eaten
|
||||||
if (zsock_rcvmore (self->cmdpipe)) {
|
if (zsock_rcvmore (self->cmdpipe)) {
|
||||||
zsys_error ("wap_client: trailing API command frames (%s)", method);
|
zsys_error ("wap_client: trailing API command frames (%s)", method);
|
||||||
@ -2274,6 +2424,14 @@ s_accept_reply (wap_client_t *self, ...)
|
|||||||
if (streq (reply, "SET LOG LEVEL OK")) {
|
if (streq (reply, "SET LOG LEVEL OK")) {
|
||||||
zsock_recv (self->actor, "8", &self->status);
|
zsock_recv (self->actor, "8", &self->status);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
if (streq (reply, "START SAVE GRAPH OK")) {
|
||||||
|
zsock_recv (self->actor, "8", &self->status);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
if (streq (reply, "STOP SAVE GRAPH OK")) {
|
||||||
|
zsock_recv (self->actor, "8", &self->status);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
filter = va_arg (args, char *);
|
filter = va_arg (args, char *);
|
||||||
@ -2555,6 +2713,38 @@ wap_client_set_log_level (wap_client_t *self, uint8_t level)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
// Start save graph
|
||||||
|
// Returns >= 0 if successful, -1 if interrupted.
|
||||||
|
|
||||||
|
int
|
||||||
|
wap_client_start_save_graph (wap_client_t *self)
|
||||||
|
{
|
||||||
|
assert (self);
|
||||||
|
|
||||||
|
zsock_send (self->actor, "s", "START SAVE GRAPH");
|
||||||
|
if (s_accept_reply (self, "START SAVE GRAPH OK", "FAILURE", NULL))
|
||||||
|
return -1; // Interrupted or timed-out
|
||||||
|
return self->status;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
// Stop save graph
|
||||||
|
// Returns >= 0 if successful, -1 if interrupted.
|
||||||
|
|
||||||
|
int
|
||||||
|
wap_client_stop_save_graph (wap_client_t *self)
|
||||||
|
{
|
||||||
|
assert (self);
|
||||||
|
|
||||||
|
zsock_send (self->actor, "s", "STOP SAVE GRAPH");
|
||||||
|
if (s_accept_reply (self, "STOP SAVE GRAPH OK", "FAILURE", NULL))
|
||||||
|
return -1; // Interrupted or timed-out
|
||||||
|
return self->status;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
// Return last received status
|
// Return last received status
|
||||||
|
|
||||||
|
@ -132,6 +132,16 @@ ERROR.
|
|||||||
SET_LOG_LEVEL_OK - This is a codec for a Bitcoin Wallet Access Protocol (RFC tbd)
|
SET_LOG_LEVEL_OK - This is a codec for a Bitcoin Wallet Access Protocol (RFC tbd)
|
||||||
status number 8 Status
|
status number 8 Status
|
||||||
|
|
||||||
|
START_SAVE_GRAPH - start_save_graph IPC
|
||||||
|
|
||||||
|
START_SAVE_GRAPH_OK - This is a codec for a Bitcoin Wallet Access Protocol (RFC tbd)
|
||||||
|
status number 8 Status
|
||||||
|
|
||||||
|
STOP_SAVE_GRAPH - stop_save_graph IPC
|
||||||
|
|
||||||
|
STOP_SAVE_GRAPH_OK - This is a codec for a Bitcoin Wallet Access Protocol (RFC tbd)
|
||||||
|
status number 8 Status
|
||||||
|
|
||||||
STOP - Wallet asks daemon to start mining. Daemon replies with STOP-OK, or
|
STOP - Wallet asks daemon to start mining. Daemon replies with STOP-OK, or
|
||||||
ERROR.
|
ERROR.
|
||||||
|
|
||||||
@ -191,13 +201,17 @@ Daemon will reply with CLOSE-OK or ERROR.
|
|||||||
#define WAP_PROTO_SET_LOG_HASH_RATE_OK 26
|
#define WAP_PROTO_SET_LOG_HASH_RATE_OK 26
|
||||||
#define WAP_PROTO_SET_LOG_LEVEL 27
|
#define WAP_PROTO_SET_LOG_LEVEL 27
|
||||||
#define WAP_PROTO_SET_LOG_LEVEL_OK 28
|
#define WAP_PROTO_SET_LOG_LEVEL_OK 28
|
||||||
#define WAP_PROTO_STOP 29
|
#define WAP_PROTO_START_SAVE_GRAPH 29
|
||||||
#define WAP_PROTO_STOP_OK 30
|
#define WAP_PROTO_START_SAVE_GRAPH_OK 30
|
||||||
#define WAP_PROTO_CLOSE 31
|
#define WAP_PROTO_STOP_SAVE_GRAPH 31
|
||||||
#define WAP_PROTO_CLOSE_OK 32
|
#define WAP_PROTO_STOP_SAVE_GRAPH_OK 32
|
||||||
#define WAP_PROTO_PING 33
|
#define WAP_PROTO_STOP 33
|
||||||
#define WAP_PROTO_PING_OK 34
|
#define WAP_PROTO_STOP_OK 34
|
||||||
#define WAP_PROTO_ERROR 35
|
#define WAP_PROTO_CLOSE 35
|
||||||
|
#define WAP_PROTO_CLOSE_OK 36
|
||||||
|
#define WAP_PROTO_PING 37
|
||||||
|
#define WAP_PROTO_PING_OK 38
|
||||||
|
#define WAP_PROTO_ERROR 39
|
||||||
|
|
||||||
#include <czmq.h>
|
#include <czmq.h>
|
||||||
|
|
||||||
|
@ -45,11 +45,13 @@ typedef enum {
|
|||||||
get_mining_status_event = 14,
|
get_mining_status_event = 14,
|
||||||
set_log_hash_rate_event = 15,
|
set_log_hash_rate_event = 15,
|
||||||
set_log_level_event = 16,
|
set_log_level_event = 16,
|
||||||
close_event = 17,
|
start_save_graph_event = 17,
|
||||||
ping_event = 18,
|
stop_save_graph_event = 18,
|
||||||
expired_event = 19,
|
close_event = 19,
|
||||||
exception_event = 20,
|
ping_event = 20,
|
||||||
settled_event = 21
|
expired_event = 21,
|
||||||
|
exception_event = 22,
|
||||||
|
settled_event = 23
|
||||||
} event_t;
|
} event_t;
|
||||||
|
|
||||||
// Names for state machine logging and error reporting
|
// Names for state machine logging and error reporting
|
||||||
@ -81,6 +83,8 @@ s_event_name [] = {
|
|||||||
"GET_MINING_STATUS",
|
"GET_MINING_STATUS",
|
||||||
"SET_LOG_HASH_RATE",
|
"SET_LOG_HASH_RATE",
|
||||||
"SET_LOG_LEVEL",
|
"SET_LOG_LEVEL",
|
||||||
|
"START_SAVE_GRAPH",
|
||||||
|
"STOP_SAVE_GRAPH",
|
||||||
"CLOSE",
|
"CLOSE",
|
||||||
"PING",
|
"PING",
|
||||||
"expired",
|
"expired",
|
||||||
@ -178,6 +182,10 @@ static void
|
|||||||
set_log_hash_rate (client_t *self);
|
set_log_hash_rate (client_t *self);
|
||||||
static void
|
static void
|
||||||
set_log_level (client_t *self);
|
set_log_level (client_t *self);
|
||||||
|
static void
|
||||||
|
start_save_graph (client_t *self);
|
||||||
|
static void
|
||||||
|
stop_save_graph (client_t *self);
|
||||||
static void
|
static void
|
||||||
deregister_wallet (client_t *self);
|
deregister_wallet (client_t *self);
|
||||||
static void
|
static void
|
||||||
@ -404,6 +412,12 @@ s_protocol_event (wap_proto_t *message)
|
|||||||
case WAP_PROTO_SET_LOG_LEVEL:
|
case WAP_PROTO_SET_LOG_LEVEL:
|
||||||
return set_log_level_event;
|
return set_log_level_event;
|
||||||
break;
|
break;
|
||||||
|
case WAP_PROTO_START_SAVE_GRAPH:
|
||||||
|
return start_save_graph_event;
|
||||||
|
break;
|
||||||
|
case WAP_PROTO_STOP_SAVE_GRAPH:
|
||||||
|
return stop_save_graph_event;
|
||||||
|
break;
|
||||||
case WAP_PROTO_STOP:
|
case WAP_PROTO_STOP:
|
||||||
return stop_event;
|
return stop_event;
|
||||||
break;
|
break;
|
||||||
@ -874,6 +888,42 @@ s_client_execute (s_client_t *self, event_t event)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
if (self->event == start_save_graph_event) {
|
||||||
|
if (!self->exception) {
|
||||||
|
// start save graph
|
||||||
|
if (self->server->verbose)
|
||||||
|
zsys_debug ("%s: $ start save graph", self->log_prefix);
|
||||||
|
start_save_graph (&self->client);
|
||||||
|
}
|
||||||
|
if (!self->exception) {
|
||||||
|
// send START_SAVE_GRAPH_OK
|
||||||
|
if (self->server->verbose)
|
||||||
|
zsys_debug ("%s: $ send START_SAVE_GRAPH_OK",
|
||||||
|
self->log_prefix);
|
||||||
|
wap_proto_set_id (self->server->message, WAP_PROTO_START_SAVE_GRAPH_OK);
|
||||||
|
wap_proto_set_routing_id (self->server->message, self->routing_id);
|
||||||
|
wap_proto_send (self->server->message, self->server->router);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
if (self->event == stop_save_graph_event) {
|
||||||
|
if (!self->exception) {
|
||||||
|
// stop save graph
|
||||||
|
if (self->server->verbose)
|
||||||
|
zsys_debug ("%s: $ stop save graph", self->log_prefix);
|
||||||
|
stop_save_graph (&self->client);
|
||||||
|
}
|
||||||
|
if (!self->exception) {
|
||||||
|
// send STOP_SAVE_GRAPH_OK
|
||||||
|
if (self->server->verbose)
|
||||||
|
zsys_debug ("%s: $ send STOP_SAVE_GRAPH_OK",
|
||||||
|
self->log_prefix);
|
||||||
|
wap_proto_set_id (self->server->message, WAP_PROTO_STOP_SAVE_GRAPH_OK);
|
||||||
|
wap_proto_set_routing_id (self->server->message, self->routing_id);
|
||||||
|
wap_proto_send (self->server->message, self->server->router);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
if (self->event == close_event) {
|
if (self->event == close_event) {
|
||||||
if (!self->exception) {
|
if (!self->exception) {
|
||||||
// send CLOSE_OK
|
// send CLOSE_OK
|
||||||
|
@ -466,3 +466,25 @@ signal_have_set_log_level_ok (client_t *self)
|
|||||||
zsock_send (self->cmdpipe, "s8", "SET LOG LEVEL OK",
|
zsock_send (self->cmdpipe, "s8", "SET LOG LEVEL OK",
|
||||||
wap_proto_status (self->message));
|
wap_proto_status (self->message));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
// signal_have_start_save_graph_ok
|
||||||
|
//
|
||||||
|
|
||||||
|
static void
|
||||||
|
signal_have_start_save_graph_ok (client_t *self)
|
||||||
|
{
|
||||||
|
zsock_send (self->cmdpipe, "s8", "START SAVE GRAPH OK",
|
||||||
|
wap_proto_status (self->message));
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
// signal_have_stop_save_graph_ok
|
||||||
|
//
|
||||||
|
|
||||||
|
static void
|
||||||
|
signal_have_stop_save_graph_ok (client_t *self)
|
||||||
|
{
|
||||||
|
zsock_send (self->cmdpipe, "s8", "STOP SAVE GRAPH OK",
|
||||||
|
wap_proto_status (self->message));
|
||||||
|
}
|
||||||
|
@ -554,6 +554,20 @@ wap_proto_recv (wap_proto_t *self, zsock_t *input)
|
|||||||
GET_NUMBER8 (self->status);
|
GET_NUMBER8 (self->status);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case WAP_PROTO_START_SAVE_GRAPH:
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WAP_PROTO_START_SAVE_GRAPH_OK:
|
||||||
|
GET_NUMBER8 (self->status);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WAP_PROTO_STOP_SAVE_GRAPH:
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WAP_PROTO_STOP_SAVE_GRAPH_OK:
|
||||||
|
GET_NUMBER8 (self->status);
|
||||||
|
break;
|
||||||
|
|
||||||
case WAP_PROTO_STOP:
|
case WAP_PROTO_STOP:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -714,6 +728,12 @@ wap_proto_send (wap_proto_t *self, zsock_t *output)
|
|||||||
case WAP_PROTO_SET_LOG_LEVEL_OK:
|
case WAP_PROTO_SET_LOG_LEVEL_OK:
|
||||||
frame_size += 8; // status
|
frame_size += 8; // status
|
||||||
break;
|
break;
|
||||||
|
case WAP_PROTO_START_SAVE_GRAPH_OK:
|
||||||
|
frame_size += 8; // status
|
||||||
|
break;
|
||||||
|
case WAP_PROTO_STOP_SAVE_GRAPH_OK:
|
||||||
|
frame_size += 8; // status
|
||||||
|
break;
|
||||||
case WAP_PROTO_ERROR:
|
case WAP_PROTO_ERROR:
|
||||||
frame_size += 2; // status
|
frame_size += 2; // status
|
||||||
frame_size += 1 + strlen (self->reason);
|
frame_size += 1 + strlen (self->reason);
|
||||||
@ -902,6 +922,14 @@ wap_proto_send (wap_proto_t *self, zsock_t *output)
|
|||||||
PUT_NUMBER8 (self->status);
|
PUT_NUMBER8 (self->status);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case WAP_PROTO_START_SAVE_GRAPH_OK:
|
||||||
|
PUT_NUMBER8 (self->status);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WAP_PROTO_STOP_SAVE_GRAPH_OK:
|
||||||
|
PUT_NUMBER8 (self->status);
|
||||||
|
break;
|
||||||
|
|
||||||
case WAP_PROTO_ERROR:
|
case WAP_PROTO_ERROR:
|
||||||
PUT_NUMBER2 (self->status);
|
PUT_NUMBER2 (self->status);
|
||||||
PUT_STRING (self->reason);
|
PUT_STRING (self->reason);
|
||||||
@ -1164,6 +1192,24 @@ wap_proto_print (wap_proto_t *self)
|
|||||||
zsys_debug (" status=%ld", (long) self->status);
|
zsys_debug (" status=%ld", (long) self->status);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case WAP_PROTO_START_SAVE_GRAPH:
|
||||||
|
zsys_debug ("WAP_PROTO_START_SAVE_GRAPH:");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WAP_PROTO_START_SAVE_GRAPH_OK:
|
||||||
|
zsys_debug ("WAP_PROTO_START_SAVE_GRAPH_OK:");
|
||||||
|
zsys_debug (" status=%ld", (long) self->status);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WAP_PROTO_STOP_SAVE_GRAPH:
|
||||||
|
zsys_debug ("WAP_PROTO_STOP_SAVE_GRAPH:");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WAP_PROTO_STOP_SAVE_GRAPH_OK:
|
||||||
|
zsys_debug ("WAP_PROTO_STOP_SAVE_GRAPH_OK:");
|
||||||
|
zsys_debug (" status=%ld", (long) self->status);
|
||||||
|
break;
|
||||||
|
|
||||||
case WAP_PROTO_STOP:
|
case WAP_PROTO_STOP:
|
||||||
zsys_debug ("WAP_PROTO_STOP:");
|
zsys_debug ("WAP_PROTO_STOP:");
|
||||||
break;
|
break;
|
||||||
@ -1325,6 +1371,18 @@ wap_proto_command (wap_proto_t *self)
|
|||||||
case WAP_PROTO_SET_LOG_LEVEL_OK:
|
case WAP_PROTO_SET_LOG_LEVEL_OK:
|
||||||
return ("SET_LOG_LEVEL_OK");
|
return ("SET_LOG_LEVEL_OK");
|
||||||
break;
|
break;
|
||||||
|
case WAP_PROTO_START_SAVE_GRAPH:
|
||||||
|
return ("START_SAVE_GRAPH");
|
||||||
|
break;
|
||||||
|
case WAP_PROTO_START_SAVE_GRAPH_OK:
|
||||||
|
return ("START_SAVE_GRAPH_OK");
|
||||||
|
break;
|
||||||
|
case WAP_PROTO_STOP_SAVE_GRAPH:
|
||||||
|
return ("STOP_SAVE_GRAPH");
|
||||||
|
break;
|
||||||
|
case WAP_PROTO_STOP_SAVE_GRAPH_OK:
|
||||||
|
return ("STOP_SAVE_GRAPH_OK");
|
||||||
|
break;
|
||||||
case WAP_PROTO_STOP:
|
case WAP_PROTO_STOP:
|
||||||
return ("STOP");
|
return ("STOP");
|
||||||
break;
|
break;
|
||||||
@ -2539,6 +2597,50 @@ wap_proto_test (bool verbose)
|
|||||||
wap_proto_send (self, output);
|
wap_proto_send (self, output);
|
||||||
wap_proto_send (self, output);
|
wap_proto_send (self, output);
|
||||||
|
|
||||||
|
for (instance = 0; instance < 2; instance++) {
|
||||||
|
wap_proto_recv (self, input);
|
||||||
|
assert (wap_proto_routing_id (self));
|
||||||
|
assert (wap_proto_status (self) == 123);
|
||||||
|
}
|
||||||
|
wap_proto_set_id (self, WAP_PROTO_START_SAVE_GRAPH);
|
||||||
|
|
||||||
|
// Send twice
|
||||||
|
wap_proto_send (self, output);
|
||||||
|
wap_proto_send (self, output);
|
||||||
|
|
||||||
|
for (instance = 0; instance < 2; instance++) {
|
||||||
|
wap_proto_recv (self, input);
|
||||||
|
assert (wap_proto_routing_id (self));
|
||||||
|
}
|
||||||
|
wap_proto_set_id (self, WAP_PROTO_START_SAVE_GRAPH_OK);
|
||||||
|
|
||||||
|
wap_proto_set_status (self, 123);
|
||||||
|
// Send twice
|
||||||
|
wap_proto_send (self, output);
|
||||||
|
wap_proto_send (self, output);
|
||||||
|
|
||||||
|
for (instance = 0; instance < 2; instance++) {
|
||||||
|
wap_proto_recv (self, input);
|
||||||
|
assert (wap_proto_routing_id (self));
|
||||||
|
assert (wap_proto_status (self) == 123);
|
||||||
|
}
|
||||||
|
wap_proto_set_id (self, WAP_PROTO_STOP_SAVE_GRAPH);
|
||||||
|
|
||||||
|
// Send twice
|
||||||
|
wap_proto_send (self, output);
|
||||||
|
wap_proto_send (self, output);
|
||||||
|
|
||||||
|
for (instance = 0; instance < 2; instance++) {
|
||||||
|
wap_proto_recv (self, input);
|
||||||
|
assert (wap_proto_routing_id (self));
|
||||||
|
}
|
||||||
|
wap_proto_set_id (self, WAP_PROTO_STOP_SAVE_GRAPH_OK);
|
||||||
|
|
||||||
|
wap_proto_set_status (self, 123);
|
||||||
|
// Send twice
|
||||||
|
wap_proto_send (self, output);
|
||||||
|
wap_proto_send (self, output);
|
||||||
|
|
||||||
for (instance = 0; instance < 2; instance++) {
|
for (instance = 0; instance < 2; instance++) {
|
||||||
wap_proto_recv (self, input);
|
wap_proto_recv (self, input);
|
||||||
assert (wap_proto_routing_id (self));
|
assert (wap_proto_routing_id (self));
|
||||||
|
@ -342,3 +342,23 @@ set_log_level (client_t *self)
|
|||||||
{
|
{
|
||||||
IPC::Daemon::set_log_level(self->message);
|
IPC::Daemon::set_log_level(self->message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
// start_save_graph
|
||||||
|
//
|
||||||
|
|
||||||
|
static void
|
||||||
|
start_save_graph (client_t *self)
|
||||||
|
{
|
||||||
|
IPC::Daemon::start_save_graph(self->message);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
// stop_save_graph
|
||||||
|
//
|
||||||
|
|
||||||
|
static void
|
||||||
|
stop_save_graph (client_t *self)
|
||||||
|
{
|
||||||
|
IPC::Daemon::stop_save_graph(self->message);
|
||||||
|
}
|
||||||
|
@ -432,6 +432,69 @@ namespace
|
|||||||
return ns_rpc_create_reply(buf, len, req, "{s:s}", "status", STATUS_OK);
|
return ns_rpc_create_reply(buf, len, req, "{s:s}", "status", STATUS_OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Implementation of 'getblockcount' method.
|
||||||
|
* \param buf Buffer to fill in response.
|
||||||
|
* \param len Max length of response.
|
||||||
|
* \param req net_skeleton RPC request
|
||||||
|
* \return Actual response length.
|
||||||
|
*/
|
||||||
|
int getblockcount(char *buf, int len, struct ns_rpc_request *req)
|
||||||
|
{
|
||||||
|
connect_to_daemon();
|
||||||
|
int rc = wap_client_get_height(ipc_client);
|
||||||
|
if (rc < 0) {
|
||||||
|
return ns_rpc_create_error(buf, len, req, daemon_connection_error,
|
||||||
|
"Couldn't connect to daemon.", "{}");
|
||||||
|
}
|
||||||
|
uint64_t count = wap_client_height(ipc_client);
|
||||||
|
rapidjson::Document response_json;
|
||||||
|
rapidjson::Value result_json;
|
||||||
|
result_json.SetObject();
|
||||||
|
result_json.AddMember("count", count, response_json.GetAllocator());
|
||||||
|
result_json.AddMember("status", "OK", response_json.GetAllocator());
|
||||||
|
std::string response;
|
||||||
|
construct_response_string(req, result_json, response_json, response);
|
||||||
|
size_t copy_length = ((uint32_t)len > response.length()) ? response.length() + 1 : (uint32_t)len;
|
||||||
|
strncpy(buf, response.c_str(), copy_length);
|
||||||
|
return response.length();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Implementation of 'startsavegraph' method.
|
||||||
|
* \param buf Buffer to fill in response.
|
||||||
|
* \param len Max length of response.
|
||||||
|
* \param req net_skeleton RPC request
|
||||||
|
* \return Actual response length.
|
||||||
|
*/
|
||||||
|
int startsavegraph(char *buf, int len, struct ns_rpc_request *req)
|
||||||
|
{
|
||||||
|
connect_to_daemon();
|
||||||
|
int rc = wap_client_start_save_graph(ipc_client);
|
||||||
|
if (rc < 0) {
|
||||||
|
return ns_rpc_create_error(buf, len, req, daemon_connection_error,
|
||||||
|
"Couldn't connect to daemon.", "{}");
|
||||||
|
}
|
||||||
|
return ns_rpc_create_reply(buf, len, req, "{s:s}", "status", STATUS_OK);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Implementation of 'stopsavegraph' method.
|
||||||
|
* \param buf Buffer to fill in response.
|
||||||
|
* \param len Max length of response.
|
||||||
|
* \param req net_skeleton RPC request
|
||||||
|
* \return Actual response length.
|
||||||
|
*/
|
||||||
|
int stopsavegraph(char *buf, int len, struct ns_rpc_request *req)
|
||||||
|
{
|
||||||
|
connect_to_daemon();
|
||||||
|
int rc = wap_client_stop_save_graph(ipc_client);
|
||||||
|
if (rc < 0) {
|
||||||
|
return ns_rpc_create_error(buf, len, req, daemon_connection_error,
|
||||||
|
"Couldn't connect to daemon.", "{}");
|
||||||
|
}
|
||||||
|
return ns_rpc_create_reply(buf, len, req, "{s:s}", "status", STATUS_OK);
|
||||||
|
}
|
||||||
// Contains a list of method names.
|
// Contains a list of method names.
|
||||||
const char *method_names[] = {
|
const char *method_names[] = {
|
||||||
"getheight",
|
"getheight",
|
||||||
@ -442,6 +505,9 @@ namespace
|
|||||||
"getminingstatus",
|
"getminingstatus",
|
||||||
"setloghashrate",
|
"setloghashrate",
|
||||||
"setloglevel",
|
"setloglevel",
|
||||||
|
"getblockcount",
|
||||||
|
"startsavegraph",
|
||||||
|
"stopsavegraph",
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -455,6 +521,9 @@ namespace
|
|||||||
getminingstatus,
|
getminingstatus,
|
||||||
setloghashrate,
|
setloghashrate,
|
||||||
setloglevel,
|
setloglevel,
|
||||||
|
getblockcount,
|
||||||
|
startsavegraph,
|
||||||
|
stopsavegraph,
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user