Browse Source

ckdb/php - blocklist show correct status - php mark orphans

master
kanoi 10 years ago
parent
commit
e363ac0750
  1. 3
      pool/page.php
  2. 19
      pool/page_blocks.php
  3. 15
      src/ckdb.c

3
pool/page.php

@ -110,6 +110,9 @@ h1 {margin-top: 20px; float:middle; font-size: 20px;}
.dl {text-align: left; padding: 2px 8px;} .dl {text-align: left; padding: 2px 8px;}
.dr {text-align: right; padding: 2px 8px;} .dr {text-align: right; padding: 2px 8px;}
.dc {text-align: center; 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; }
</style>\n"; </style>\n";
$head .= '<meta name="robots" content="noindex">'; $head .= '<meta name="robots" content="noindex">';

19
pool/page_blocks.php

@ -12,7 +12,8 @@ function doblocks($data, $user)
$pg .= "<td class=dl>Height</td>"; $pg .= "<td class=dl>Height</td>";
$pg .= "<td class=dl>Who</td>"; $pg .= "<td class=dl>Who</td>";
$pg .= "<td class=dr>Reward</td>"; $pg .= "<td class=dr>Reward</td>";
$pg .= "<td class=dr>When</td>"; $pg .= "<td class=dc>When</td>";
$pg .= "<td class=dr>Status</td>";
$pg .= "</tr>\n"; $pg .= "</tr>\n";
if ($ans['STATUS'] == 'ok') if ($ans['STATUS'] == 'ok')
{ {
@ -24,11 +25,19 @@ function doblocks($data, $user)
else else
$row = 'odd'; $row = 'odd';
$ex = '';
$stat = $ans['status'.$i];
if ($stat == 'Orphan')
$ex = 's';
if ($stat == '1-Confirm')
$stat = 'Conf';
$pg .= "<tr class=$row>"; $pg .= "<tr class=$row>";
$pg .= '<td class=dl>'.$ans['height'.$i].'</td>'; $pg .= "<td class=dl$ex>".$ans['height'.$i].'</td>';
$pg .= '<td class=dl>'.$ans['workername'.$i].'</td>'; $pg .= "<td class=dl$ex>".$ans['workername'.$i].'</td>';
$pg .= '<td class=dr>'.btcfmt($ans['reward'.$i]).'</td>'; $pg .= "<td class=dr$ex>".btcfmt($ans['reward'.$i]).'</td>';
$pg .= '<td class=dl>'.gmdate('Y-m-d H:i:s+00', $ans['createdate'.$i]).'</td>'; $pg .= "<td class=dl$ex>".gmdate('Y-m-d H:i:s+00', $ans['createdate'.$i]).'</td>';
$pg .= "<td class=dr$ex>".$stat.'</td>';
$pg .= "</tr>\n"; $pg .= "</tr>\n";
} }
} }

15
src/ckdb.c

@ -47,7 +47,7 @@
#define DB_VLOCK "1" #define DB_VLOCK "1"
#define DB_VERSION "0.7" #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 " - from %s %s() line %d"
#define WHERE_FFL_HERE __FILE__, __func__, __LINE__ #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; char *buf;
size_t len, off; size_t len, off;
int rows; int rows;
int32_t height;
LOGDEBUG("%s(): cmd '%s'", __func__, cmd); LOGDEBUG("%s(): cmd '%s'", __func__, cmd);
b_item = last_in_ktree(blocks_root, ctx);
APPEND_REALLOC_INIT(buf, off, len); APPEND_REALLOC_INIT(buf, off, len);
APPEND_REALLOC(buf, off, len, "ok."); APPEND_REALLOC(buf, off, len, "ok.");
rows = 0; rows = 0;
height = -1; K_RLOCK(blocks_free);
b_item = last_in_ktree(blocks_root, ctx);
while (b_item && rows < 42) { while (b_item && rows < 42) {
if (height != DATA_BLOCKS(b_item)->height) { if (CURRENT(&(DATA_BLOCKS(b_item)->expirydate))) {
height = DATA_BLOCKS(b_item)->height; int_to_buf(DATA_BLOCKS(b_item)->height, reply, sizeof(reply));
snprintf(tmp, sizeof(tmp), "height%d=%s%c", rows, reply, FLDSEP);
snprintf(tmp, sizeof(tmp), "height%d=%d%c", rows, height, FLDSEP);
APPEND_REALLOC(buf, off, len, tmp); APPEND_REALLOC(buf, off, len, tmp);
str_to_buf(DATA_BLOCKS(b_item)->blockhash, reply, sizeof(reply)); 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); b_item = prev_in_ktree(ctx);
} }
K_RUNLOCK(blocks_free);
snprintf(tmp, sizeof(tmp), "rows=%d", rows); snprintf(tmp, sizeof(tmp), "rows=%d", rows);
APPEND_REALLOC(buf, off, len, tmp); APPEND_REALLOC(buf, off, len, tmp);

Loading…
Cancel
Save