From a058c387b3de06a17558e54a1d0c6edf1f622029 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Sun, 2 Nov 2014 13:37:42 +1100 Subject: [PATCH] Give pings an integer id and handle pongs and spurious responses without an error message --- src/stratifier.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/stratifier.c b/src/stratifier.c index 8251c06a..63756614 100644 --- a/src/stratifier.c +++ b/src/stratifier.c @@ -1297,9 +1297,9 @@ static void broadcast_ping(void) { json_t *json_msg; - JSON_CPACK(json_msg, "{s:[],s:o,s:s}", + JSON_CPACK(json_msg, "{s:[],s:i,s:s}", "params", - "id", json_null(), + "id", 42, "method", "mining.ping"); stratum_broadcast(json_msg); @@ -2803,6 +2803,15 @@ static void parse_instance_msg(smsg_t *msg) method = json_object_get(val, "method"); if (unlikely(!method)) { + json_t *res_val = json_object_get(val, "result"); + + /* Is this a spurious result or ping response? */ + if (res_val) { + const char *result = json_string_value(res_val); + + LOGDEBUG("Received spurious response %s", result ? result : ""); + goto out; + } send_json_err(client_id, id_val, "-3:method not found"); goto out; }