|
|
@@ -1453,8 +1453,6 @@ static void calc_midstate(struct work *work)
|
|
|
|
|
|
static bool work_decode(const json_t *val, struct work *work)
|
|
|
{
|
|
|
- unsigned char bits = 0, i;
|
|
|
-
|
|
|
if (unlikely(detect_algo == 1)) {
|
|
|
json_t *tmp = json_object_get(val, "algorithm");
|
|
|
const char *v = tmp ? json_string_value(tmp) : "";
|
|
|
@@ -1526,22 +1524,6 @@ static bool work_decode(const json_t *val, struct work *work)
|
|
|
work->target[p] = c;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- for (i = 32; i--; )
|
|
|
- {
|
|
|
- if (work->target[i])
|
|
|
- {
|
|
|
- unsigned char j = ~work->target[i];
|
|
|
- while (j & 0x80)
|
|
|
- {
|
|
|
- ++bits;
|
|
|
- j <<= 1;
|
|
|
- }
|
|
|
- break;
|
|
|
- }
|
|
|
- bits += 8;
|
|
|
- }
|
|
|
- work->difficulty = pow(2, bits - 32);
|
|
|
|
|
|
memset(work->hash, 0, sizeof(work->hash));
|
|
|
|
|
|
@@ -2176,6 +2158,7 @@ static bool submit_upstream_work(const struct work *work, CURL *curl, bool resub
|
|
|
double work_to_submit = tdiff(&tv_submit,
|
|
|
(struct timeval *)&(work->tv_work_found));
|
|
|
double submit_time = tdiff(&tv_submit_reply, &tv_submit);
|
|
|
+ int diffplaces = 3;
|
|
|
|
|
|
tm = localtime(&(work->tv_getwork.tv_sec));
|
|
|
memcpy(&tm_getwork, tm, sizeof(struct tm));
|
|
|
@@ -2190,10 +2173,14 @@ static bool submit_upstream_work(const struct work *work, CURL *curl, bool resub
|
|
|
else
|
|
|
strcpy(workclone, "O");
|
|
|
|
|
|
- sprintf(worktime, " <-%08lx.%08lx M:%c G:%02d:%02d:%02d:%1.3f %s (%1.3f) W:%1.3f (%1.3f) S:%1.3f R:%02d:%02d:%02d",
|
|
|
+ if (work->work_difficulty < 1)
|
|
|
+ diffplaces = 6;
|
|
|
+
|
|
|
+ sprintf(worktime, " <-%08lx.%08lx M:%c D:%1.*f G:%02d:%02d:%02d:%1.3f %s (%1.3f) W:%1.3f (%1.3f) S:%1.3f R:%02d:%02d:%02d",
|
|
|
(unsigned long)swab32(*(uint32_t *)&(work->data[28])),
|
|
|
(unsigned long)swab32(*(uint32_t *)&(work->data[24])),
|
|
|
- work->getwork_mode, tm_getwork.tm_hour, tm_getwork.tm_min,
|
|
|
+ work->getwork_mode, diffplaces, work->work_difficulty,
|
|
|
+ tm_getwork.tm_hour, tm_getwork.tm_min,
|
|
|
tm_getwork.tm_sec, getwork_time, workclone,
|
|
|
getwork_to_work, work_time, work_to_submit, submit_time,
|
|
|
tm_submit_reply.tm_hour, tm_submit_reply.tm_min,
|
|
|
@@ -2206,9 +2193,9 @@ static bool submit_upstream_work(const struct work *work, CURL *curl, bool resub
|
|
|
* same time is zero so there is no point adding extra locking */
|
|
|
if (json_is_null(res) || json_is_true(res)) {
|
|
|
cgpu->accepted++;
|
|
|
- cgpu->accepted_weighed += work->difficulty;
|
|
|
+ cgpu->accepted_weighed += work->work_difficulty;
|
|
|
total_accepted++;
|
|
|
- total_accepted_weighed += work->difficulty;
|
|
|
+ total_accepted_weighed += work->work_difficulty;
|
|
|
pool->accepted++;
|
|
|
pool->seq_rejects = 0;
|
|
|
cgpu->last_share_pool = pool->pool_no;
|
|
|
@@ -2373,6 +2360,25 @@ static inline struct pool *select_pool(bool lagging)
|
|
|
return pool;
|
|
|
}
|
|
|
|
|
|
+static double DIFFEXACTONE = 26959946667150639794667015087019630673637144422540572481103610249216.0;
|
|
|
+
|
|
|
+/*
|
|
|
+ * Calculate the work share difficulty
|
|
|
+ */
|
|
|
+static void calc_diff(struct work *work)
|
|
|
+{
|
|
|
+ double targ;
|
|
|
+ int i;
|
|
|
+
|
|
|
+ targ = 0;
|
|
|
+ for (i = 31; i >= 0; i--) {
|
|
|
+ targ *= 256;
|
|
|
+ targ += work->target[i];
|
|
|
+ }
|
|
|
+
|
|
|
+ work->work_difficulty = DIFFEXACTONE / (targ ? : DIFFEXACTONE);
|
|
|
+}
|
|
|
+
|
|
|
static void get_benchmark_work(struct work *work)
|
|
|
{
|
|
|
// Use a random work block pulled from a pool
|
|
|
@@ -2388,6 +2394,7 @@ static void get_benchmark_work(struct work *work)
|
|
|
gettimeofday(&(work->tv_getwork), NULL);
|
|
|
memcpy(&(work->tv_getwork_reply), &(work->tv_getwork), sizeof(struct timeval));
|
|
|
work->getwork_mode = GETWORK_MODE_BENCHMARK;
|
|
|
+ calc_diff(work);
|
|
|
}
|
|
|
|
|
|
static char *prepare_rpc_req(struct work *work, enum pool_protocol proto, const char *lpid)
|
|
|
@@ -2513,6 +2520,7 @@ tryagain:
|
|
|
work->pool = pool;
|
|
|
work->longpoll = false;
|
|
|
work->getwork_mode = GETWORK_MODE_POOL;
|
|
|
+ calc_diff(work);
|
|
|
total_getworks++;
|
|
|
pool->getwork_requested++;
|
|
|
|
|
|
@@ -4658,6 +4666,7 @@ tryagain:
|
|
|
memcpy(&(work->tv_getwork), &tv_getwork, sizeof(struct timeval));
|
|
|
memcpy(&(work->tv_getwork_reply), &tv_getwork_reply, sizeof(struct timeval));
|
|
|
work->getwork_mode = GETWORK_MODE_TESTPOOL;
|
|
|
+ calc_diff(work);
|
|
|
applog(LOG_DEBUG, "Pushing pooltest work to base pool");
|
|
|
|
|
|
tq_push(thr_info[stage_thr_id].q, work);
|
|
|
@@ -5281,6 +5290,7 @@ static void convert_to_work(json_t *val, int rolltime, struct pool *pool, struct
|
|
|
memcpy(&(work->tv_getwork), tv_lp, sizeof(struct timeval));
|
|
|
memcpy(&(work->tv_getwork_reply), tv_lp_reply, sizeof(struct timeval));
|
|
|
work->getwork_mode = GETWORK_MODE_LP;
|
|
|
+ calc_diff(work);
|
|
|
|
|
|
if (pool->enabled == POOL_REJECTING)
|
|
|
work->mandatory = true;
|