From d64827bf35c9784b346cf43c1c004db77f07c479 Mon Sep 17 00:00:00 2001 From: CC Ding Date: Thu, 18 Sep 2014 02:01:29 +0000 Subject: [PATCH 1/7] Get rid of the square brackets when using numeric ipv6 address. --- src/libckpool.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/libckpool.c b/src/libckpool.c index 8a568e0d..5d507672 100644 --- a/src/libckpool.c +++ b/src/libckpool.c @@ -353,6 +353,12 @@ bool extract_sockaddr(char *url, char **sockaddr_url, char **sockaddr_port) } else url_len = strlen(url_begin); + /* Get rid of the [] */ + if (ipv6_begin && ipv6_end && ipv6_end > ipv6_begin){ + url_len -= 2; + url_begin++; + } + if (url_len < 1) { LOGWARNING("Null length URL passed to extract_sockaddr"); return false; From 947e22a91a08e328bc8511c232e9d1deda63c442 Mon Sep 17 00:00:00 2001 From: kanoi Date: Thu, 18 Sep 2014 12:10:58 +1000 Subject: [PATCH 2/7] php - fix user level menu mess up --- pool/page.php | 3 +++ pool/prime.php | 5 ----- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/pool/page.php b/pool/page.php index ed8945bb..f4127f04 100644 --- a/pool/page.php +++ b/pool/page.php @@ -361,6 +361,9 @@ function pgmenu($menus) $side = ''; foreach ($menus as $menu => $submenus) { + if ($menu == 'Admin' && $submenus == null) + continue; + if ($menu == 'gap') { $side = 'r'; diff --git a/pool/prime.php b/pool/prime.php index d6599b7d..cdcea841 100644 --- a/pool/prime.php +++ b/pool/prime.php @@ -14,11 +14,6 @@ function process($p, $user, $menu) $menu['Admin']['PPLNS'] = 'pplns'; $menu['Admin']['AllWork'] = 'allwork'; } - else - { - if (isset($menu['Admin'])) - unset($menu['Admin']); - } $page = ''; $n = ''; foreach ($menu as $item => $options) From 4f9fca780608eb7529129f85d69c999400066c46 Mon Sep 17 00:00:00 2001 From: kanoi Date: Thu, 18 Sep 2014 13:36:47 +1000 Subject: [PATCH 3/7] ckdb - initialise pool data for optioncontrol --- src/ckdb.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/ckdb.c b/src/ckdb.c index b6aae128..f9d8b898 100644 --- a/src/ckdb.c +++ b/src/ckdb.c @@ -49,7 +49,7 @@ #define DB_VLOCK "1" #define DB_VERSION "0.9.2" -#define CKDB_VERSION DB_VERSION"-0.320" +#define CKDB_VERSION DB_VERSION"-0.321" #define WHERE_FFL " - from %s %s() line %d" #define WHERE_FFL_HERE __FILE__, __func__, __LINE__ @@ -233,6 +233,9 @@ typedef struct loadstatus { } LOADSTATUS; static LOADSTATUS dbstatus; +// So cmd_getopts works on a new empty pool +#define START_POOL_HEIGHT 2 + // Share stats since last block typedef struct poolstatus { int64_t workinfoid; // Last block @@ -243,7 +246,7 @@ typedef struct poolstatus { double shareinv; // Non-acc double best_sdiff; // TODO (maybe) } POOLSTATUS; -static POOLSTATUS pool; +static POOLSTATUS pool = { 0, START_POOL_HEIGHT, 0, 0, 0, 0, 0 }; /* TODO: when we know about orphans, the count reset to zero * will need to be undone - i.e. recalculate this data from * the memory tables - maybe ... */ @@ -1156,7 +1159,12 @@ typedef struct optioncontrol { #define DATA_OPTIONCONTROL_NULL(_var, _item) DATA_GENERIC(_var, _item, optioncontrol, false) // Value it must default to (to work properly) -#define OPTIONCONTROL_HEIGHT 1 +#define OPTIONCONTROL_HEIGHT 1 + +// Test it here rather than obscuring the #define elsewhere +#if ((OPTIONCONTROL_HEIGHT+1) != START_POOL_HEIGHT) +#error "START_POOL_HEIGHT must = (OPTIONCONTROL_HEIGHT+1)" +#endif static K_TREE *optioncontrol_root; static K_LIST *optioncontrol_free; From fe39c582298769c88fe4bf7b9e0c8070df86a276 Mon Sep 17 00:00:00 2001 From: kanoi Date: Thu, 18 Sep 2014 18:15:35 +1000 Subject: [PATCH 4/7] ckdb - add missing stats --- src/ckdb.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/ckdb.c b/src/ckdb.c index f9d8b898..98420b8d 100644 --- a/src/ckdb.c +++ b/src/ckdb.c @@ -49,7 +49,7 @@ #define DB_VLOCK "1" #define DB_VERSION "0.9.2" -#define CKDB_VERSION DB_VERSION"-0.321" +#define CKDB_VERSION DB_VERSION"-0.322" #define WHERE_FFL " - from %s %s() line %d" #define WHERE_FFL_HERE __FILE__, __func__, __LINE__ @@ -11861,15 +11861,18 @@ static char *cmd_stats(__maybe_unused PGconn *conn, char *cmd, char *id, rows++; USEINFO(users, 1, 2); + USEINFO(useratts, 1, 1); USEINFO(workers, 1, 1); USEINFO(paymentaddresses, 1, 1); USEINFO(payments, 1, 1); USEINFO(idcontrol, 1, 0); + USEINFO(optioncontrol, 1, 1); USEINFO(workinfo, 1, 1); USEINFO(shares, 1, 1); USEINFO(shareerrors, 1, 1); USEINFO(sharesummary, 1, 2); USEINFO(blocks, 1, 1); + USEINFO(miningpayouts, 1, 1); USEINFO(auths, 1, 1); USEINFO(poolstats, 1, 1); USEINFO(userstats, 4, 2); From 9226a0ea2957c5578528ce17c281fd270e59a106 Mon Sep 17 00:00:00 2001 From: kanoi Date: Fri, 19 Sep 2014 18:26:33 +1000 Subject: [PATCH 5/7] php - same header spacing for users/workers --- pool/page.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pool/page.php b/pool/page.php index f4127f04..b9fca6ed 100644 --- a/pool/page.php +++ b/pool/page.php @@ -306,10 +306,10 @@ function pgtop($dotop, $user, $douser) $top .= " $nlb"; $top .= ''; $top .= ''; - $top .= ''; - $top .= ''; - $top .= ''; - $top .= '
Users:'.$info['users'].'
Workers:'.$info['workers'].'
'; + $top .= 'Users: '; + $top .= ' '.$info['users'].''; + $top .= 'Workers: '; + $top .= ' '.$info['workers'].''; $top .= ''; if ($douser === true) From 7b119f05a37b8ba1b87fef5323ab389b94cc9eec Mon Sep 17 00:00:00 2001 From: kanoi Date: Fri, 19 Sep 2014 19:10:23 +1000 Subject: [PATCH 6/7] ckdb - share invalid breakdown per worker --- src/ckdb.c | 114 ++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 104 insertions(+), 10 deletions(-) diff --git a/src/ckdb.c b/src/ckdb.c index 98420b8d..76caad8a 100644 --- a/src/ckdb.c +++ b/src/ckdb.c @@ -49,7 +49,7 @@ #define DB_VLOCK "1" #define DB_VERSION "0.9.2" -#define CKDB_VERSION DB_VERSION"-0.322" +#define CKDB_VERSION DB_VERSION"-0.325" #define WHERE_FFL " - from %s %s() line %d" #define WHERE_FFL_HERE __FILE__, __func__, __LINE__ @@ -1565,8 +1565,16 @@ typedef struct workerstatus { // 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; } WORKERSTATUS; #define ALLOC_WORKERSTATUS 1000 @@ -2461,7 +2469,11 @@ static void zero_on_new_block() while (ws_item) { DATA_WORKERSTATUS(workerstatus, ws_item); workerstatus->diffacc = workerstatus->diffinv = - workerstatus->shareacc = workerstatus->shareinv = 0.0; + workerstatus->diffsta = workerstatus->diffdup = + workerstatus->diffhi = workerstatus->diffrej = + workerstatus->shareacc = workerstatus->shareinv = + workerstatus->sharesta = workerstatus->sharedup = + workerstatus->sharehi = workerstatus->sharerej = 0.0; ws_item = next_in_ktree(ctx); } K_WUNLOCK(workerstatus_free); @@ -2530,9 +2542,17 @@ static void set_block_share_counters() 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; ss_item = prev_in_ktree(ctx); } @@ -2636,12 +2656,35 @@ static void _workerstatus_update(AUTHS *auths, SHARES *shares, copy_tv(&(row->last_share), &(shares->createdate)); row->last_diff = shares->diff; } - if (shares->errn == SE_NONE) { - row->diffacc += shares->diff; - row->shareacc++; - } else { - row->diffinv += shares->diff; - row->shareinv++; + switch (shares->errn) { + case SE_NONE: + row->diffacc += shares->diff; + row->shareacc++; + break; + case SE_STALE: + row->diffinv += shares->diff; + row->shareinv++; + row->diffsta += shares->diff; + row->sharesta++; + break; + case SE_DUPE: + row->diffinv += shares->diff; + row->shareinv++; + row->diffdup += shares->diff; + row->sharedup++; + break; + case SE_HIGH_DIFF: + row->diffinv += shares->diff; + row->shareinv++; + row->diffhi += shares->diff; + row->sharehi++; + break; + default: + row->diffinv += shares->diff; + row->shareinv++; + row->diffrej += shares->diff; + row->sharerej++; + break; } } } @@ -9723,13 +9766,21 @@ static char *cmd_workers(__maybe_unused PGconn *conn, char *cmd, char *id, int64_t w_elapsed; tv_t w_lastshare; double w_lastdiff, w_diffacc, w_diffinv; + double w_diffsta, w_diffdup; + double w_diffhi, w_diffrej; double w_shareacc, w_shareinv; + double w_sharesta, w_sharedup; + double w_sharehi, w_sharerej; w_hashrate5m = w_hashrate1hr = 0.0; w_elapsed = -1; w_lastshare.tv_sec = 0; w_lastdiff = w_diffacc = w_diffinv = - w_shareacc = w_shareinv = 0; + w_diffsta = w_diffdup = + w_diffhi = w_diffrej = + w_shareacc = w_shareinv = + w_sharesta = w_sharedup = + w_sharehi = w_sharerej = 0; ws_item = find_workerstatus(users->userid, workers->workername, __FILE__, __func__, __LINE__); @@ -9739,8 +9790,16 @@ static char *cmd_workers(__maybe_unused PGconn *conn, char *cmd, char *id, 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; } // find last stored userid record @@ -9804,6 +9863,22 @@ static char *cmd_workers(__maybe_unused PGconn *conn, char *cmd, char *id, snprintf(tmp, sizeof(tmp), "w_diffinv:%d=%s%c", rows, reply, FLDSEP); APPEND_REALLOC(buf, off, len, tmp); + double_to_buf(w_diffsta, reply, sizeof(reply)); + snprintf(tmp, sizeof(tmp), "w_diffsta:%d=%s%c", rows, reply, FLDSEP); + APPEND_REALLOC(buf, off, len, tmp); + + double_to_buf(w_diffdup, reply, sizeof(reply)); + snprintf(tmp, sizeof(tmp), "w_diffdup:%d=%s%c", rows, reply, FLDSEP); + APPEND_REALLOC(buf, off, len, tmp); + + double_to_buf(w_diffhi, reply, sizeof(reply)); + snprintf(tmp, sizeof(tmp), "w_diffhi:%d=%s%c", rows, reply, FLDSEP); + APPEND_REALLOC(buf, off, len, tmp); + + double_to_buf(w_diffrej, reply, sizeof(reply)); + snprintf(tmp, sizeof(tmp), "w_diffrej:%d=%s%c", rows, reply, FLDSEP); + APPEND_REALLOC(buf, off, len, tmp); + double_to_buf(w_shareacc, reply, sizeof(reply)); snprintf(tmp, sizeof(tmp), "w_shareacc:%d=%s%c", rows, reply, FLDSEP); APPEND_REALLOC(buf, off, len, tmp); @@ -9812,6 +9887,22 @@ static char *cmd_workers(__maybe_unused PGconn *conn, char *cmd, char *id, snprintf(tmp, sizeof(tmp), "w_shareinv:%d=%s%c", rows, reply, FLDSEP); APPEND_REALLOC(buf, off, len, tmp); + double_to_buf(w_sharesta, reply, sizeof(reply)); + snprintf(tmp, sizeof(tmp), "w_sharesta:%d=%s%c", rows, reply, FLDSEP); + APPEND_REALLOC(buf, off, len, tmp); + + double_to_buf(w_sharedup, reply, sizeof(reply)); + snprintf(tmp, sizeof(tmp), "w_sharedup:%d=%s%c", rows, reply, FLDSEP); + APPEND_REALLOC(buf, off, len, tmp); + + double_to_buf(w_sharehi, reply, sizeof(reply)); + snprintf(tmp, sizeof(tmp), "w_sharehi:%d=%s%c", rows, reply, FLDSEP); + APPEND_REALLOC(buf, off, len, tmp); + + 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); + userstats_workername_root = free_ktree(userstats_workername_root, NULL); K_RUNLOCK(userstats_free); } @@ -9827,7 +9918,10 @@ static char *cmd_workers(__maybe_unused PGconn *conn, char *cmd, char *id, "workername,difficultydefault,idlenotificationenabled," "idlenotificationtime", stats ? ",w_hashrate5m,w_hashrate1hr,w_elapsed,w_lastshare," - "w_lastdiff,w_diffacc,w_diffinv,w_shareacc,w_shareinv" : "", + "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" : "", FLDSEP); APPEND_REALLOC(buf, off, len, tmp); From 23f0b77f33f45badc0e2a0b5637def29ee5de9d9 Mon Sep 17 00:00:00 2001 From: kanoi Date: Fri, 19 Sep 2014 22:06:53 +1000 Subject: [PATCH 7/7] php - make the share age function reusable --- pool/base.php | 37 ++++++++++++++++++++++++++++++++++++- pool/page_workers.php | 32 +------------------------------- 2 files changed, 37 insertions(+), 32 deletions(-) diff --git a/pool/base.php b/pool/base.php index aab770b9..8f26c8b1 100644 --- a/pool/base.php +++ b/pool/base.php @@ -18,6 +18,41 @@ function adddbg($str) } } # +function howlongago($sec) +{ + if ($sec < 60) + $des = $sec.'s'; + else + { + $sec = round($sec/60); + if ($sec < 60) + $des = $sec.'min'; + else + { + $sec = round($sec/60); + if ($sec < 24) + { + $des = $sec.'hr'; + if ($sec != 1) + $des .= 's'; + } + else + { + $sec = round($sec/24); + if ($sec < 9999) + { + $des = $sec.'day'; + if ($sec != 1) + $des .= 's'; + } + else + $des = 'never'; + } + } + } + return $des; +} +# function btcfmt($amt) { $amt /= 100000000; @@ -240,7 +275,7 @@ function validUserPass($user, $pass) { $rep = checkPass($user, $pass); if ($rep != null) - $ans = repDecode($rep); + $ans = repDecode($rep); usleep(100000); // Max 10x per second if ($rep != null && $ans['STATUS'] == 'ok') { diff --git a/pool/page_workers.php b/pool/page_workers.php index 625630e6..7129ab60 100644 --- a/pool/page_workers.php +++ b/pool/page_workers.php @@ -42,37 +42,7 @@ function workuser($data, $user, &$offset, &$totshare, &$totdiff, $ld = ' '; $pg .= "$ld"; - if ($lst < 60) - $lstdes = $lst.'s'; - else - { - $lst = round($lst/60); - if ($lst < 60) - $lstdes = $lst.'min'; - else - { - $lst = round($lst/60); - if ($lst < 24) - { - $lstdes = $lst.'hr'; - if ($lst != 1) - $lstdes .= 's'; - } - else - { - $lst = round($lst/24); - if ($lst < 9999) - { - $lstdes = $lst.'day'; - if ($lst != 1) - $lstdes .= 's'; - } - else - $lstdes = 'never'; - } - } - } - $pg .= "$lstdes"; + $pg .= ''.howlongago($lst).''; $shareacc = number_format($ans['w_shareacc:'.$i], 0); $totshare += $ans['w_shareacc:'.$i];