Browse Source

ckdb - use ckpool instances

master
kanoi 9 years ago
parent
commit
d2bd3e536c
  1. 7
      pool/page_allwork.php
  2. 18
      pool/page_workers.php
  3. 9
      src/ckdb.h
  4. 22
      src/ckdb_cmd.c
  5. 9
      src/ckdb_dbio.c

7
pool/page_allwork.php

@ -16,6 +16,7 @@ function doallwork($data, $user)
$offset = 0; $offset = 0;
$blockacc = 0; $blockacc = 0;
$blockreward = 0; $blockreward = 0;
$instances = 0;
$pg .= worktitle($data, $user); $pg .= worktitle($data, $user);
@ -29,12 +30,14 @@ function doallwork($data, $user)
$pg .= workuser($data, $ans['username:'.$i], $pg .= workuser($data, $ans['username:'.$i],
$offset, $totshare, $totdiff, $offset, $totshare, $totdiff,
$totshrate, $totinvalid, $totrate, $totshrate, $totinvalid, $totrate,
$blockacc, $blockreward, 3600, false, false, $title); $blockacc, $blockreward,
3600, false, false,
$title, $instances);
} }
} }
$pg .= worktotal($offset, $totshare, $totdiff, $totshrate, $totinvalid, $pg .= worktotal($offset, $totshare, $totdiff, $totshrate, $totinvalid,
$totrate, $blockacc, $blockreward); $totrate, $blockacc, $blockreward, $instances);
$pg .= "</table>\n"; $pg .= "</table>\n";

18
pool/page_workers.php

@ -42,7 +42,7 @@ function workhashorder($a, $b)
function workuser($data, $user, &$offset, &$totshare, &$totdiff, function workuser($data, $user, &$offset, &$totshare, &$totdiff,
&$totshrate, &$totinvalid, &$totrate, &$blockacc, &$totshrate, &$totinvalid, &$totrate, &$blockacc,
&$blockreward, $old = false, $srt = false, &$blockreward, $old = false, $srt = false,
$one = false, &$title) $one = false, &$title, &$instances)
{ {
$ans = getWorkers($user); $ans = getWorkers($user);
@ -93,6 +93,8 @@ function workuser($data, $user, &$offset, &$totshare, &$totdiff,
'w_active_diffacc' => $ans['w_active_diffacc:'.$i], 'w_active_diffacc' => $ans['w_active_diffacc:'.$i],
'w_active_start' => $ans['w_active_start:'.$i], 'w_active_start' => $ans['w_active_start:'.$i],
'w_uhr' => $uhr); 'w_uhr' => $uhr);
$instances += $ans['w_instances:'.$i];
} }
if ($srt) if ($srt)
@ -205,16 +207,21 @@ function workuser($data, $user, &$offset, &$totshare, &$totdiff,
} }
# #
function worktotal($offset, $totshare, $totdiff, $totshrate, $totinvalid, function worktotal($offset, $totshare, $totdiff, $totshrate, $totinvalid,
$totrate, $blockacc, $blockreward) $totrate, $blockacc, $blockreward, $instances)
{ {
$pg = ''; $pg = '';
$totshrate = dsprate($totshrate); $totshrate = dsprate($totshrate);
$totrate = dsprate($totrate); $totrate = dsprate($totrate);
# if ($instances >= 0)
# $dspinst = " ($instances miners)";
# else
$dspinst = '';
if (($offset % 2) == 0) if (($offset % 2) == 0)
$row = 'even'; $row = 'even';
else else
$row = 'odd'; $row = 'odd';
$pg .= "<tr class=$row><td class=dl>Total: $offset</td><td colspan=2 class=dl></td>"; $pg .= "<tr class=$row><td class=dl colspan=3>Total: $offset$dspinst</td>";
$shareacc = number_format($totshare, 0); $shareacc = number_format($totshare, 0);
$pg .= "<td class=dr>$shareacc</td>"; $pg .= "<td class=dr>$shareacc</td>";
$diffacc = number_format($totdiff, 0); $diffacc = number_format($totdiff, 0);
@ -250,13 +257,14 @@ function doworker($data, $user)
$offset = 0; $offset = 0;
$blockacc = 0; $blockacc = 0;
$blockreward = 0; $blockreward = 0;
$instances = 0;
$pg .= worktitle($data, $user); $pg .= worktitle($data, $user);
$pg .= workuser($data, $user, $offset, $totshare, $totdiff, $totshrate, $pg .= workuser($data, $user, $offset, $totshare, $totdiff, $totshrate,
$totinvalid, $totrate, $blockacc, $blockreward, $totinvalid, $totrate, $blockacc, $blockreward,
false, true, true, $title); false, true, true, $title, $instances);
$pg .= worktotal($offset, $totshare, $totdiff, $totshrate, $totinvalid, $pg .= worktotal($offset, $totshare, $totdiff, $totshrate, $totinvalid,
$totrate, $blockacc, $blockreward); $totrate, $blockacc, $blockreward, $instances);
if (false && $blockacc > 0 && $blockreward > 0) if (false && $blockacc > 0 && $blockreward > 0)
{ {

9
src/ckdb.h

@ -51,7 +51,7 @@
#define DB_VLOCK "1" #define DB_VLOCK "1"
#define DB_VERSION "1.0.4" #define DB_VERSION "1.0.4"
#define CKDB_VERSION DB_VERSION"-1.913" #define CKDB_VERSION DB_VERSION"-1.914"
#define WHERE_FFL " - from %s %s() line %d" #define WHERE_FFL " - from %s %s() line %d"
#define WHERE_FFL_HERE __FILE__, __func__, __LINE__ #define WHERE_FFL_HERE __FILE__, __func__, __LINE__
@ -1777,6 +1777,7 @@ typedef struct userstats {
double hashrate1hr; double hashrate1hr;
double hashrate24hr; double hashrate24hr;
bool idle; // non-DB field bool idle; // non-DB field
int instances;
char summarylevel[TXT_FLAG+1]; // SUMMARY_NONE in RAM char summarylevel[TXT_FLAG+1]; // SUMMARY_NONE in RAM
int32_t summarycount; int32_t summarycount;
tv_t statsdate; tv_t statsdate;
@ -1800,6 +1801,8 @@ extern K_STORE *userstats_store;
// Awaiting EOS // Awaiting EOS
extern K_STORE *userstats_eos_store; extern K_STORE *userstats_eos_store;
#define NO_INSTANCE_DATA -1
/* 1.5 x how often we expect to get user's stats from ckpool /* 1.5 x how often we expect to get user's stats from ckpool
* This is used when grouping the sub-worker stats into a single user * This is used when grouping the sub-worker stats into a single user
* We add each worker's latest stats to the total - except we ignore * We add each worker's latest stats to the total - except we ignore
@ -2629,8 +2632,8 @@ extern bool userstats_add(char *poolinstance, char *elapsed, char *username,
extern bool workerstats_add(char *poolinstance, char *elapsed, char *username, extern bool workerstats_add(char *poolinstance, char *elapsed, char *username,
char *workername, char *hashrate, char *hashrate5m, char *workername, char *hashrate, char *hashrate5m,
char *hashrate1hr, char *hashrate24hr, bool idle, char *hashrate1hr, char *hashrate24hr, bool idle,
char *by, char *code, char *inet, tv_t *cd, char *instances, char *by, char *code, char *inet,
K_TREE *trf_root); tv_t *cd, K_TREE *trf_root);
extern bool userstats_fill(PGconn *conn); extern bool userstats_fill(PGconn *conn);
extern bool markersummary_add(PGconn *conn, K_ITEM *ms_item, char *by, char *code, extern bool markersummary_add(PGconn *conn, K_ITEM *ms_item, char *by, char *code,
char *inet, tv_t *cd, K_TREE *trf_root); char *inet, tv_t *cd, K_TREE *trf_root);

22
src/ckdb_cmd.c

@ -1111,7 +1111,7 @@ static char *cmd_workerstats(__maybe_unused PGconn *conn, char *cmd, char *id,
K_ITEM *i_poolinstance, *i_elapsed, *i_username, *i_workername; K_ITEM *i_poolinstance, *i_elapsed, *i_username, *i_workername;
K_ITEM *i_hashrate, *i_hashrate5m, *i_hashrate1hr, *i_hashrate24hr; K_ITEM *i_hashrate, *i_hashrate5m, *i_hashrate1hr, *i_hashrate24hr;
K_ITEM *i_idle; K_ITEM *i_idle, *i_instances;
bool ok = false, idle; bool ok = false, idle;
LOGDEBUG("%s(): cmd '%s'", __func__, cmd); LOGDEBUG("%s(): cmd '%s'", __func__, cmd);
@ -1154,6 +1154,8 @@ static char *cmd_workerstats(__maybe_unused PGconn *conn, char *cmd, char *id,
idle = (strcasecmp(transfer_data(i_idle), TRUE_STR) == 0); idle = (strcasecmp(transfer_data(i_idle), TRUE_STR) == 0);
i_instances = optional_name(trf_root, "instances", 1, NULL, reply, siz);
ok = workerstats_add(transfer_data(i_poolinstance), ok = workerstats_add(transfer_data(i_poolinstance),
transfer_data(i_elapsed), transfer_data(i_elapsed),
transfer_data(i_username), transfer_data(i_username),
@ -1161,8 +1163,9 @@ static char *cmd_workerstats(__maybe_unused PGconn *conn, char *cmd, char *id,
transfer_data(i_hashrate), transfer_data(i_hashrate),
transfer_data(i_hashrate5m), transfer_data(i_hashrate5m),
transfer_data(i_hashrate1hr), transfer_data(i_hashrate1hr),
transfer_data(i_hashrate24hr), transfer_data(i_hashrate24hr), idle,
idle, by, code, inet, cd, trf_root); i_instances ? transfer_data(i_instances) : NULL,
by, code, inet, cd, trf_root);
if (!ok) { if (!ok) {
LOGERR("%s() %s.failed.DATA", __func__, id); LOGERR("%s() %s.failed.DATA", __func__, id);
@ -2089,10 +2092,12 @@ static char *cmd_workers(__maybe_unused PGconn *conn, char *cmd, char *id,
double w_sharehi, w_sharerej; double w_sharehi, w_sharerej;
double w_active_diffacc; double w_active_diffacc;
tv_t w_active_start; tv_t w_active_start;
int w_instances;
w_hashrate5m = w_hashrate1hr = w_hashrate5m = w_hashrate1hr =
w_hashrate24hr = 0.0; w_hashrate24hr = 0.0;
w_elapsed = -1; w_elapsed = -1;
w_instances = NO_INSTANCE_DATA;
if (!ws_item) { if (!ws_item) {
w_lastshare.tv_sec = w_lastshare.tv_sec =
@ -2143,6 +2148,12 @@ static char *cmd_workers(__maybe_unused PGconn *conn, char *cmd, char *id,
w_hashrate24hr += userstats->hashrate24hr; w_hashrate24hr += userstats->hashrate24hr;
if (w_elapsed == -1 || w_elapsed > userstats->elapsed) if (w_elapsed == -1 || w_elapsed > userstats->elapsed)
w_elapsed = userstats->elapsed; w_elapsed = userstats->elapsed;
w_instances += userstats->instances;
if (userstats->instances != NO_INSTANCE_DATA) {
if (w_instances == NO_INSTANCE_DATA)
w_instances = 0;
w_instances += userstats->instances;
}
} }
} }
K_RUNLOCK(userstats_free); K_RUNLOCK(userstats_free);
@ -2231,6 +2242,9 @@ static char *cmd_workers(__maybe_unused PGconn *conn, char *cmd, char *id,
snprintf(tmp, sizeof(tmp), "w_active_start:%d=%s%c", rows, reply, FLDSEP); snprintf(tmp, sizeof(tmp), "w_active_start:%d=%s%c", rows, reply, FLDSEP);
APPEND_REALLOC(buf, off, len, tmp); APPEND_REALLOC(buf, off, len, tmp);
int_to_buf(w_instances, reply, sizeof(reply));
snprintf(tmp, sizeof(tmp), "w_instances:%d=%s%c", rows, reply, FLDSEP);
APPEND_REALLOC(buf, off, len, tmp);
} }
rows++; rows++;
} }
@ -2251,7 +2265,7 @@ static char *cmd_workers(__maybe_unused PGconn *conn, char *cmd, char *id,
"w_diffsta,w_diffdup,w_diffhi,w_diffrej," "w_diffsta,w_diffdup,w_diffhi,w_diffrej,"
"w_shareacc,w_shareinv," "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" : "", "w_active_diffacc,w_active_start,w_instances" : "",
FLDSEP); FLDSEP);
APPEND_REALLOC(buf, off, len, tmp); APPEND_REALLOC(buf, off, len, tmp);

9
src/ckdb_dbio.c

@ -6544,6 +6544,7 @@ bool userstats_add(char *poolinstance, char *elapsed, char *username,
TXT_TO_DOUBLE("hashrate1hr", hashrate1hr, row->hashrate1hr); TXT_TO_DOUBLE("hashrate1hr", hashrate1hr, row->hashrate1hr);
TXT_TO_DOUBLE("hashrate24hr", hashrate24hr, row->hashrate24hr); TXT_TO_DOUBLE("hashrate24hr", hashrate24hr, row->hashrate24hr);
row->idle = idle; row->idle = idle;
row->instances = NO_INSTANCE_DATA;
row->summarylevel[0] = SUMMARY_NONE; row->summarylevel[0] = SUMMARY_NONE;
row->summarylevel[1] = '\0'; row->summarylevel[1] = '\0';
row->summarycount = 1; row->summarycount = 1;
@ -6612,8 +6613,8 @@ bool userstats_add(char *poolinstance, char *elapsed, char *username,
bool workerstats_add(char *poolinstance, char *elapsed, char *username, bool workerstats_add(char *poolinstance, char *elapsed, char *username,
char *workername, char *hashrate, char *hashrate5m, char *workername, char *hashrate, char *hashrate5m,
char *hashrate1hr, char *hashrate24hr, bool idle, char *hashrate1hr, char *hashrate24hr, bool idle,
char *by, char *code, char *inet, tv_t *cd, char *instances, char *by, char *code, char *inet,
K_TREE *trf_root) tv_t *cd, K_TREE *trf_root)
{ {
K_ITEM *us_item, *u_item, *us_match; K_ITEM *us_item, *u_item, *us_match;
USERSTATS *row, *match; USERSTATS *row, *match;
@ -6652,6 +6653,10 @@ bool workerstats_add(char *poolinstance, char *elapsed, char *username,
TXT_TO_DOUBLE("hashrate1hr", hashrate1hr, row->hashrate1hr); TXT_TO_DOUBLE("hashrate1hr", hashrate1hr, row->hashrate1hr);
TXT_TO_DOUBLE("hashrate24hr", hashrate24hr, row->hashrate24hr); TXT_TO_DOUBLE("hashrate24hr", hashrate24hr, row->hashrate24hr);
row->idle = idle; row->idle = idle;
if (instances)
TXT_TO_INT("instances", instances, row->instances);
else
row->instances = NO_INSTANCE_DATA;
row->summarylevel[0] = SUMMARY_NONE; row->summarylevel[0] = SUMMARY_NONE;
row->summarylevel[1] = '\0'; row->summarylevel[1] = '\0';
row->summarycount = 1; row->summarycount = 1;

Loading…
Cancel
Save