From 55595f3855c962c9ed51fccf4ee5c503a3719f24 Mon Sep 17 00:00:00 2001 From: kanoi Date: Sat, 24 Jan 2015 17:57:38 +1100 Subject: [PATCH] ckdb/php - put the pool block # in the web block information --- pool/page_blocks.php | 5 ++++- src/ckdb.h | 2 +- src/ckdb_cmd.c | 15 +++++++++++++-- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/pool/page_blocks.php b/pool/page_blocks.php index 8e860ef2..a0d6e92f 100644 --- a/pool/page_blocks.php +++ b/pool/page_blocks.php @@ -96,10 +96,10 @@ function doblocks($data, $user) $csv = "Sequence,Height,Status,Timestamp,DiffAcc,NetDiff,Hash\n"; if ($ans['STATUS'] == 'ok') { + $tot = $ans['tot']; $count = $ans['rows']; for ($i = 0; $i < $count; $i++) { - $seq = $i + 1; if (($i % 2) == 0) $row = 'even'; else @@ -114,7 +114,10 @@ function doblocks($data, $user) { $ex = 's'; $orph = true; + $seq = ''; } + else + $seq = $tot--; if ($stat == '1-Confirm') { if (isset($data['info']['lastheight'])) diff --git a/src/ckdb.h b/src/ckdb.h index 4944ff81..56272881 100644 --- a/src/ckdb.h +++ b/src/ckdb.h @@ -52,7 +52,7 @@ #define DB_VLOCK "1" #define DB_VERSION "0.9.6" -#define CKDB_VERSION DB_VERSION"-0.902" +#define CKDB_VERSION DB_VERSION"-0.903" #define WHERE_FFL " - from %s %s() line %d" #define WHERE_FFL_HERE __FILE__, __func__, __LINE__ diff --git a/src/ckdb_cmd.c b/src/ckdb_cmd.c index 02ebd6b0..08001bdf 100644 --- a/src/ckdb_cmd.c +++ b/src/ckdb_cmd.c @@ -819,7 +819,7 @@ static char *cmd_blocklist(__maybe_unused PGconn *conn, char *cmd, char *id, size_t len, off; int32_t height = -1; tv_t first_cd = {0,0}; - int rows; + int rows, tot; LOGDEBUG("%s(): cmd '%s'", __func__, cmd); @@ -828,6 +828,16 @@ static char *cmd_blocklist(__maybe_unused PGconn *conn, char *cmd, char *id, rows = 0; K_RLOCK(blocks_free); b_item = last_in_ktree(blocks_root, ctx); + tot = 0; + while (b_item) { + DATA_BLOCKS(blocks, b_item); + if (CURRENT(&(blocks->expirydate))) { + if (blocks->confirmed[0] != BLOCKS_ORPHAN) + tot++; + } + b_item = prev_in_ktree(ctx); + } + b_item = last_in_ktree(blocks_root, ctx); while (b_item && rows < 42) { DATA_BLOCKS(blocks, b_item); if (height != blocks->height) { @@ -914,7 +924,8 @@ static char *cmd_blocklist(__maybe_unused PGconn *conn, char *cmd, char *id, } K_RUNLOCK(blocks_free); snprintf(tmp, sizeof(tmp), - "rows=%d%cflds=%s%c", + "tot=%d%crows=%d%cflds=%s%c", + tot, FLDSEP, rows, FLDSEP, "height,blockhash,nonce,reward,workername,firstcreatedate," "createdate,status,diffacc,diffinv,shareacc,shareinv,elapsed,"