Browse Source

Submit the actual shares sent to the proxy upstream

master
Con Kolivas 11 years ago
parent
commit
e36e5ce010
  1. 28
      src/generator.c
  2. 12
      src/stratifier.c

28
src/generator.c

@ -872,12 +872,16 @@ static void *proxy_recv(void *arg)
static void *proxy_send(void *arg) static void *proxy_send(void *arg)
{ {
proxy_instance_t *proxi = (proxy_instance_t *)arg; proxy_instance_t *proxi = (proxy_instance_t *)arg;
connsock_t *cs = proxi->cs;
rename_proc("proxysend"); rename_proc("proxysend");
while (42) { while (42) {
notify_instance_t *instance;
stratum_msg_t *msg; stratum_msg_t *msg;
char *buf; char *jobid;
json_t *val;
uint32_t id;
mutex_lock(&proxi->psend_lock); mutex_lock(&proxi->psend_lock);
if (!proxi->psends) if (!proxi->psends)
@ -890,9 +894,27 @@ static void *proxy_send(void *arg)
if (unlikely(!msg)) if (unlikely(!msg))
continue; continue;
buf = json_dumps(msg->json_msg, 0); json_uintcpy(&id, msg->json_msg, "jobid");
LOGDEBUG("Proxysend received: %s", buf);
mutex_lock(&proxi->notify_lock);
HASH_FIND_INT(proxi->notify_instances, &id, instance);
if (instance)
jobid = strdup(instance->jobid);
mutex_unlock(&proxi->notify_lock);
if (!instance) {
LOGWARNING("Failed to find matching jobid in proxysend");
continue;
}
/* FIXME Use unique IDs and parse responses */
val = json_pack("{s[ssooo]siss}", "params", proxi->auth, jobid,
json_object_get(msg->json_msg, "nonce2"),
json_object_get(msg->json_msg, "ntime"),
json_object_get(msg->json_msg, "nonce"),
"id", 0, "method", "mining.submit");
free(jobid);
send_json_msg(cs, val);
json_decref(val);
json_decref(msg->json_msg); json_decref(msg->json_msg);
free(msg); free(msg);
} }

12
src/stratifier.c

@ -175,6 +175,7 @@ struct stratum_instance {
char enonce1[32]; char enonce1[32];
uchar enonce1bin[16]; uchar enonce1bin[16];
char enonce1var[12];
uint64_t enonce1_64; uint64_t enonce1_64;
int diff; /* Current diff */ int diff; /* Current diff */
@ -863,6 +864,7 @@ static void new_enonce1(stratum_instance_t *client)
if (wb->enonce1constlen) if (wb->enonce1constlen)
memcpy(client->enonce1bin, wb->enonce1constbin, wb->enonce1constlen); memcpy(client->enonce1bin, wb->enonce1constbin, wb->enonce1constlen);
memcpy(client->enonce1bin + wb->enonce1constlen, &client->enonce1_64, wb->enonce1varlen); 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); __bin2hex(client->enonce1, client->enonce1bin, wb->enonce1constlen + wb->enonce1varlen);
ck_wunlock(&workbase_lock); ck_wunlock(&workbase_lock);
} }
@ -1205,16 +1207,16 @@ out_unlock:
} }
/* Submit a share in proxy mode to the parent pool. workbase_lock is held */ /* Submit a share in proxy mode to the parent pool. workbase_lock is held */
static void __submit_share(workbase_t *wb, const char *jobid, const char *nonce2, static void __submit_share(stratum_instance_t *client, workbase_t *wb, uint64_t jobid,
const char *ntime, const char *nonce) const char *nonce2, const char *ntime, const char *nonce)
{ {
ckpool_t *ckp = wb->ckp; ckpool_t *ckp = wb->ckp;
json_t *json_msg; json_t *json_msg;
char enonce2[32]; char enonce2[32];
char *msg; char *msg;
sprintf(enonce2, "%s%s", wb->enonce1const, nonce2); sprintf(enonce2, "%s%s", client->enonce1var, nonce2);
json_msg = json_pack("{ssssssss}", "jobid", jobid, "nonce2", enonce2, json_msg = json_pack("{sissssss}", "jobid", jobid, "nonce2", enonce2,
"ntime", ntime, "nonce", nonce); "ntime", ntime, "nonce", nonce);
msg = json_dumps(json_msg, 0); msg = json_dumps(json_msg, 0);
json_decref(json_msg); json_decref(json_msg);
@ -1312,7 +1314,7 @@ static json_t *parse_submit(stratum_instance_t *client, json_t *json_msg,
} }
invalid = false; invalid = false;
if (wb->proxy && sdiff > wb->diff) if (wb->proxy && sdiff > wb->diff)
__submit_share(wb, idstring, nonce2, ntime, nonce); __submit_share(client, wb, id, nonce2, ntime, nonce);
out_unlock: out_unlock:
ck_runlock(&workbase_lock); ck_runlock(&workbase_lock);

Loading…
Cancel
Save