diff --git a/pool/page_allwork.php b/pool/page_allwork.php index d190f398..e289e8ac 100644 --- a/pool/page_allwork.php +++ b/pool/page_allwork.php @@ -10,6 +10,7 @@ function doallwork($data, $user) $totshare = 0; $totdiff = 0; + $totshrate = 0; $totinvalid = 0; $totrate = 0; $offset = 0; @@ -26,13 +27,13 @@ function doallwork($data, $user) { $pg .= workuser($data, $ans['username:'.$i], $offset, $totshare, $totdiff, - $totinvalid, $totrate, + $totshrate, $totinvalid, $totrate, $blockacc, $blockreward, 3600); } } - $pg .= worktotal($offset, $totshare, $totdiff, $totinvalid, $totrate, - $blockacc, $blockreward); + $pg .= worktotal($offset, $totshare, $totdiff, $totshrate, $totinvalid, + $totrate, $blockacc, $blockreward); $pg .= "\n"; diff --git a/pool/page_workers.php b/pool/page_workers.php index c0f638c2..07987311 100644 --- a/pool/page_workers.php +++ b/pool/page_workers.php @@ -10,9 +10,10 @@ function worktitle($data, $user) $pg .= "<$r id=srtlst data-sf=n2>:Last Share"; $pg .= 'Shares'; $pg .= "<$r id=srtdiff data-sf=r4>:Diff"; - $pg .= "<$r id=srtinv data-sf=r5>:Invalid"; + $pg .= "<$r id=srtshrate data-sf=r5>:Share Rate"; + $pg .= "<$r id=srtinv data-sf=r6>:Invalid"; $pg .= 'Block %'; - $pg .= "<$r id=srtrate data-sf=r7>:Hash Rate"; + $pg .= "<$r id=srtrate data-sf=r8>:Hash Rate"; $pg .= "\n"; return $pg; } @@ -23,7 +24,7 @@ function workhashorder($a, $b) } # function workuser($data, $user, &$offset, &$totshare, &$totdiff, - &$totinvalid, &$totrate, &$blockacc, + &$totshrate, &$totinvalid, &$totrate, &$blockacc, &$blockreward, $old = false, $srt = false, $one = false, &$title) { @@ -63,6 +64,8 @@ function workuser($data, $user, &$offset, &$totshare, &$totdiff, 'w_diffacc' => $ans['w_diffacc:'.$i], 'w_diffinv' => $ans['w_diffinv:'.$i], 'w_lastdiff' => $ans['w_lastdiff:'.$i], + 'w_active_diffacc' => $ans['w_active_diffacc:'.$i], + 'w_active_start' => $ans['w_active_start:'.$i], 'w_uhr' => $uhr); } @@ -99,6 +102,22 @@ function workuser($data, $user, &$offset, &$totshare, &$totdiff, $pg .= "$shareacc"; $pg .= "$diffacc"; + $acthr = '0'; + $acthrv = 0; + $actstt = $all[$i]['w_active_start']; + if ($actstt > 0) + { + $elapsed = $ans['STAMP'] - $actstt; + if ($elapsed > 0) + { + $acthrv = $all[$i]['w_active_diffacc'] * + pow(2,32) / $elapsed; + $acthr = dsprate($acthrv); + $totshrate += $acthrv; + } + } + $pg .= "$acthr"; + $dinv = $all[$i]['w_diffinv']; $dtot = $dacc + $dinv; if ($dtot > 0) @@ -144,9 +163,11 @@ function workuser($data, $user, &$offset, &$totshare, &$totdiff, return $pg; } # -function worktotal($offset, $totshare, $totdiff, $totinvalid, $totrate, $blockacc, $blockreward) +function worktotal($offset, $totshare, $totdiff, $totshrate, $totinvalid, + $totrate, $blockacc, $blockreward) { $pg = ''; + $totshrate = dsprate($totshrate); $totrate = dsprate($totrate); if (($offset % 2) == 0) $row = 'even'; @@ -157,6 +178,7 @@ function worktotal($offset, $totshare, $totdiff, $totinvalid, $totrate, $blockac $pg .= "$shareacc"; $diffacc = number_format($totdiff, 0); $pg .= "$diffacc"; + $pg .= "$totshrate"; $dtot = $totdiff + $totinvalid; if ($dtot > 0) $rej = number_format(100.0 * $totinvalid / $dtot, 3); @@ -180,6 +202,7 @@ function doworker($data, $user) $totshare = 0; $totdiff = 0; + $totshrate = 0; $totinvalid = 0; $totrate = 0; $offset = 0; @@ -187,11 +210,11 @@ function doworker($data, $user) $blockreward = 0; $pg .= worktitle($data, $user); - $pg .= workuser($data, $user, $offset, $totshare, $totdiff, $totinvalid, - $totrate, $blockacc, $blockreward, false, true, true, - $title); - $pg .= worktotal($offset, $totshare, $totdiff, $totinvalid, $totrate, - $blockacc, $blockreward); + $pg .= workuser($data, $user, $offset, $totshare, $totdiff, $totshrate, + $totinvalid, $totrate, $blockacc, $blockreward, + false, true, true, $title); + $pg .= worktotal($offset, $totshare, $totdiff, $totshrate, $totinvalid, + $totrate, $blockacc, $blockreward); if (false && $blockacc > 0 && $blockreward > 0) { diff --git a/src/ckdb.h b/src/ckdb.h index 05052701..b3feaaa7 100644 --- a/src/ckdb.h +++ b/src/ckdb.h @@ -55,7 +55,7 @@ #define DB_VLOCK "1" #define DB_VERSION "1.0.0" -#define CKDB_VERSION DB_VERSION"-1.113" +#define CKDB_VERSION DB_VERSION"-1.120" #define WHERE_FFL " - from %s %s() line %d" #define WHERE_FFL_HERE __FILE__, __func__, __LINE__ @@ -1735,18 +1735,32 @@ typedef struct workerstatus { tv_t last_stats; tv_t last_idle; // Below gets reset on each block - double diffacc; - double diffinv; // Non-acc - double diffsta; - double diffdup; - double diffhi; - double diffrej; - double shareacc; - double shareinv; // Non-acc - double sharesta; - double sharedup; - double sharehi; - double sharerej; + double block_diffacc; + double block_diffinv; // Non-acc + double block_diffsta; + double block_diffdup; + double block_diffhi; + double block_diffrej; + double block_shareacc; + double block_shareinv; // Non-acc + double block_sharesta; + double block_sharedup; + double block_sharehi; + double block_sharerej; + // Below gets reset on each idle + double active_diffacc; + double active_diffinv; // Non-acc + double active_diffsta; + double active_diffdup; + double active_diffhi; + double active_diffrej; + double active_shareacc; + double active_shareinv; // Non-acc + double active_sharesta; + double active_sharedup; + double active_sharehi; + double active_sharerej; + tv_t active_start; } WORKERSTATUS; #define ALLOC_WORKERSTATUS 1000 diff --git a/src/ckdb_cmd.c b/src/ckdb_cmd.c index 656ac868..c7b4565a 100644 --- a/src/ckdb_cmd.c +++ b/src/ckdb_cmd.c @@ -1395,18 +1395,18 @@ static char *cmd_percent(char *cmd, char *id, tv_t *now, USERS *users) ws_item = get_workerstatus(users->userid, workers->workername); if (ws_item) { DATA_WORKERSTATUS(workerstatus, ws_item); - t_diffacc += workerstatus->diffacc; - t_diffinv += workerstatus->diffinv; - t_diffsta += workerstatus->diffsta; - t_diffdup += workerstatus->diffdup; - t_diffhi += workerstatus->diffhi; - t_diffrej += workerstatus->diffrej; - t_shareacc += workerstatus->shareacc; - t_shareinv += workerstatus->shareinv; - t_sharesta += workerstatus->sharesta; - t_sharedup += workerstatus->sharedup; - t_sharehi += workerstatus->sharehi; - t_sharerej += workerstatus->sharerej; + t_diffacc += workerstatus->block_diffacc; + t_diffinv += workerstatus->block_diffinv; + t_diffsta += workerstatus->block_diffsta; + t_diffdup += workerstatus->block_diffdup; + t_diffhi += workerstatus->block_diffhi; + t_diffrej += workerstatus->block_diffrej; + t_shareacc += workerstatus->block_shareacc; + t_shareinv += workerstatus->block_shareinv; + t_sharesta += workerstatus->block_sharesta; + t_sharedup += workerstatus->block_sharedup; + t_sharehi += workerstatus->block_sharehi; + t_sharerej += workerstatus->block_sharerej; } /* TODO: workers_root userid+worker is ordered @@ -1692,6 +1692,8 @@ static char *cmd_workers(__maybe_unused PGconn *conn, char *cmd, char *id, double w_shareacc, w_shareinv; double w_sharesta, w_sharedup; double w_sharehi, w_sharerej; + double w_active_diffacc; + tv_t w_active_start; w_hashrate5m = w_hashrate1hr = w_hashrate24hr = 0.0; @@ -1699,30 +1701,34 @@ static char *cmd_workers(__maybe_unused PGconn *conn, char *cmd, char *id, if (!ws_item) { w_lastshare.tv_sec = 0; - w_lastdiff = w_diffacc = w_diffinv = - w_diffsta = w_diffdup = - w_diffhi = w_diffrej = - w_shareacc = w_shareinv = - w_sharesta = w_sharedup = - w_sharehi = w_sharerej = 0; + w_lastdiff = w_diffacc = + w_diffinv = w_diffsta = + w_diffdup = w_diffhi = + w_diffrej = w_shareacc = + w_shareinv = w_sharesta = + w_sharedup = w_sharehi = + w_sharerej = w_active_diffacc = 0; + w_active_start.tv_sec = 0; } else { DATA_WORKERSTATUS(workerstatus, ws_item); // It's bad to read possibly changing data K_RLOCK(workerstatus_free); w_lastshare.tv_sec = workerstatus->last_share.tv_sec; w_lastdiff = workerstatus->last_diff; - w_diffacc = workerstatus->diffacc; - w_diffinv = workerstatus->diffinv; - w_diffsta = workerstatus->diffsta; - w_diffdup = workerstatus->diffdup; - w_diffhi = workerstatus->diffhi; - w_diffrej = workerstatus->diffrej; - w_shareacc = workerstatus->shareacc; - w_shareinv = workerstatus->shareinv; - w_sharesta = workerstatus->sharesta; - w_sharedup = workerstatus->sharedup; - w_sharehi = workerstatus->sharehi; - w_sharerej = workerstatus->sharerej; + w_diffacc = workerstatus->block_diffacc; + w_diffinv = workerstatus->block_diffinv; + w_diffsta = workerstatus->block_diffsta; + w_diffdup = workerstatus->block_diffdup; + w_diffhi = workerstatus->block_diffhi; + w_diffrej = workerstatus->block_diffrej; + w_shareacc = workerstatus->block_shareacc; + w_shareinv = workerstatus->block_shareinv; + w_sharesta = workerstatus->block_sharesta; + w_sharedup = workerstatus->block_sharedup; + w_sharehi = workerstatus->block_sharehi; + w_sharerej = workerstatus->block_sharerej; + w_active_diffacc = workerstatus->active_diffacc; + w_active_start.tv_sec = workerstatus->active_start.tv_sec; K_RUNLOCK(workerstatus_free); } @@ -1815,6 +1821,15 @@ static char *cmd_workers(__maybe_unused PGconn *conn, char *cmd, char *id, double_to_buf(w_sharerej, reply, sizeof(reply)); snprintf(tmp, sizeof(tmp), "w_sharerej:%d=%s%c", rows, reply, FLDSEP); APPEND_REALLOC(buf, off, len, tmp); + + double_to_buf(w_active_diffacc, reply, sizeof(reply)); + snprintf(tmp, sizeof(tmp), "w_active_diffacc:%d=%s%c", rows, reply, FLDSEP); + APPEND_REALLOC(buf, off, len, tmp); + + int_to_buf((int)(w_active_start.tv_sec), reply, sizeof(reply)); + snprintf(tmp, sizeof(tmp), "w_active_start:%d=%s%c", rows, reply, FLDSEP); + APPEND_REALLOC(buf, off, len, tmp); + } rows++; } @@ -1832,7 +1847,8 @@ static char *cmd_workers(__maybe_unused PGconn *conn, char *cmd, char *id, "w_lastdiff,w_diffacc,w_diffinv," "w_diffsta,w_diffdup,w_diffhi,w_diffrej," "w_shareacc,w_shareinv," - "w_sharesta,w_sharedup,w_sharehi,w_sharerej" : "", + "w_sharesta,w_sharedup,w_sharehi,w_sharerej," + "w_active_diffacc,w_active_start" : "", FLDSEP); APPEND_REALLOC(buf, off, len, tmp); diff --git a/src/ckdb_data.c b/src/ckdb_data.c index 96af3b90..cc5ca7b5 100644 --- a/src/ckdb_data.c +++ b/src/ckdb_data.c @@ -871,6 +871,18 @@ K_ITEM *_find_create_workerstatus(int64_t userid, char *workername, return ws_item; } +// workerstatus must be locked +static void zero_on_idle(tv_t *when, WORKERSTATUS *workerstatus) +{ + copy_tv(&(workerstatus->active_start), when); + workerstatus->active_diffacc = workerstatus->active_diffinv = + workerstatus->active_diffsta = workerstatus->active_diffdup = + workerstatus->active_diffhi = workerstatus->active_diffrej = + workerstatus->active_shareacc = workerstatus->active_shareinv = + workerstatus->active_sharesta = workerstatus->active_sharedup = + workerstatus->active_sharehi = workerstatus->active_sharerej = 0.0; +} + /* All data is loaded, now update workerstatus fields TODO: combine set_block_share_counters() with this? */ void workerstatus_ready() @@ -939,6 +951,8 @@ void _workerstatus_update(AUTHS *auths, SHARES *shares, K_WLOCK(workerstatus_free); if (tv_newer(&(row->last_auth), &(auths->createdate))) copy_tv(&(row->last_auth), &(auths->createdate)); + if (row->active_start.tv_sec == 0) + copy_tv(&(row->active_start), &(auths->createdate)); K_WUNLOCK(workerstatus_free); } } @@ -960,34 +974,54 @@ void _workerstatus_update(AUTHS *auths, SHARES *shares, copy_tv(&(row->last_share), &(shares->createdate)); row->last_diff = shares->diff; } + if (row->active_start.tv_sec == 0) + copy_tv(&(row->active_start), &(shares->createdate)); switch (shares->errn) { case SE_NONE: - row->diffacc += shares->diff; - row->shareacc++; + row->block_diffacc += shares->diff; + row->block_shareacc++; + row->active_diffacc += shares->diff; + row->active_shareacc++; break; case SE_STALE: - row->diffinv += shares->diff; - row->shareinv++; - row->diffsta += shares->diff; - row->sharesta++; + row->block_diffinv += shares->diff; + row->block_shareinv++; + row->block_diffsta += shares->diff; + row->block_sharesta++; + row->active_diffinv += shares->diff; + row->active_shareinv++; + row->active_diffsta += shares->diff; + row->active_sharesta++; break; case SE_DUPE: - row->diffinv += shares->diff; - row->shareinv++; - row->diffdup += shares->diff; - row->sharedup++; + row->block_diffinv += shares->diff; + row->block_shareinv++; + row->block_diffdup += shares->diff; + row->block_sharedup++; + row->active_diffinv += shares->diff; + row->active_shareinv++; + row->active_diffdup += shares->diff; + row->active_sharedup++; break; case SE_HIGH_DIFF: - row->diffinv += shares->diff; - row->shareinv++; - row->diffhi += shares->diff; - row->sharehi++; + row->block_diffinv += shares->diff; + row->block_shareinv++; + row->block_diffhi += shares->diff; + row->block_sharehi++; + row->active_diffinv += shares->diff; + row->active_shareinv++; + row->active_diffhi += shares->diff; + row->active_sharehi++; break; default: - row->diffinv += shares->diff; - row->shareinv++; - row->diffrej += shares->diff; - row->sharerej++; + row->block_diffinv += shares->diff; + row->block_shareinv++; + row->block_diffrej += shares->diff; + row->block_sharerej++; + row->active_diffinv += shares->diff; + row->active_shareinv++; + row->active_diffrej += shares->diff; + row->active_sharerej++; break; } K_WUNLOCK(workerstatus_free); @@ -1001,8 +1035,10 @@ void _workerstatus_update(AUTHS *auths, SHARES *shares, DATA_WORKERSTATUS(row, item); K_WLOCK(workerstatus_free); if (userstats->idle) { - if (tv_newer(&(row->last_idle), &(userstats->statsdate))) + if (tv_newer(&(row->last_idle), &(userstats->statsdate))) { copy_tv(&(row->last_idle), &(userstats->statsdate)); + zero_on_idle(&(userstats->statsdate), row); + } } else { if (tv_newer(&(row->last_stats), &(userstats->statsdate))) copy_tv(&(row->last_stats), &(userstats->statsdate)); @@ -2436,12 +2472,12 @@ void zero_on_new_block() ws_item = first_in_ktree(workerstatus_root, ctx); while (ws_item) { DATA_WORKERSTATUS(workerstatus, ws_item); - workerstatus->diffacc = workerstatus->diffinv = - workerstatus->diffsta = workerstatus->diffdup = - workerstatus->diffhi = workerstatus->diffrej = - workerstatus->shareacc = workerstatus->shareinv = - workerstatus->sharesta = workerstatus->sharedup = - workerstatus->sharehi = workerstatus->sharerej = 0.0; + workerstatus->block_diffacc = workerstatus->block_diffinv = + workerstatus->block_diffsta = workerstatus->block_diffdup = + workerstatus->block_diffhi = workerstatus->block_diffrej = + workerstatus->block_shareacc = workerstatus->block_shareinv = + workerstatus->block_sharesta = workerstatus->block_sharedup = + workerstatus->block_sharehi = workerstatus->block_sharerej = 0.0; ws_item = next_in_ktree(ctx); } K_WUNLOCK(workerstatus_free); @@ -2511,20 +2547,25 @@ void set_block_share_counters() pool.diffacc += sharesummary->diffacc; pool.diffinv += sharesummary->diffsta + sharesummary->diffdup + sharesummary->diffhi + sharesummary->diffrej; - workerstatus->diffacc += sharesummary->diffacc; - workerstatus->diffinv += sharesummary->diffsta + sharesummary->diffdup + - sharesummary->diffhi + sharesummary->diffrej; - workerstatus->diffsta += sharesummary->diffsta; - workerstatus->diffdup += sharesummary->diffdup; - workerstatus->diffhi += sharesummary->diffhi; - workerstatus->diffrej += sharesummary->diffrej; - workerstatus->shareacc += sharesummary->shareacc; - workerstatus->shareinv += sharesummary->sharesta + sharesummary->sharedup + - sharesummary->sharehi + sharesummary->sharerej; - workerstatus->sharesta += sharesummary->sharesta; - workerstatus->sharedup += sharesummary->sharedup; - workerstatus->sharehi += sharesummary->sharehi; - workerstatus->sharerej += sharesummary->sharerej; + // Block stats only + workerstatus->block_diffacc += sharesummary->diffacc; + workerstatus->block_diffinv += sharesummary->diffsta + + sharesummary->diffdup + + sharesummary->diffhi + + sharesummary->diffrej; + workerstatus->block_diffsta += sharesummary->diffsta; + workerstatus->block_diffdup += sharesummary->diffdup; + workerstatus->block_diffhi += sharesummary->diffhi; + workerstatus->block_diffrej += sharesummary->diffrej; + workerstatus->block_shareacc += sharesummary->shareacc; + workerstatus->block_shareinv += sharesummary->sharesta + + sharesummary->sharedup + + sharesummary->sharehi + + sharesummary->sharerej; + workerstatus->block_sharesta += sharesummary->sharesta; + workerstatus->block_sharedup += sharesummary->sharedup; + workerstatus->block_sharehi += sharesummary->sharehi; + workerstatus->block_sharerej += sharesummary->sharerej; ss_item = prev_in_ktree(ctx); } @@ -2589,20 +2630,25 @@ void set_block_share_counters() pool.diffacc += markersummary->diffacc; pool.diffinv += markersummary->diffsta + markersummary->diffdup + markersummary->diffhi + markersummary->diffrej; - workerstatus->diffacc += markersummary->diffacc; - workerstatus->diffinv += markersummary->diffsta + markersummary->diffdup + - markersummary->diffhi + markersummary->diffrej; - workerstatus->diffsta += markersummary->diffsta; - workerstatus->diffdup += markersummary->diffdup; - workerstatus->diffhi += markersummary->diffhi; - workerstatus->diffrej += markersummary->diffrej; - workerstatus->shareacc += markersummary->shareacc; - workerstatus->shareinv += markersummary->sharesta + markersummary->sharedup + - markersummary->sharehi + markersummary->sharerej; - workerstatus->sharesta += markersummary->sharesta; - workerstatus->sharedup += markersummary->sharedup; - workerstatus->sharehi += markersummary->sharehi; - workerstatus->sharerej += markersummary->sharerej; + // Block stats only + workerstatus->block_diffacc += markersummary->diffacc; + workerstatus->block_diffinv += markersummary->diffsta + + markersummary->diffdup + + markersummary->diffhi + + markersummary->diffrej; + workerstatus->block_diffsta += markersummary->diffsta; + workerstatus->block_diffdup += markersummary->diffdup; + workerstatus->block_diffhi += markersummary->diffhi; + workerstatus->block_diffrej += markersummary->diffrej; + workerstatus->block_shareacc += markersummary->shareacc; + workerstatus->block_shareinv += markersummary->sharesta + + markersummary->sharedup + + markersummary->sharehi + + markersummary->sharerej; + workerstatus->block_sharesta += markersummary->sharesta; + workerstatus->block_sharedup += markersummary->sharedup; + workerstatus->block_sharehi += markersummary->sharehi; + workerstatus->block_sharerej += markersummary->sharerej; ms_item = prev_in_ktree(ctx_ms); }