Browse Source

ckdb/php - add 5m hashrate to allusers and use it

master
kanoi 10 years ago
parent
commit
f8725a3a69
  1. 8
      pool/page_stats.php
  2. 12
      src/ckdb.c

8
pool/page_stats.php

@ -2,7 +2,7 @@
# #
function allusersort($a, $b) function allusersort($a, $b)
{ {
$cmp = $a['u_hashrate1hr'] != $b['u_hashrate1hr']; $cmp = $a['u_hashrate5m'] != $b['u_hashrate5m'];
if ($cmp != 0) if ($cmp != 0)
return $cmp; return $cmp;
return $a['userid'] - $b['userid']; return $a['userid'] - $b['userid'];
@ -18,7 +18,7 @@ function dostats($data, $user)
$pg .= "<table callpadding=0 cellspacing=0 border=0>\n"; $pg .= "<table callpadding=0 cellspacing=0 border=0>\n";
$pg .= "<tr class=title>"; $pg .= "<tr class=title>";
$pg .= "<td class=dl>Username</td>"; $pg .= "<td class=dl>Username</td>";
$pg .= "<td class=dr>Hash Rate 1hr</td>"; $pg .= "<td class=dr>Hash Rate 5m</td>";
$pg .= "</tr>\n"; $pg .= "</tr>\n";
if ($ans['STATUS'] == 'ok') if ($ans['STATUS'] == 'ok')
{ {
@ -28,7 +28,7 @@ function dostats($data, $user)
{ {
$all[] = array('username' => $ans['username'.$i], $all[] = array('username' => $ans['username'.$i],
'userid' => $ans['userid'.$i], 'userid' => $ans['userid'.$i],
'u_hashrate1hr' => $ans['u_hashrate1hr'.$i]); 'u_hashrate5m' => $ans['u_hashrate5m'.$i]);
} }
usort($all, 'allusersort'); usort($all, 'allusersort');
@ -42,7 +42,7 @@ function dostats($data, $user)
$pg .= "<tr class=$row>"; $pg .= "<tr class=$row>";
$pg .= '<td class=dl>'.$all[$i]['username'].'</td>'; $pg .= '<td class=dl>'.$all[$i]['username'].'</td>';
$uhr = $all[$i]['u_hashrate1hr']; $uhr = $all[$i]['u_hashrate5m'];
if ($uhr == '?') if ($uhr == '?')
$uhr = '?GHs'; $uhr = '?GHs';
else else

12
src/ckdb.c

@ -6797,6 +6797,7 @@ static char *cmd_allusers(__maybe_unused PGconn *conn, char *cmd, char *id,
size_t len, off; size_t len, off;
int rows; int rows;
int64_t userid = -1; int64_t userid = -1;
double u_hashrate5m = 0.0;
double u_hashrate1hr = 0.0; double u_hashrate1hr = 0.0;
LOGDEBUG("%s(): cmd '%s'", __func__, cmd); LOGDEBUG("%s(): cmd '%s'", __func__, cmd);
@ -6812,6 +6813,7 @@ static char *cmd_allusers(__maybe_unused PGconn *conn, char *cmd, char *id,
DATA_USERSTATS(usw_item)->userid = DATA_USERSTATS(us_item)->userid; DATA_USERSTATS(usw_item)->userid = DATA_USERSTATS(us_item)->userid;
strcpy(DATA_USERSTATS(usw_item)->workername, DATA_USERSTATS(us_item)->workername); strcpy(DATA_USERSTATS(usw_item)->workername, DATA_USERSTATS(us_item)->workername);
DATA_USERSTATS(usw_item)->hashrate5m = DATA_USERSTATS(us_item)->hashrate5m;
DATA_USERSTATS(usw_item)->hashrate1hr = DATA_USERSTATS(us_item)->hashrate1hr; DATA_USERSTATS(usw_item)->hashrate1hr = DATA_USERSTATS(us_item)->hashrate1hr;
userstats_workername_root = add_to_ktree(userstats_workername_root, usw_item, cmp_userstats_workername); userstats_workername_root = add_to_ktree(userstats_workername_root, usw_item, cmp_userstats_workername);
@ -6842,6 +6844,10 @@ static char *cmd_allusers(__maybe_unused PGconn *conn, char *cmd, char *id,
snprintf(tmp, sizeof(tmp), "userid%d=%s%c", rows, reply, FLDSEP); snprintf(tmp, sizeof(tmp), "userid%d=%s%c", rows, reply, FLDSEP);
APPEND_REALLOC(buf, off, len, tmp); APPEND_REALLOC(buf, off, len, tmp);
double_to_buf(u_hashrate5m, reply, sizeof(reply));
snprintf(tmp, sizeof(tmp), "u_hashrate5m%d=%s%c", rows, reply, FLDSEP);
APPEND_REALLOC(buf, off, len, tmp);
double_to_buf(u_hashrate1hr, reply, sizeof(reply)); double_to_buf(u_hashrate1hr, reply, sizeof(reply));
snprintf(tmp, sizeof(tmp), "u_hashrate1hr%d=%s%c", rows, reply, FLDSEP); snprintf(tmp, sizeof(tmp), "u_hashrate1hr%d=%s%c", rows, reply, FLDSEP);
APPEND_REALLOC(buf, off, len, tmp); APPEND_REALLOC(buf, off, len, tmp);
@ -6850,8 +6856,10 @@ static char *cmd_allusers(__maybe_unused PGconn *conn, char *cmd, char *id,
} }
} }
userid = DATA_USERSTATS(usw_item)->userid; userid = DATA_USERSTATS(usw_item)->userid;
u_hashrate5m = 0;
u_hashrate1hr = 0; u_hashrate1hr = 0;
} }
u_hashrate5m += DATA_USERSTATS(usw_item)->hashrate5m;
u_hashrate1hr += DATA_USERSTATS(usw_item)->hashrate1hr; u_hashrate1hr += DATA_USERSTATS(usw_item)->hashrate1hr;
tmp_item = usw_item; tmp_item = usw_item;
@ -6875,6 +6883,10 @@ static char *cmd_allusers(__maybe_unused PGconn *conn, char *cmd, char *id,
snprintf(tmp, sizeof(tmp), "userid%d=%s%c", rows, reply, FLDSEP); snprintf(tmp, sizeof(tmp), "userid%d=%s%c", rows, reply, FLDSEP);
APPEND_REALLOC(buf, off, len, tmp); APPEND_REALLOC(buf, off, len, tmp);
double_to_buf(u_hashrate5m, reply, sizeof(reply));
snprintf(tmp, sizeof(tmp), "u_hashrate5m%d=%s%c", rows, reply, FLDSEP);
APPEND_REALLOC(buf, off, len, tmp);
double_to_buf(u_hashrate1hr, reply, sizeof(reply)); double_to_buf(u_hashrate1hr, reply, sizeof(reply));
snprintf(tmp, sizeof(tmp), "u_hashrate1hr%d=%s%c", rows, reply, FLDSEP); snprintf(tmp, sizeof(tmp), "u_hashrate1hr%d=%s%c", rows, reply, FLDSEP);
APPEND_REALLOC(buf, off, len, tmp); APPEND_REALLOC(buf, off, len, tmp);

Loading…
Cancel
Save