From cdfbef578f8cd1a8d38915beb1e9d175adcf9c28 Mon Sep 17 00:00:00 2001 From: kanoi Date: Tue, 2 Sep 2014 22:31:27 +1000 Subject: [PATCH] ckdb/php - add block height to homepage blocks --- pool/page.php | 6 ++++++ src/ckdb.c | 22 ++++++++++++++++++++-- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/pool/page.php b/pool/page.php index 1939977d..a9c1f727 100644 --- a/pool/page.php +++ b/pool/page.php @@ -187,6 +187,9 @@ function pgtop($dotop, $user, $douser) } } + if (isset($info['lastblockheight'])) + $plb .= ' ('.$info['lastblockheight'].')'; + if (isset($info['lastbc'])) { $nlb = $info['lastbc']; @@ -201,6 +204,9 @@ function pgtop($dotop, $user, $douser) } } + if (isset($info['lastheight'])) + $nlb .= ' ('.$info['lastheight'].')'; + if (isset($info['blockacc'])) { $acc = $info['blockacc']; diff --git a/src/ckdb.c b/src/ckdb.c index 4cb3b102..3e71db22 100644 --- a/src/ckdb.c +++ b/src/ckdb.c @@ -8656,8 +8656,21 @@ static char *cmd_homepage(__maybe_unused PGconn *conn, char *cmd, char *id, tvs_to_buf(&last_bc, reply, sizeof(reply)); snprintf(tmp, sizeof(tmp), "lastbc=%s%c", reply, FLDSEP); APPEND_REALLOC(buf, off, len, tmp); + if (workinfo_current) { + WORKINFO *wic; + int32_t hi; + DATA_WORKINFO(wic, workinfo_current); + hi = coinbase1height(wic->coinbase1); + snprintf(tmp, sizeof(tmp), "lastheight=%d%c", + hi-1, FLDSEP); + APPEND_REALLOC(buf, off, len, tmp); + } else { + snprintf(tmp, sizeof(tmp), "lastheight=?%c", FLDSEP); + APPEND_REALLOC(buf, off, len, tmp); + } } else { - snprintf(tmp, sizeof(tmp), "lastbc=?%c", FLDSEP); + snprintf(tmp, sizeof(tmp), "lastbc=?%clastheight=?%c", + FLDSEP, FLDSEP); APPEND_REALLOC(buf, off, len, tmp); } @@ -8680,8 +8693,13 @@ static char *cmd_homepage(__maybe_unused PGconn *conn, char *cmd, char *id, reply, FLDSEP, blocks->confirmed, FLDSEP); APPEND_REALLOC(buf, off, len, tmp); + snprintf(tmp, sizeof(tmp), "lastblockheight=%d%c", + blocks->height, FLDSEP); + APPEND_REALLOC(buf, off, len, tmp); } else { - snprintf(tmp, sizeof(tmp), "lastblock=?%cconfirmed=?%c", FLDSEP, FLDSEP); + snprintf(tmp, sizeof(tmp), "lastblock=?%cconfirmed=?%c" + "lastblockheight=?%c", + FLDSEP, FLDSEP, FLDSEP); APPEND_REALLOC(buf, off, len, tmp); }