Browse Source

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

master
Con Kolivas 10 years ago
parent
commit
27a7a36e38
  1. 29
      src/stratifier.c

29
src/stratifier.c

@ -232,7 +232,7 @@ struct stratum_instance {
char address[INET6_ADDRSTRLEN];
bool authorised;
bool invalid;
bool subscribed;
bool idle;
bool notified_idle;
@ -1245,9 +1245,8 @@ static void new_enonce1(stratum_instance_t *client)
}
/* Extranonce1 must be set here */
static json_t *parse_subscribe(int64_t client_id, json_t *params_val)
static json_t *parse_subscribe(stratum_instance_t *client, int64_t client_id, json_t *params_val)
{
stratum_instance_t *client = NULL;
bool old_match = false;
int arr_size;
json_t *ret;
@ -1256,15 +1255,6 @@ static json_t *parse_subscribe(int64_t client_id, json_t *params_val)
if (unlikely(!json_is_array(params_val)))
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))
return json_string("Initialising");
@ -1309,6 +1299,8 @@ static json_t *parse_subscribe(int64_t client_id, json_t *params_val)
n2len);
ck_runlock(&workbase_lock);
client->subscribed = true;
return ret;
}
@ -2132,25 +2124,20 @@ 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. */
method = json_string_value(method_val);
if (cmdmatch(method, "mining.subscribe")) {
json_t *val, *result_val = parse_subscribe(client_id, params_val);
json_t *val, *result_val = parse_subscribe(client, client_id, params_val);
if (unlikely(!result_val))
return;
val = json_object();
json_object_set_new_nocheck(val, "result", result_val);
json_object_set_nocheck(val, "id", id_val);
json_object_set_new_nocheck(val, "error", json_null());
stratum_add_send(val, client_id);
if (unlikely(!json_is_true(result_val))) {
client->invalid = true;
return;
}
if (likely(client->subscribed))
update_client(client, client_id);
return;
}
if (unlikely(client->invalid)) {
LOGINFO("Dropping invalidated client %d", client->id);
if (unlikely(!client->subscribed)) {
LOGINFO("Dropping unsubscribed client %d", client->id);
snprintf(buf, 255, "dropclient=%ld", client->id);
send_proc(client->ckp->connector, buf);
drop_client(client->id);

Loading…
Cancel
Save