Browse Source

Revert "Mining subscribe does not return true as the result so use a subscribed boolean"

This reverts commit 27a7a36e38.
master
Con Kolivas 10 years ago
parent
commit
55a14d4ea5
  1. 31
      src/stratifier.c

31
src/stratifier.c

@ -232,7 +232,7 @@ struct stratum_instance {
char address[INET6_ADDRSTRLEN]; char address[INET6_ADDRSTRLEN];
bool authorised; bool authorised;
bool subscribed; bool invalid;
bool idle; bool idle;
bool notified_idle; bool notified_idle;
@ -1245,8 +1245,9 @@ static void new_enonce1(stratum_instance_t *client)
} }
/* Extranonce1 must be set here */ /* Extranonce1 must be set here */
static json_t *parse_subscribe(stratum_instance_t *client, int64_t client_id, json_t *params_val) static json_t *parse_subscribe(int64_t client_id, json_t *params_val)
{ {
stratum_instance_t *client = NULL;
bool old_match = false; bool old_match = false;
int arr_size; int arr_size;
json_t *ret; json_t *ret;
@ -1255,6 +1256,15 @@ static json_t *parse_subscribe(stratum_instance_t *client, int64_t client_id, js
if (unlikely(!json_is_array(params_val))) if (unlikely(!json_is_array(params_val)))
return json_string("params not an array"); return json_string("params not an array");
ck_rlock(&instance_lock);
client = __instance_by_id(client_id);
ck_runlock(&instance_lock);
if (unlikely(!client)) {
LOGERR("Failed to find client id %d in hashtable!", client_id);
return NULL;
}
if (unlikely(!current_workbase)) if (unlikely(!current_workbase))
return json_string("Initialising"); return json_string("Initialising");
@ -1299,8 +1309,6 @@ static json_t *parse_subscribe(stratum_instance_t *client, int64_t client_id, js
n2len); n2len);
ck_runlock(&workbase_lock); ck_runlock(&workbase_lock);
client->subscribed = true;
return ret; return ret;
} }
@ -2124,20 +2132,25 @@ static void parse_method(const int64_t client_id, json_t *id_val, json_t *method
* the json item for id_val as is for the response. */ * the json item for id_val as is for the response. */
method = json_string_value(method_val); method = json_string_value(method_val);
if (cmdmatch(method, "mining.subscribe")) { if (cmdmatch(method, "mining.subscribe")) {
json_t *val, *result_val = parse_subscribe(client, client_id, params_val); json_t *val, *result_val = parse_subscribe(client_id, params_val);
if (unlikely(!result_val))
return;
val = json_object(); val = json_object();
json_object_set_new_nocheck(val, "result", result_val); json_object_set_new_nocheck(val, "result", result_val);
json_object_set_nocheck(val, "id", id_val); json_object_set_nocheck(val, "id", id_val);
json_object_set_new_nocheck(val, "error", json_null()); json_object_set_new_nocheck(val, "error", json_null());
stratum_add_send(val, client_id); stratum_add_send(val, client_id);
if (likely(client->subscribed)) if (unlikely(!json_is_true(result_val))) {
update_client(client, client_id); client->invalid = true;
return;
}
update_client(client, client_id);
return; return;
} }
if (unlikely(!client->subscribed)) { if (unlikely(client->invalid)) {
LOGINFO("Dropping unsubscribed client %d", client->id); LOGINFO("Dropping invalidated client %d", client->id);
snprintf(buf, 255, "dropclient=%ld", client->id); snprintf(buf, 255, "dropclient=%ld", client->id);
send_proc(client->ckp->connector, buf); send_proc(client->ckp->connector, buf);
drop_client(client->id); drop_client(client->id);

Loading…
Cancel
Save