mirror of
https://github.com/GOSTSec/sgminer
synced 2025-01-29 16:04:33 +00:00
Calculate work difficulty for each getwork and display with WorkTime debug
This commit is contained in:
parent
8f4ccebf0d
commit
923b9e0d86
3
README
3
README
@ -477,12 +477,13 @@ and pipe the output directly to that command.
|
||||
The WorkTime details 'debug' option adds details on the end of each line
|
||||
displayed for Accepted or Rejected work done. An example would be:
|
||||
|
||||
<-00000059.ed4834a3 M:X G:17:02:38:0.405 C:1.855 (2.995) W:3.440 (0.000) S:0.461 R:17:02:47
|
||||
<-00000059.ed4834a3 M:X D:1.0 G:17:02:38:0.405 C:1.855 (2.995) W:3.440 (0.000) S:0.461 R:17:02:47
|
||||
|
||||
The first 2 hex codes are the previous block hash, the rest are reported in
|
||||
seconds unless stated otherwise:
|
||||
The previous hash is followed by the getwork mode used M:X where X is one of
|
||||
P:Pool, T:Test Pool, L:LP or B:Benchmark,
|
||||
then D:d.ddd is the difficulty required to get a share from the work,
|
||||
then G:hh:mm:ss:n.nnn, which is when the getwork or LP was sent to the pool and
|
||||
the n.nnn is how long it took to reply,
|
||||
followed by 'O' on it's own if it is an original getwork, or 'C:n.nnn' if it was
|
||||
|
32
cgminer.c
32
cgminer.c
@ -1833,6 +1833,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));
|
||||
@ -1847,10 +1848,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,
|
||||
@ -2026,6 +2031,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
|
||||
@ -2041,6 +2065,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 bool get_upstream_work(struct work *work, CURL *curl)
|
||||
@ -2088,6 +2113,7 @@ static bool get_upstream_work(struct work *work, CURL *curl)
|
||||
work->pool = pool;
|
||||
work->longpoll = false;
|
||||
work->getwork_mode = GETWORK_MODE_POOL;
|
||||
calc_diff(work);
|
||||
total_getworks++;
|
||||
pool->getwork_requested++;
|
||||
|
||||
@ -3897,6 +3923,7 @@ static bool pool_active(struct pool *pool, bool pinging)
|
||||
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);
|
||||
@ -4519,6 +4546,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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user