Skip to content

Commit

Permalink
Support arbitrary-size arguments to mining.submit
Browse files Browse the repository at this point in the history
Fixes #87
  • Loading branch information
pooler committed Feb 14, 2015
1 parent 2d92d66 commit 4611186
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions cpu-miner.c
Original file line number Diff line number Diff line change
Expand Up @@ -661,19 +661,22 @@ static bool submit_upstream_work(CURL *curl, struct work *work)

if (have_stratum) {
uint32_t ntime, nonce;
char ntimestr[9], noncestr[9], *xnonce2str;
char ntimestr[9], noncestr[9], *xnonce2str, *req;

le32enc(&ntime, work->data[17]);
le32enc(&nonce, work->data[19]);
bin2hex(ntimestr, (const unsigned char *)(&ntime), 4);
bin2hex(noncestr, (const unsigned char *)(&nonce), 4);
xnonce2str = abin2hex(work->xnonce2, work->xnonce2_len);
sprintf(s,
req = malloc(256 + strlen(rpc_user) + strlen(work->job_id) + 2 * work->xnonce2_len);
sprintf(req,
"{\"method\": \"mining.submit\", \"params\": [\"%s\", \"%s\", \"%s\", \"%s\", \"%s\"], \"id\":4}",
rpc_user, work->job_id, xnonce2str, ntimestr, noncestr);
free(xnonce2str);

if (unlikely(!stratum_send_line(&stratum, s))) {
rc = stratum_send_line(&stratum, req);
free(req);
if (unlikely(!rc)) {
applog(LOG_ERR, "submit_upstream_work stratum_send_line failed");
goto out;
}
Expand Down

0 comments on commit 4611186

Please sign in to comment.