|
@@ -97,6 +97,7 @@ int getwork_error(struct MHD_Connection *conn, int16_t errcode, const char *errm
|
|
|
char * const reply = malloc(replysz);
|
|
char * const reply = malloc(replysz);
|
|
|
replysz = snprintf(reply, replysz, "{\"result\":null,\"error\":{\"code\":%d,\"message\":\"%s\"},\"id\":%s}", errcode, errmsg, idstr ?: "0");
|
|
replysz = snprintf(reply, replysz, "{\"result\":null,\"error\":{\"code\":%d,\"message\":\"%s\"},\"id\":%s}", errcode, errmsg, idstr ?: "0");
|
|
|
struct MHD_Response * const resp = MHD_create_response_from_buffer(replysz, reply, MHD_RESPMEM_MUST_FREE);
|
|
struct MHD_Response * const resp = MHD_create_response_from_buffer(replysz, reply, MHD_RESPMEM_MUST_FREE);
|
|
|
|
|
+ MHD_add_response_header(resp, MHD_HTTP_HEADER_CONTENT_TYPE, "application/json");
|
|
|
const int ret = MHD_queue_response(conn, 500, resp);
|
|
const int ret = MHD_queue_response(conn, 500, resp);
|
|
|
MHD_destroy_response(resp);
|
|
MHD_destroy_response(resp);
|
|
|
return ret;
|
|
return ret;
|
|
@@ -232,6 +233,7 @@ int handle_getwork(struct MHD_Connection *conn, bytes_t *upbuf)
|
|
|
sprintf(reply, "{\"error\":null,\"result\":%s,\"id\":%s}",
|
|
sprintf(reply, "{\"error\":null,\"result\":%s,\"id\":%s}",
|
|
|
rejreason ? "false" : "true", idstr);
|
|
rejreason ? "false" : "true", idstr);
|
|
|
resp = MHD_create_response_from_buffer(replysz, reply, MHD_RESPMEM_MUST_FREE);
|
|
resp = MHD_create_response_from_buffer(replysz, reply, MHD_RESPMEM_MUST_FREE);
|
|
|
|
|
+ MHD_add_response_header(resp, MHD_HTTP_HEADER_CONTENT_TYPE, "application/json");
|
|
|
if (rejreason)
|
|
if (rejreason)
|
|
|
MHD_add_response_header(resp, "X-Reject-Reason", rejreason);
|
|
MHD_add_response_header(resp, "X-Reject-Reason", rejreason);
|
|
|
ret = MHD_queue_response(conn, 200, resp);
|
|
ret = MHD_queue_response(conn, 200, resp);
|
|
@@ -246,7 +248,7 @@ int handle_getwork(struct MHD_Connection *conn, bytes_t *upbuf)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
{
|
|
{
|
|
|
- const size_t replysz = 451 + idstr_sz;
|
|
|
|
|
|
|
+ const size_t replysz = 590 + idstr_sz;
|
|
|
|
|
|
|
|
work = get_work(thr);
|
|
work = get_work(thr);
|
|
|
reply = malloc(replysz);
|
|
reply = malloc(replysz);
|
|
@@ -254,14 +256,15 @@ int handle_getwork(struct MHD_Connection *conn, bytes_t *upbuf)
|
|
|
bin2hex(&reply[108], work->data, 128);
|
|
bin2hex(&reply[108], work->data, 128);
|
|
|
memcpy(&reply[364], "\",\"midstate\":\"", 14);
|
|
memcpy(&reply[364], "\",\"midstate\":\"", 14);
|
|
|
bin2hex(&reply[378], work->midstate, 32);
|
|
bin2hex(&reply[378], work->midstate, 32);
|
|
|
- memcpy(&reply[442], "\"},\"id\":", 8);
|
|
|
|
|
- memcpy(&reply[450], idstr ?: "0", idstr_sz);
|
|
|
|
|
- memcpy(&reply[450 + idstr_sz], "}", 1);
|
|
|
|
|
|
|
+ memcpy(&reply[442], "\",\"hash1\":\"00000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000010000\"},\"id\":", 147);
|
|
|
|
|
+ memcpy(&reply[589], idstr ?: "0", idstr_sz);
|
|
|
|
|
+ memcpy(&reply[589 + idstr_sz], "}", 1);
|
|
|
|
|
|
|
|
timer_set_now(&work->tv_work_start);
|
|
timer_set_now(&work->tv_work_start);
|
|
|
HASH_ADD_KEYPTR(hh, client->work, work->data, 76, work);
|
|
HASH_ADD_KEYPTR(hh, client->work, work->data, 76, work);
|
|
|
|
|
|
|
|
resp = MHD_create_response_from_buffer(replysz, reply, MHD_RESPMEM_MUST_FREE);
|
|
resp = MHD_create_response_from_buffer(replysz, reply, MHD_RESPMEM_MUST_FREE);
|
|
|
|
|
+ MHD_add_response_header(resp, MHD_HTTP_HEADER_CONTENT_TYPE, "application/json");
|
|
|
ret = MHD_queue_response(conn, 200, resp);
|
|
ret = MHD_queue_response(conn, 200, resp);
|
|
|
MHD_destroy_response(resp);
|
|
MHD_destroy_response(resp);
|
|
|
}
|
|
}
|