From e363ac0750c240ac85deeff0ab22ec0ceb11a5a5 Mon Sep 17 00:00:00 2001 From: kanoi Date: Sat, 30 Aug 2014 23:16:44 +1000 Subject: [PATCH] ckdb/php - blocklist show correct status - php mark orphans --- pool/page.php | 3 +++ pool/page_blocks.php | 19 ++++++++++++++----- src/ckdb.c | 15 +++++++-------- 3 files changed, 24 insertions(+), 13 deletions(-) diff --git a/pool/page.php b/pool/page.php index b522e9ff..1939977d 100644 --- a/pool/page.php +++ b/pool/page.php @@ -110,6 +110,9 @@ h1 {margin-top: 20px; float:middle; font-size: 20px;} .dl {text-align: left; padding: 2px 8px;} .dr {text-align: right; padding: 2px 8px;} .dc {text-align: center; padding: 2px 8px;} +.dls {text-align: left; padding: 2px 8px; text-decoration:line-through; font-weight:lighter; } +.drs {text-align: right; padding: 2px 8px; text-decoration:line-through; font-weight:lighter; } +.dcs {text-align: center; padding: 2px 8px; text-decoration:line-through; font-weight:lighter; } \n"; $head .= ''; diff --git a/pool/page_blocks.php b/pool/page_blocks.php index f031a96b..8d682fee 100644 --- a/pool/page_blocks.php +++ b/pool/page_blocks.php @@ -12,7 +12,8 @@ function doblocks($data, $user) $pg .= "Height"; $pg .= "Who"; $pg .= "Reward"; - $pg .= "When"; + $pg .= "When"; + $pg .= "Status"; $pg .= "\n"; if ($ans['STATUS'] == 'ok') { @@ -24,11 +25,19 @@ function doblocks($data, $user) else $row = 'odd'; + $ex = ''; + $stat = $ans['status'.$i]; + if ($stat == 'Orphan') + $ex = 's'; + if ($stat == '1-Confirm') + $stat = 'Conf'; + $pg .= ""; - $pg .= ''.$ans['height'.$i].''; - $pg .= ''.$ans['workername'.$i].''; - $pg .= ''.btcfmt($ans['reward'.$i]).''; - $pg .= ''.gmdate('Y-m-d H:i:s+00', $ans['createdate'.$i]).''; + $pg .= "".$ans['height'.$i].''; + $pg .= "".$ans['workername'.$i].''; + $pg .= "".btcfmt($ans['reward'.$i]).''; + $pg .= "".gmdate('Y-m-d H:i:s+00', $ans['createdate'.$i]).''; + $pg .= "".$stat.''; $pg .= "\n"; } } diff --git a/src/ckdb.c b/src/ckdb.c index d6e6d8d5..769577e1 100644 --- a/src/ckdb.c +++ b/src/ckdb.c @@ -47,7 +47,7 @@ #define DB_VLOCK "1" #define DB_VERSION "0.7" -#define CKDB_VERSION DB_VERSION"-0.105" +#define CKDB_VERSION DB_VERSION"-0.106" #define WHERE_FFL " - from %s %s() line %d" #define WHERE_FFL_HERE __FILE__, __func__, __LINE__ @@ -7273,20 +7273,18 @@ static char *cmd_blocklist(__maybe_unused PGconn *conn, char *cmd, char *id, char *buf; size_t len, off; int rows; - int32_t height; LOGDEBUG("%s(): cmd '%s'", __func__, cmd); - b_item = last_in_ktree(blocks_root, ctx); APPEND_REALLOC_INIT(buf, off, len); APPEND_REALLOC(buf, off, len, "ok."); rows = 0; - height = -1; + K_RLOCK(blocks_free); + b_item = last_in_ktree(blocks_root, ctx); while (b_item && rows < 42) { - if (height != DATA_BLOCKS(b_item)->height) { - height = DATA_BLOCKS(b_item)->height; - - snprintf(tmp, sizeof(tmp), "height%d=%d%c", rows, height, FLDSEP); + if (CURRENT(&(DATA_BLOCKS(b_item)->expirydate))) { + int_to_buf(DATA_BLOCKS(b_item)->height, reply, sizeof(reply)); + snprintf(tmp, sizeof(tmp), "height%d=%s%c", rows, reply, FLDSEP); APPEND_REALLOC(buf, off, len, tmp); str_to_buf(DATA_BLOCKS(b_item)->blockhash, reply, sizeof(reply)); @@ -7319,6 +7317,7 @@ static char *cmd_blocklist(__maybe_unused PGconn *conn, char *cmd, char *id, } b_item = prev_in_ktree(ctx); } + K_RUNLOCK(blocks_free); snprintf(tmp, sizeof(tmp), "rows=%d", rows); APPEND_REALLOC(buf, off, len, tmp);