From c178d6b3bb085a34b470c5141e4183161bb6ad5c Mon Sep 17 00:00:00 2001 From: kanoi Date: Tue, 4 Nov 2014 23:57:14 +1100 Subject: [PATCH] ckdb - ensure each block's workinfo is loaded --- src/ckdb.h | 2 +- src/ckdb_dbio.c | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/ckdb.h b/src/ckdb.h index 7ac5cdb0..da341b46 100644 --- a/src/ckdb.h +++ b/src/ckdb.h @@ -52,7 +52,7 @@ #define DB_VLOCK "1" #define DB_VERSION "0.9.2" -#define CKDB_VERSION DB_VERSION"-0.600" +#define CKDB_VERSION DB_VERSION"-0.601" #define WHERE_FFL " - from %s %s() line %d" #define WHERE_FFL_HERE __FILE__, __func__, __LINE__ diff --git a/src/ckdb_dbio.c b/src/ckdb_dbio.c index b69c8989..df791e24 100644 --- a/src/ckdb_dbio.c +++ b/src/ckdb_dbio.c @@ -2266,11 +2266,13 @@ bool workinfo_fill(PGconn *conn) "workinfoid,poolinstance,merklehash,prevhash," "coinbase1,coinbase2,version,bits,ntime,reward" HISTORYDATECONTROL - " from workinfo where workinfoid>=$1 and workinfoid<=$2 and expirydate=$3"; + " from workinfo where expirydate=$1 and" + " ((workinfoid>=$2 and workinfoid<=$3) or" + " workinfoid in (select workinfoid from blocks) )"; par = 0; + params[par++] = tv_to_buf((tv_t *)(&default_expiry), NULL, 0); params[par++] = bigint_to_buf(dbload_workinfoid_start, NULL, 0); params[par++] = bigint_to_buf(dbload_workinfoid_finish, NULL, 0); - params[par++] = tv_to_buf((tv_t *)(&default_expiry), NULL, 0); PARCHK(par, params); res = PQexecParams(conn, sel, par, NULL, (const char **)params, NULL, NULL, 0, CKPQ_READ); rescode = PQresultStatus(res);