mirror of
https://github.com/GOSTSec/sgminer
synced 2025-01-22 20:44:19 +00:00
Implement rudimentary X-Mining-Hashrate support.
This commit is contained in:
parent
29c0f7bd37
commit
3267b534a8
@ -100,6 +100,7 @@ int opt_scantime = 60;
|
|||||||
int opt_expiry = 120;
|
int opt_expiry = 120;
|
||||||
int opt_bench_algo = -1;
|
int opt_bench_algo = -1;
|
||||||
static const bool opt_time = true;
|
static const bool opt_time = true;
|
||||||
|
unsigned long long global_hashrate;
|
||||||
|
|
||||||
#ifdef HAVE_OPENCL
|
#ifdef HAVE_OPENCL
|
||||||
int opt_dynamic_interval = 7;
|
int opt_dynamic_interval = 7;
|
||||||
@ -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);
|
local_secs = (double)total_diff.tv_sec + ((double)total_diff.tv_usec / 1000000.0);
|
||||||
decay_time(&rolling, local_mhashes_done / local_secs);
|
decay_time(&rolling, local_mhashes_done / local_secs);
|
||||||
|
global_hashrate = roundl(rolling) * 1000000;
|
||||||
|
|
||||||
timeval_subtract(&total_diff, &total_tv_end, &total_tv_start);
|
timeval_subtract(&total_diff, &total_tv_end, &total_tv_start);
|
||||||
total_secs = (double)total_diff.tv_sec +
|
total_secs = (double)total_diff.tv_sec +
|
||||||
|
1
miner.h
1
miner.h
@ -620,6 +620,7 @@ extern unsigned int local_work;
|
|||||||
extern unsigned int total_go, total_ro;
|
extern unsigned int total_go, total_ro;
|
||||||
extern const int opt_cutofftemp;
|
extern const int opt_cutofftemp;
|
||||||
extern int opt_log_interval;
|
extern int opt_log_interval;
|
||||||
|
extern unsigned long long global_hashrate;
|
||||||
|
|
||||||
#ifdef HAVE_OPENCL
|
#ifdef HAVE_OPENCL
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
23
util.c
23
util.c
@ -256,17 +256,17 @@ json_t *json_rpc_call(CURL *curl, const char *url,
|
|||||||
bool probe, bool longpoll, int *rolltime,
|
bool probe, bool longpoll, int *rolltime,
|
||||||
struct pool *pool, bool share)
|
struct pool *pool, bool share)
|
||||||
{
|
{
|
||||||
json_t *val, *err_val, *res_val;
|
char len_hdr[64], user_agent_hdr[128], *ghashrate;
|
||||||
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];
|
|
||||||
long timeout = longpoll ? (60 * 60) : 60;
|
long timeout = longpoll ? (60 * 60) : 60;
|
||||||
|
struct data_buffer all_data = {NULL, 0};
|
||||||
struct header_info hi = {NULL, 0, NULL};
|
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;
|
bool probing = false;
|
||||||
|
json_error_t err;
|
||||||
|
int rc;
|
||||||
|
|
||||||
memset(&err, 0, sizeof(err));
|
memset(&err, 0, sizeof(err));
|
||||||
|
|
||||||
@ -325,6 +325,13 @@ json_t *json_rpc_call(CURL *curl, const char *url,
|
|||||||
"Content-type: application/json");
|
"Content-type: application/json");
|
||||||
headers = curl_slist_append(headers,
|
headers = curl_slist_append(headers,
|
||||||
"X-Mining-Extensions: longpoll midstate rollntime submitold");
|
"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, len_hdr);
|
||||||
headers = curl_slist_append(headers, user_agent_hdr);
|
headers = curl_slist_append(headers, user_agent_hdr);
|
||||||
headers = curl_slist_append(headers, "Expect:"); /* disable Expect hdr*/
|
headers = curl_slist_append(headers, "Expect:"); /* disable Expect hdr*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user