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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150
diff --git a/cgminer.c b/cgminer.c
index 81e29ec..3f315d8 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -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)
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)
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)
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 {
};
/* 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)
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)
struct timeval start, end;
CURL *curl = NULL;
int failures = 0;
- bool rolltime;
+ int rolltime;
curl = curl_easy_init();
if (unlikely(!curl)) {
diff --git a/miner.h b/miner.h
index 69cdcf2..8675195 100644
--- a/miner.h
+++ b/miner.h
@@ -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 {
bool mined;
bool clone;
bool cloned;
- bool rolltime;
+ int rolltime;
bool longpoll;
bool stale;
bool mandatory;
diff --git a/util.c b/util.c
index 509d938..703be54 100644
--- a/util.c
+++ b/util.c
@@ -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)
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)
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,
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,
hi.lp_path = NULL;
}
- *rolltime = hi.has_rolltime;
+ *rolltime = hi.rolltime;
val = JSON_LOADS(all_data.buf, &err);
if (!val) {