From bf602d4a18607b9c73da59227f51ae46ea2c2195 Mon Sep 17 00:00:00 2001 From: kanoi Date: Sun, 31 Aug 2014 16:46:22 +1000 Subject: [PATCH] ckdb/php - add/show block find time to blocklist --- pool/page_blocks.php | 2 +- src/ckdb.c | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/pool/page_blocks.php b/pool/page_blocks.php index 8d682fee..0168b8d2 100644 --- a/pool/page_blocks.php +++ b/pool/page_blocks.php @@ -36,7 +36,7 @@ function doblocks($data, $user) $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 .= "".gmdate('Y-m-d H:i:s+00', $ans['firstcreatedate'.$i]).''; $pg .= "".$stat.''; $pg .= "\n"; } diff --git a/src/ckdb.c b/src/ckdb.c index 72f55bc1..7024c0a0 100644 --- a/src/ckdb.c +++ b/src/ckdb.c @@ -47,7 +47,7 @@ #define DB_VLOCK "1" #define DB_VERSION "0.8" -#define CKDB_VERSION DB_VERSION"-0.200" +#define CKDB_VERSION DB_VERSION"-0.201" #define WHERE_FFL " - from %s %s() line %d" #define WHERE_FFL_HERE __FILE__, __func__, __LINE__ @@ -7256,6 +7256,8 @@ static char *cmd_blocklist(__maybe_unused PGconn *conn, char *cmd, char *id, char tmp[1024]; char *buf; size_t len, off; + int32_t height = -1; + tv_t first_cd = {0,0}; int rows; LOGDEBUG("%s(): cmd '%s'", __func__, cmd); @@ -7266,6 +7268,10 @@ static char *cmd_blocklist(__maybe_unused PGconn *conn, char *cmd, char *id, 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; + copy_tv(&first_cd, &(DATA_BLOCKS(b_item)->createdate)); + } 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); @@ -7287,6 +7293,11 @@ static char *cmd_blocklist(__maybe_unused PGconn *conn, char *cmd, char *id, snprintf(tmp, sizeof(tmp), "workername%d=%s%c", rows, reply, FLDSEP); APPEND_REALLOC(buf, off, len, tmp); + snprintf(tmp, sizeof(tmp), + "firstcreatedate%d=%ld%c", rows, + first_cd.tv_sec, FLDSEP); + APPEND_REALLOC(buf, off, len, tmp); + snprintf(tmp, sizeof(tmp), "createdate%d=%ld%c", rows, DATA_BLOCKS(b_item)->createdate.tv_sec, FLDSEP);