Browse Source

Send the proxy details from the generator to the stratifier

master
Con Kolivas 10 years ago
parent
commit
fd7d62df15
  1. 9
      src/generator.c
  2. 17
      src/stratifier.c

9
src/generator.c

@ -1303,11 +1303,10 @@ static void send_subscribe(ckpool_t *ckp, proxy_instance_t *proxi)
json_t *json_msg; json_t *json_msg;
char *msg, *buf; char *msg, *buf;
JSON_CPACK(json_msg, "{sIsisssi}", JSON_CPACK(json_msg, "{ss,ss,ss,sI,si,ss,si}",
"proxy", proxi->id, "url", proxi->url, "auth", proxi->auth, "pass", proxi->pass,
"subproxy", proxi->subid, "proxy", proxi->id, "subproxy", proxi->subid,
"enonce1", proxi->enonce1, "enonce1", proxi->enonce1, "nonce2len", proxi->nonce2len);
"nonce2len", proxi->nonce2len);
msg = json_dumps(json_msg, JSON_NO_UTF8); msg = json_dumps(json_msg, JSON_NO_UTF8);
json_decref(json_msg); json_decref(json_msg);
ASPRINTF(&buf, "subscribe=%s", msg); ASPRINTF(&buf, "subscribe=%s", msg);

17
src/stratifier.c

@ -302,6 +302,9 @@ struct proxy_base {
double diff; double diff;
char url[128];
char auth[128];
char pass[128];
char enonce1[32]; char enonce1[32];
uchar enonce1bin[16]; uchar enonce1bin[16];
int enonce1constlen; int enonce1constlen;
@ -1378,6 +1381,12 @@ static void update_subscribe(ckpool_t *ckp, const char *cmd)
ck_wlock(&dsdata->workbase_lock); ck_wlock(&dsdata->workbase_lock);
proxy->subscribed = true; proxy->subscribed = true;
proxy->diff = ckp->startdiff; proxy->diff = ckp->startdiff;
memset(proxy->url, 0, 128);
memset(proxy->auth, 0, 128);
memset(proxy->pass, 0, 128);
strncpy(proxy->url, json_string_value(json_object_get(val, "url")), 127);
strncpy(proxy->auth, json_string_value(json_object_get(val, "auth")), 127);
strncpy(proxy->pass, json_string_value(json_object_get(val, "pass")), 127);
/* Length is checked by generator */ /* Length is checked by generator */
strcpy(proxy->enonce1, json_string_value(json_object_get(val, "enonce1"))); strcpy(proxy->enonce1, json_string_value(json_object_get(val, "enonce1")));
proxy->enonce1constlen = strlen(proxy->enonce1) / 2; proxy->enonce1constlen = strlen(proxy->enonce1) / 2;
@ -1397,11 +1406,11 @@ static void update_subscribe(ckpool_t *ckp, const char *cmd)
ck_wunlock(&dsdata->workbase_lock); ck_wunlock(&dsdata->workbase_lock);
if (subid) { if (subid) {
LOGINFO("Upstream pool %d:%d extranonce2 length %d, max proxy clients %"PRId64, LOGINFO("Upstream pool %s %d:%d extranonce2 length %d, max proxy clients %"PRId64,
id, subid, proxy->nonce2len, proxy->max_clients); proxy->url, id, subid, proxy->nonce2len, proxy->max_clients);
} else { } else {
LOGNOTICE("Upstream pool %d extranonce2 length %d, max proxy clients %"PRId64, LOGNOTICE("Upstream pool %s %d extranonce2 length %d, max proxy clients %"PRId64,
id, proxy->nonce2len, proxy->max_clients); proxy->url, id, proxy->nonce2len, proxy->max_clients);
} }
json_decref(val); json_decref(val);
} }

Loading…
Cancel
Save