Browse Source

Merge with master

nfactor-troky
Con Kolivas 13 years ago
parent
commit
8d3eeed2e9
  1. 17
      cgminer.c
  2. 4
      miner.h
  3. 17
      util.c

17
cgminer.c

@ -1622,7 +1622,7 @@ static bool submit_upstream_work(const struct work *work, CURL *curl)
int thr_id = work->thr_id; int thr_id = work->thr_id;
struct cgpu_info *cgpu = thr_info[thr_id].cgpu; struct cgpu_info *cgpu = thr_info[thr_id].cgpu;
struct pool *pool = work->pool; struct pool *pool = work->pool;
bool rolltime; int rolltime;
uint32_t *hash32; uint32_t *hash32;
char hashshow[64+1] = ""; char hashshow[64+1] = "";
@ -2163,6 +2163,9 @@ static bool stale_work(struct work *work, bool share)
if (share) { if (share) {
if ((now.tv_sec - work->tv_staged.tv_sec) >= opt_expiry) if ((now.tv_sec - work->tv_staged.tv_sec) >= opt_expiry)
return true; return true;
} else if (work->rolls) {
if ((now.tv_sec - work->tv_staged.tv_sec) >= work->rolltime)
return true;
} else if ((now.tv_sec - work->tv_staged.tv_sec) >= opt_scantime) } else if ((now.tv_sec - work->tv_staged.tv_sec) >= opt_scantime)
return true; return true;
@ -3385,7 +3388,7 @@ static bool pool_active(struct pool *pool, bool pinging)
bool ret = false; bool ret = false;
json_t *val; json_t *val;
CURL *curl; CURL *curl;
bool rolltime; int rolltime;
curl = curl_easy_init(); curl = curl_easy_init();
if (unlikely(!curl)) { if (unlikely(!curl)) {
@ -3571,8 +3574,7 @@ static inline bool should_roll(struct work *work)
static inline bool can_roll(struct work *work) static inline bool can_roll(struct work *work)
{ {
return (work->pool && !stale_work(work, false) && work->rolltime && return (work->pool && !stale_work(work, false) && work->rolltime && !work->clone);
work->rolls < 11 && !work->clone);
} }
static void roll_work(struct work *work) static void roll_work(struct work *work)
@ -4022,9 +4024,10 @@ enum {
}; };
/* Stage another work item from the work returned in a longpoll */ /* Stage another work item from the work returned in a longpoll */
static void convert_to_work(json_t *val, bool rolltime, struct pool *pool) static void convert_to_work(json_t *val, int rolltime, struct pool *pool)
{ {
struct work *work, *work_clone; struct work *work, *work_clone;
int rolled = 0;
bool rc; bool rc;
work = make_work(); work = make_work();
@ -4059,7 +4062,7 @@ static void convert_to_work(json_t *val, bool rolltime, struct pool *pool)
work_clone = make_work(); work_clone = make_work();
memcpy(work_clone, work, sizeof(struct work)); memcpy(work_clone, work, sizeof(struct work));
while (reuse_work(work)) { while (reuse_work(work) && rolled++ < mining_threads) {
work_clone->clone = true; work_clone->clone = true;
work_clone->longpoll = false; work_clone->longpoll = false;
applog(LOG_DEBUG, "Pushing rolled converted work to stage thread"); applog(LOG_DEBUG, "Pushing rolled converted work to stage thread");
@ -4120,7 +4123,7 @@ static void *longpoll_thread(void *userdata)
struct timeval start, end; struct timeval start, end;
CURL *curl = NULL; CURL *curl = NULL;
int failures = 0; int failures = 0;
bool rolltime; int rolltime;
curl = curl_easy_init(); curl = curl_easy_init();
if (unlikely(!curl)) { if (unlikely(!curl)) {

4
miner.h

@ -531,7 +531,7 @@ extern pthread_rwlock_t netacc_lock;
extern const uint32_t sha256_init_state[]; extern const uint32_t sha256_init_state[];
extern json_t *json_rpc_call(CURL *curl, const char *url, const char *userpass, extern json_t *json_rpc_call(CURL *curl, const char *url, const char *userpass,
const char *rpc_req, bool, bool, bool *, const char *rpc_req, bool, bool, int *,
struct pool *pool, bool); struct pool *pool, bool);
extern char *bin2hex(const unsigned char *p, size_t len); extern char *bin2hex(const unsigned char *p, size_t len);
extern bool hex2bin(unsigned char *p, const char *hexstr, size_t len); extern bool hex2bin(unsigned char *p, const char *hexstr, size_t len);
@ -733,7 +733,7 @@ struct work {
bool mined; bool mined;
bool clone; bool clone;
bool cloned; bool cloned;
bool rolltime; int rolltime;
bool longpoll; bool longpoll;
bool stale; bool stale;
bool mandatory; bool mandatory;

17
util.c

@ -56,7 +56,7 @@ struct upload_buffer {
struct header_info { struct header_info {
char *lp_path; char *lp_path;
bool has_rolltime; int rolltime;
char *reason; char *reason;
}; };
@ -160,8 +160,13 @@ static size_t resp_hdr_cb(void *ptr, size_t size, size_t nmemb, void *user_data)
if (!strncasecmp("N", val, 1)) { if (!strncasecmp("N", val, 1)) {
applog(LOG_DEBUG, "X-Roll-Ntime: N found"); applog(LOG_DEBUG, "X-Roll-Ntime: N found");
} else { } else {
applog(LOG_DEBUG, "X-Roll-Ntime found"); /* Check to see if expire= is supported and if not, set
hi->has_rolltime = true; * the rolltime to the default scantime */
if (strlen(val) > 7 && !strncasecmp("expire=", val, 7))
sscanf(val + 7, "%d", &hi->rolltime);
else
hi->rolltime = opt_scantime;
applog(LOG_DEBUG, "X-Roll-Ntime expiry set to %d", hi->rolltime);
} }
} }
@ -248,7 +253,7 @@ static void set_nettime(void)
json_t *json_rpc_call(CURL *curl, const char *url, json_t *json_rpc_call(CURL *curl, const char *url,
const char *userpass, const char *rpc_req, const char *userpass, const char *rpc_req,
bool probe, bool longpoll, bool *rolltime, bool probe, bool longpoll, int *rolltime,
struct pool *pool, bool share) struct pool *pool, bool share)
{ {
json_t *val, *err_val, *res_val; json_t *val, *err_val, *res_val;
@ -260,7 +265,7 @@ json_t *json_rpc_call(CURL *curl, const char *url,
char len_hdr[64], user_agent_hdr[128]; char len_hdr[64], user_agent_hdr[128];
char curl_err_str[CURL_ERROR_SIZE]; char curl_err_str[CURL_ERROR_SIZE];
long timeout = longpoll ? (60 * 60) : 60; long timeout = longpoll ? (60 * 60) : 60;
struct header_info hi = {NULL, false, NULL}; struct header_info hi = {NULL, 0, NULL};
bool probing = false; bool probing = false;
memset(&err, 0, sizeof(err)); memset(&err, 0, sizeof(err));
@ -375,7 +380,7 @@ json_t *json_rpc_call(CURL *curl, const char *url,
hi.lp_path = NULL; hi.lp_path = NULL;
} }
*rolltime = hi.has_rolltime; *rolltime = hi.rolltime;
val = JSON_LOADS(all_data.buf, &err); val = JSON_LOADS(all_data.buf, &err);
if (!val) { if (!val) {

Loading…
Cancel
Save