From 9ce0db510028dda60a7f0819f77f51f3eb62be5e Mon Sep 17 00:00:00 2001 From: pooler Date: Wed, 1 Feb 2012 03:59:08 +0100 Subject: [PATCH] Add "X-Mining-Extensions: midstate" to HTTP headers Drop support for the the deprecated "midstate" and "hash1" fields. --- cpu-miner.c | 14 -------------- util.c | 10 ++++++---- 2 files changed, 6 insertions(+), 18 deletions(-) diff --git a/cpu-miner.c b/cpu-miner.c index f9e1139..7c4fc32 100644 --- a/cpu-miner.c +++ b/cpu-miner.c @@ -207,8 +207,6 @@ static struct option options[] = { struct work { unsigned char data[128]; - unsigned char hash1[64]; - unsigned char midstate[32]; unsigned char target[32]; unsigned char hash[32]; @@ -242,22 +240,10 @@ static bool jobj_binary(const json_t *obj, const char *key, static bool work_decode(const json_t *val, struct work *work) { - if (unlikely(!jobj_binary(val, "midstate", - work->midstate, sizeof(work->midstate)))) { - applog(LOG_ERR, "JSON inval midstate"); - goto err_out; - } - if (unlikely(!jobj_binary(val, "data", work->data, sizeof(work->data)))) { applog(LOG_ERR, "JSON inval data"); goto err_out; } - - if (unlikely(!jobj_binary(val, "hash1", work->hash1, sizeof(work->hash1)))) { - applog(LOG_ERR, "JSON inval hash1"); - goto err_out; - } - if (unlikely(!jobj_binary(val, "target", work->target, sizeof(work->target)))) { applog(LOG_ERR, "JSON inval target"); goto err_out; diff --git a/util.c b/util.c index 3806c4a..609bf8a 100644 --- a/util.c +++ b/util.c @@ -213,7 +213,7 @@ json_t *json_rpc_call(CURL *curl, const char *url, struct upload_buffer upload_data; json_error_t err = { }; struct curl_slist *headers = NULL; - char len_hdr[64], user_agent_hdr[128]; + char len_hdr[64]; char curl_err_str[CURL_ERROR_SIZE]; long timeout = opt_timeout; struct header_info hi = { }; @@ -255,12 +255,14 @@ json_t *json_rpc_call(CURL *curl, const char *url, upload_data.len = strlen(rpc_req); sprintf(len_hdr, "Content-Length: %lu", (unsigned long) upload_data.len); - sprintf(user_agent_hdr, "User-Agent: %s", PACKAGE_STRING); headers = curl_slist_append(headers, - "Content-type: application/json"); + "Content-Type: application/json"); headers = curl_slist_append(headers, len_hdr); - headers = curl_slist_append(headers, user_agent_hdr); + headers = curl_slist_append(headers, "User-Agent: " PACKAGE_STRING); + headers = curl_slist_append(headers, + "X-Mining-Extensions: midstate"); + headers = curl_slist_append(headers, "Accept:"); /* disable Accept hdr*/ headers = curl_slist_append(headers, "Expect:"); /* disable Expect hdr*/ curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);