Browse Source

Give pings an integer id and handle pongs and spurious responses without an error message

master
Con Kolivas 10 years ago
parent
commit
a058c387b3
  1. 13
      src/stratifier.c

13
src/stratifier.c

@ -1297,9 +1297,9 @@ static void broadcast_ping(void)
{ {
json_t *json_msg; json_t *json_msg;
JSON_CPACK(json_msg, "{s:[],s:o,s:s}", JSON_CPACK(json_msg, "{s:[],s:i,s:s}",
"params", "params",
"id", json_null(), "id", 42,
"method", "mining.ping"); "method", "mining.ping");
stratum_broadcast(json_msg); stratum_broadcast(json_msg);
@ -2803,6 +2803,15 @@ static void parse_instance_msg(smsg_t *msg)
method = json_object_get(val, "method"); method = json_object_get(val, "method");
if (unlikely(!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"); send_json_err(client_id, id_val, "-3:method not found");
goto out; goto out;
} }

Loading…
Cancel
Save