Browse Source

Extend nrolltime to support the expiry= parameter. Do this by turning the rolltime bool into an integer set to the expiry time. If the pool supports rolltime but not expiry= then set the expiry time to the standard scantime.

nfactor-troky
ckolivas 13 years ago
parent
commit
c5a21fabf0
  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) @@ -1622,7 +1622,7 @@ static bool submit_upstream_work(const struct work *work, CURL *curl)
int thr_id = work->thr_id;
struct cgpu_info *cgpu = thr_info[thr_id].cgpu;
struct pool *pool = work->pool;
bool rolltime;
int rolltime;
uint32_t *hash32;
char hashshow[64+1] = "";
@ -2163,6 +2163,9 @@ static bool stale_work(struct work *work, bool share) @@ -2163,6 +2163,9 @@ static bool stale_work(struct work *work, bool share)
if (share) {
if ((now.tv_sec - work->tv_staged.tv_sec) >= opt_expiry)
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)
return true;
@ -3380,7 +3383,7 @@ static bool pool_active(struct pool *pool, bool pinging) @@ -3380,7 +3383,7 @@ static bool pool_active(struct pool *pool, bool pinging)
bool ret = false;
json_t *val;
CURL *curl;
bool rolltime;
int rolltime;
curl = curl_easy_init();
if (unlikely(!curl)) {
@ -3566,8 +3569,7 @@ static inline bool should_roll(struct work *work) @@ -3566,8 +3569,7 @@ static inline bool should_roll(struct work *work)
static inline bool can_roll(struct work *work)
{
return (work->pool && !stale_work(work, false) && work->rolltime &&
work->rolls < 11 && !work->clone);
return (work->pool && !stale_work(work, false) && work->rolltime && !work->clone);
}
static void roll_work(struct work *work)
@ -4015,9 +4017,10 @@ enum { @@ -4015,9 +4017,10 @@ enum {
};
/* 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;
int rolled = 0;
bool rc;
work = make_work();
@ -4052,7 +4055,7 @@ static void convert_to_work(json_t *val, bool rolltime, struct pool *pool) @@ -4052,7 +4055,7 @@ static void convert_to_work(json_t *val, bool rolltime, struct pool *pool)
work_clone = make_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->longpoll = false;
applog(LOG_DEBUG, "Pushing rolled converted work to stage thread");
@ -4113,7 +4116,7 @@ static void *longpoll_thread(void *userdata) @@ -4113,7 +4116,7 @@ static void *longpoll_thread(void *userdata)
struct timeval start, end;
CURL *curl = NULL;
int failures = 0;
bool rolltime;
int rolltime;
curl = curl_easy_init();
if (unlikely(!curl)) {

4
miner.h

@ -530,7 +530,7 @@ extern pthread_rwlock_t netacc_lock; @@ -530,7 +530,7 @@ extern pthread_rwlock_t netacc_lock;
extern const uint32_t sha256_init_state[];
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);
extern char *bin2hex(const unsigned char *p, size_t len);
extern bool hex2bin(unsigned char *p, const char *hexstr, size_t len);
@ -732,7 +732,7 @@ struct work { @@ -732,7 +732,7 @@ struct work {
bool mined;
bool clone;
bool cloned;
bool rolltime;
int rolltime;
bool longpoll;
bool stale;
bool mandatory;

17
util.c

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

Loading…
Cancel
Save