Browse Source

Implement rudimentary X-Mining-Hashrate support.

nfactor-troky
Con Kolivas 12 years ago
parent
commit
3267b534a8
  1. 2
      cgminer.c
  2. 1
      miner.h
  3. 23
      util.c

2
cgminer.c

@ -100,6 +100,7 @@ int opt_scantime = 60; @@ -100,6 +100,7 @@ int opt_scantime = 60;
int opt_expiry = 120;
int opt_bench_algo = -1;
static const bool opt_time = true;
unsigned long long global_hashrate;
#ifdef HAVE_OPENCL
int opt_dynamic_interval = 7;
@ -3400,6 +3401,7 @@ static void hashmeter(int thr_id, struct timeval *diff, @@ -3400,6 +3401,7 @@ static void hashmeter(int thr_id, struct timeval *diff,
local_secs = (double)total_diff.tv_sec + ((double)total_diff.tv_usec / 1000000.0);
decay_time(&rolling, local_mhashes_done / local_secs);
global_hashrate = roundl(rolling) * 1000000;
timeval_subtract(&total_diff, &total_tv_end, &total_tv_start);
total_secs = (double)total_diff.tv_sec +

1
miner.h

@ -620,6 +620,7 @@ extern unsigned int local_work; @@ -620,6 +620,7 @@ extern unsigned int local_work;
extern unsigned int total_go, total_ro;
extern const int opt_cutofftemp;
extern int opt_log_interval;
extern unsigned long long global_hashrate;
#ifdef HAVE_OPENCL
typedef struct {

23
util.c

@ -256,17 +256,17 @@ json_t *json_rpc_call(CURL *curl, const char *url, @@ -256,17 +256,17 @@ json_t *json_rpc_call(CURL *curl, const char *url,
bool probe, bool longpoll, int *rolltime,
struct pool *pool, bool share)
{
json_t *val, *err_val, *res_val;
int rc;
struct data_buffer all_data = {NULL, 0};
struct upload_buffer upload_data;
json_error_t err;
struct curl_slist *headers = NULL;
char len_hdr[64], user_agent_hdr[128];
char curl_err_str[CURL_ERROR_SIZE];
char len_hdr[64], user_agent_hdr[128], *ghashrate;
long timeout = longpoll ? (60 * 60) : 60;
struct data_buffer all_data = {NULL, 0};
struct header_info hi = {NULL, 0, NULL};
char curl_err_str[CURL_ERROR_SIZE];
struct curl_slist *headers = NULL;
struct upload_buffer upload_data;
json_t *val, *err_val, *res_val;
bool probing = false;
json_error_t err;
int rc;
memset(&err, 0, sizeof(err));
@ -325,6 +325,13 @@ json_t *json_rpc_call(CURL *curl, const char *url, @@ -325,6 +325,13 @@ json_t *json_rpc_call(CURL *curl, const char *url,
"Content-type: application/json");
headers = curl_slist_append(headers,
"X-Mining-Extensions: longpoll midstate rollntime submitold");
if (likely(global_hashrate)) {
asprintf(&ghashrate, "X-Mining-Hashrate: %llu", global_hashrate);
headers = curl_slist_append(headers, ghashrate);
free(ghashrate);
}
headers = curl_slist_append(headers, len_hdr);
headers = curl_slist_append(headers, user_agent_hdr);
headers = curl_slist_append(headers, "Expect:"); /* disable Expect hdr*/

Loading…
Cancel
Save