From 543c5e70821c48d1de4c3ea3960b872730a798cc Mon Sep 17 00:00:00 2001 From: kanoi Date: Sat, 22 Aug 2015 22:17:19 +1000 Subject: [PATCH] ckdb - add optioncontrol override for blocklist rows --- src/ckdb.h | 7 ++++++- src/ckdb_cmd.c | 8 ++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/ckdb.h b/src/ckdb.h index 8c62f405..1038b5a0 100644 --- a/src/ckdb.h +++ b/src/ckdb.h @@ -55,7 +55,7 @@ #define DB_VLOCK "1" #define DB_VERSION "1.0.2" -#define CKDB_VERSION DB_VERSION"-1.224" +#define CKDB_VERSION DB_VERSION"-1.225" #define WHERE_FFL " - from %s %s() line %d" #define WHERE_FFL_HERE __FILE__, __func__, __LINE__ @@ -1548,6 +1548,11 @@ extern K_STORE *blocks_store; extern tv_t blocks_stats_time; extern bool blocks_stats_rebuild; +// Default number of blocks to display on web +#define BLOCKS_DEFAULT 42 +// OptionControl can override it +#define BLOCKS_SETTING_NAME "BlocksPageSize" + // MININGPAYOUTS typedef struct miningpayouts { int64_t payoutid; diff --git a/src/ckdb_cmd.c b/src/ckdb_cmd.c index bc96c1f9..fe03ab59 100644 --- a/src/ckdb_cmd.c +++ b/src/ckdb_cmd.c @@ -1116,7 +1116,7 @@ static char *cmd_workerstats(__maybe_unused PGconn *conn, char *cmd, char *id, } static char *cmd_blocklist(__maybe_unused PGconn *conn, char *cmd, char *id, - __maybe_unused tv_t *now, __maybe_unused char *by, + tv_t *now, __maybe_unused char *by, __maybe_unused char *code, __maybe_unused char *inet, __maybe_unused tv_t *notcd, __maybe_unused K_TREE *trf_root) @@ -1131,10 +1131,14 @@ static char *cmd_blocklist(__maybe_unused PGconn *conn, char *cmd, char *id, int32_t height = -1; tv_t first_cd = {0,0}, stats_tv = {0,0}, stats_tv2 = {0,0}; int rows, srows, tot, seq; + int64_t maxrows; bool has_stats; LOGDEBUG("%s(): cmd '%s'", __func__, cmd); + // 0 means just the system setting + maxrows = user_sys_setting(0, BLOCKS_SETTING_NAME, BLOCKS_DEFAULT, now); + APPEND_REALLOC_INIT(buf, off, len); APPEND_REALLOC(buf, off, len, "ok."); @@ -1158,7 +1162,7 @@ redo: } seq = tot; b_item = last_in_ktree(blocks_root, ctx); - while (b_item && rows < 42) { + while (b_item && rows < (int)maxrows) { DATA_BLOCKS(blocks, b_item); /* For each block remember the initial createdate * Reverse sort order the oldest expirydate is first