Browse Source

Revert "Do not hand out enonce1 to new clients when no notify data exists"

This reverts commit cc791f0b67.
master
Con Kolivas 11 years ago
parent
commit
740edcc80c
  1. 35
      src/stratifier.c

35
src/stratifier.c

@ -392,7 +392,7 @@ static void add_base(ckpool_t *ckp, workbase_t *wb, bool *new_block)
if (unlikely(ret && errno != EEXIST))
quit(1, "Failed to create log directory %s", wb->logdir);
HASH_ITER(hh, workbases, tmp, tmpa) {
if (HASH_COUNT(workbases) < 2)
if (HASH_COUNT(workbases) < 3)
break;
/* Age old workbases older than 10 minutes old */
if (tmp->gentime < wb->gentime - 600) {
@ -490,7 +490,6 @@ static void drop_allclients(ckpool_t *ckp)
static bool update_subscribe(ckpool_t *ckp)
{
workbase_t *wb, *tmp;
json_t *val;
char *buf;
@ -516,11 +515,6 @@ static bool update_subscribe(ckpool_t *ckp)
else
proxy_base.enonce1varlen = 2;
proxy_base.enonce2varlen = proxy_base.nonce2len - proxy_base.enonce1varlen;
/* Delete all the workbases since they're now invalid */
HASH_ITER(hh, workbases, wb, tmp) {
HASH_DEL(workbases, wb);
clear_workbase(wb);
}
ck_wunlock(&workbase_lock);
json_decref(val);
@ -619,9 +613,7 @@ static void update_diff(ckpool_t *ckp)
ck_wlock(&workbase_lock);
old_diff = proxy_base.diff;
proxy_base.diff = diff;
if (current_workbase)
current_workbase->diff = diff;
current_workbase->diff = proxy_base.diff = diff;
ck_wunlock(&workbase_lock);
if (old_diff < diff)
@ -916,16 +908,11 @@ static void *blockupdate(void *arg)
return NULL;
}
static bool new_enonce1(stratum_instance_t *client)
static void new_enonce1(stratum_instance_t *client)
{
bool ret = true;
workbase_t *wb;
ck_wlock(&workbase_lock);
if (unlikely(!current_workbase)) {
ret = false;
goto out_unlock;
}
client->enonce1_64 = enonce1_64;
wb = current_workbase;
if (wb->enonce1varlen == 8) {
@ -944,10 +931,7 @@ static bool new_enonce1(stratum_instance_t *client)
memcpy(client->enonce1bin + wb->enonce1constlen, &client->enonce1_64, wb->enonce1varlen);
__bin2hex(client->enonce1var, &client->enonce1_64, wb->enonce1varlen);
__bin2hex(client->enonce1, client->enonce1bin, wb->enonce1constlen + wb->enonce1varlen);
out_unlock:
ck_wunlock(&workbase_lock);
return ret;
}
/* Extranonce1 must be set here */
@ -955,8 +939,8 @@ static json_t *parse_subscribe(int client_id, json_t *params_val)
{
stratum_instance_t *client = NULL;
bool old_match = false;
json_t *ret = NULL;
int arr_size;
json_t *ret;
int n2len;
if (unlikely(!json_is_array(params_val)))
@ -968,7 +952,7 @@ static json_t *parse_subscribe(int client_id, json_t *params_val)
if (unlikely(!client)) {
LOGERR("Failed to find client id %d in hashtable!", client_id);
goto out;
return NULL;
}
arr_size = json_array_size(params_val);
@ -993,10 +977,7 @@ static json_t *parse_subscribe(int client_id, json_t *params_val)
}
if (!old_match) {
/* Create a new extranonce1 based on a uint64_t pointer */
if (!new_enonce1(client)) {
LOGNOTICE("No valid data from upstream to create enonce1 for client %d", client_id);
goto out;
}
new_enonce1(client);
LOGINFO("Set new subscription %d to new enonce1 %s", client->id,
client->enonce1);
} else {
@ -1012,7 +993,7 @@ static json_t *parse_subscribe(int client_id, json_t *params_val)
ret = json_pack("[[[s,s]],s,i]", "mining.notify", client->enonce1, client->enonce1,
n2len);
ck_runlock(&workbase_lock);
out:
return ret;
}
@ -1525,8 +1506,6 @@ static json_t *gen_json_result(int client_id, json_t *json_msg, json_t *method_v
if (!strncasecmp(method, "mining.subscribe", 16)) {
*update = true;
ret = parse_subscribe(client_id, params_val);
if (!ret)
drop_client(client_id);
goto out;
}

Loading…
Cancel
Save