From c33ae04ad889de165630378fb3521d3ca8ded8cb Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Fri, 7 Nov 2014 21:54:55 +1100 Subject: [PATCH] Handle mining.ping in proxy mode --- src/generator.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/generator.c b/src/generator.c index 524b1ec6..6257b338 100644 --- a/src/generator.c +++ b/src/generator.c @@ -792,6 +792,19 @@ static bool show_message(json_t *val) return true; } +static bool send_pong(proxy_instance_t *proxi, json_t *val) +{ + json_t *json_msg, *id_val = json_object_dup(val, "id"); + connsock_t *cs = proxi->cs; + bool ret; + + JSON_CPACK(json_msg, "{sossso}", "id", id_val, "result", "pong", + "error", json_null()); + ret = send_json_msg(cs, json_msg); + json_decref(json_msg); + return ret; +} + static bool parse_reconnect(proxy_instance_t *proxi, json_t *val) { server_instance_t *newsi, *si = proxi->si; @@ -924,6 +937,11 @@ static bool parse_method(proxy_instance_t *proxi, const char *msg) ret = show_message(params); goto out; } + + if (cmdmatch(buf, "mining.ping")) { + ret = send_pong(proxi, val); + goto out; + } out: if (val) json_decref(val);