From 05f5cfd27bbc59ccf1bb5891222379a19908f095 Mon Sep 17 00:00:00 2001 From: kanoi Date: Thu, 28 Aug 2014 12:07:09 +1000 Subject: [PATCH] ckdb/php - add more pplns info and fix a ckdb corruption --- pool/page_pplns.php | 11 +++++++++-- src/ckdb.c | 20 +++++++++++++++++--- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/pool/page_pplns.php b/pool/page_pplns.php index d2b812a6..4b38074b 100644 --- a/pool/page_pplns.php +++ b/pool/page_pplns.php @@ -44,22 +44,29 @@ Block: return '
'.$ans['STATUS'].': '.$ans['ERROR'].'
'; $data = array( 'Block' => 'block', + 'Block Hash' => 'block_hash', + 'Block Reward (Satoshis)' => 'block_reward', 'PPLNS Wanted' => 'diff_want', 'PPLNS Used' => 'diffacc_total', 'Elapsed Seconds' => 'pplns_elapsed', 'Users' => 'rows', 'Oldest Workinfoid' => 'begin_workinfoid', 'Oldest Time' => 'begin_stamp', + 'Oldest Epoch' => 'begin_epoch', 'Block Workinfoid' => 'block_workinfoid', 'Block Time' => 'block_stamp', + 'Block Epoch' => 'block_epoch', 'Newest Workinfoid' => 'end_workinfoid', - 'Newest Time' => 'end_stamp', + 'Newest Share Time' => 'end_stamp', + 'Newest Share Epoch' => 'end_epoch', 'Network Difficulty' => 'block_ndiff', 'PPLNS Factor' => 'diff_times', 'PPLNS Added' => 'diff_add', 'Share Count' => 'share_count'); - $pg = "
\n"; + $pg = '
Blockchain '.$ans['block']."
\n"; + $pg .= "
\n"; $pg .= ''; $pg .= ''; $pg .= ''; diff --git a/src/ckdb.c b/src/ckdb.c index 21670485..a4928a70 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.71" +#define CKDB_VERSION DB_VERSION"-0.100" #define WHERE_FFL " - from %s %s() line %d" #define WHERE_FFL_HERE __FILE__, __func__, __LINE__ @@ -5080,7 +5080,7 @@ static bool blocks_fill(PGconn *conn) PQ_GET_FLD(res, i, "workername", field, ok); if (!ok) break; - TXT_TO_BLOB("workername", field, row->workername); + TXT_TO_STR("workername", field, row->workername); PQ_GET_FLD(res, i, "clientid", field, ok); if (!ok) @@ -5573,7 +5573,7 @@ static bool auths_fill(PGconn *conn) PQ_GET_FLD(res, i, "enonce1", field, ok); if (!ok) break; - TXT_TO_BLOB("enonce1", field, row->enonce1); + TXT_TO_STR("enonce1", field, row->enonce1); PQ_GET_FLD(res, i, "useragent", field, ok); if (!ok) @@ -8352,6 +8352,14 @@ static char *cmd_pplns(__maybe_unused PGconn *conn, char *cmd, char *id, APPEND_REALLOC(buf, off, len, "ok."); snprintf(tmp, sizeof(tmp), "block=%d%c", height, FLDSEP); APPEND_REALLOC(buf, off, len, tmp); + snprintf(tmp, sizeof(tmp), "block_hash=%s%c", DATA_BLOCKS(b_item)->blockhash, FLDSEP); + APPEND_REALLOC(buf, off, len, tmp); + snprintf(tmp, sizeof(tmp), "block_reward=%"PRId64"%c", DATA_BLOCKS(b_item)->reward, FLDSEP); + APPEND_REALLOC(buf, off, len, tmp); + snprintf(tmp, sizeof(tmp), "workername=%s%c", DATA_BLOCKS(b_item)->workername, FLDSEP); + APPEND_REALLOC(buf, off, len, tmp); + snprintf(tmp, sizeof(tmp), "nonce=%s%c", DATA_BLOCKS(b_item)->nonce, FLDSEP); + APPEND_REALLOC(buf, off, len, tmp); snprintf(tmp, sizeof(tmp), "begin_workinfoid=%"PRId64"%c", begin_workinfoid, FLDSEP); APPEND_REALLOC(buf, off, len, tmp); snprintf(tmp, sizeof(tmp), "block_workinfoid=%"PRId64"%c", workinfoid, FLDSEP); @@ -8401,12 +8409,18 @@ static char *cmd_pplns(__maybe_unused PGconn *conn, char *cmd, char *id, tv_to_buf(&begin_tv, tv_buf, sizeof(tv_buf)); snprintf(tmp, sizeof(tmp), "begin_stamp=%s%c", tv_buf, FLDSEP); APPEND_REALLOC(buf, off, len, tmp); + snprintf(tmp, sizeof(tmp), "begin_epoch=%ld%c", begin_tv.tv_sec, FLDSEP); + APPEND_REALLOC(buf, off, len, tmp); tv_to_buf(&block_tv, tv_buf, sizeof(tv_buf)); snprintf(tmp, sizeof(tmp), "block_stamp=%s%c", tv_buf, FLDSEP); APPEND_REALLOC(buf, off, len, tmp); + snprintf(tmp, sizeof(tmp), "block_epoch=%ld%c", block_tv.tv_sec, FLDSEP); + APPEND_REALLOC(buf, off, len, tmp); tv_to_buf(&end_tv, tv_buf, sizeof(tv_buf)); snprintf(tmp, sizeof(tmp), "end_stamp=%s%c", tv_buf, FLDSEP); APPEND_REALLOC(buf, off, len, tmp); + snprintf(tmp, sizeof(tmp), "end_epoch=%ld%c", end_tv.tv_sec, FLDSEP); + APPEND_REALLOC(buf, off, len, tmp); snprintf(tmp, sizeof(tmp), "block_ndiff=%f%c", ndiff, FLDSEP); APPEND_REALLOC(buf, off, len, tmp);
NameValue