Browse Source

ckdb - add in_ to the front of intransient workinfo fields

master
kanoi 8 years ago
parent
commit
39fed01b69
  1. 10
      src/ckdb.c
  2. 10
      src/ckdb.h
  3. 8
      src/ckdb_cmd.c
  4. 8
      src/ckdb_data.c
  5. 28
      src/ckdb_dbio.c

10
src/ckdb.c

@ -5204,7 +5204,7 @@ static void make_a_shift_mark()
return; return;
setnow(&now); setnow(&now);
ok = marks_process(NULL, true, workinfo->poolinstance, ok = marks_process(NULL, true, workinfo->in_poolinstance,
workinfo->workinfoid, description, EMPTY, workinfo->workinfoid, description, EMPTY,
MARKTYPE_OTHER_BEGIN_STR, MARK_USED_STR, MARKTYPE_OTHER_BEGIN_STR, MARK_USED_STR,
(char *)by_default, (char *)__func__, (char *)by_default, (char *)__func__,
@ -5383,7 +5383,7 @@ static void make_a_shift_mark()
return; return;
} }
if (wi_bits[0] == '\0') if (wi_bits[0] == '\0')
STRNCPY(wi_bits, workinfo->bits); STRNCPY(wi_bits, workinfo->in_bits);
else { else {
/* Make sure you set the SHIFT_DIFF_BLOCK_STR /* Make sure you set the SHIFT_DIFF_BLOCK_STR
* optioncontrol if you changed ckdb to V1.323 * optioncontrol if you changed ckdb to V1.323
@ -5405,14 +5405,14 @@ static void make_a_shift_mark()
/* Did difficulty change? /* Did difficulty change?
* Stop at the last workinfo, before the diff * Stop at the last workinfo, before the diff
* changed */ * changed */
if (strcmp(wi_bits, workinfo->bits) != 0) { if (strcmp(wi_bits, workinfo->in_bits) != 0) {
if (workinfo->height > (int32_t)shiftdiffblock) { if (workinfo->height > (int32_t)shiftdiffblock) {
LOGDEBUG("%s() OK shift stops for a diff" LOGDEBUG("%s() OK shift stops for a diff"
" change '%s->%s' %"PRId64 " change '%s->%s' %"PRId64
"->%"PRId64" height %"PRId32 "->%"PRId64" height %"PRId32
" limit %"PRId64, " limit %"PRId64,
__func__, wi_bits, __func__, wi_bits,
workinfo->bits, prev_wid, workinfo->in_bits, prev_wid,
workinfo->workinfoid, workinfo->workinfoid,
workinfo->height, workinfo->height,
shiftdiffblock); shiftdiffblock);
@ -5589,7 +5589,7 @@ static void make_a_shift_mark()
} }
setnow(&now); setnow(&now);
ok = marks_process(NULL, true, workinfo->poolinstance, ok = marks_process(NULL, true, workinfo->in_poolinstance,
marks_wid, des, extra, shifttype, status, marks_wid, des, extra, shifttype, status,
(char *)by_default, (char *)__func__, (char *)by_default, (char *)__func__,
(char *)inet_default, &now, NULL); (char *)inet_default, &now, NULL);

10
src/ckdb.h

@ -58,7 +58,7 @@
#define DB_VLOCK "1" #define DB_VLOCK "1"
#define DB_VERSION "1.0.7" #define DB_VERSION "1.0.7"
#define CKDB_VERSION DB_VERSION"-2.447" #define CKDB_VERSION DB_VERSION"-2.448"
#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__
@ -1951,14 +1951,14 @@ extern K_STORE *esm_store;
// WORKINFO workinfo.id.json={...} // WORKINFO workinfo.id.json={...}
typedef struct workinfo { typedef struct workinfo {
int64_t workinfoid; int64_t workinfoid;
char *poolinstance; char *in_poolinstance;
char *transactiontree; char *transactiontree;
char *merklehash; char *merklehash;
char *prevhash; char *in_prevhash;
char *coinbase1; char *coinbase1;
char *coinbase2; char *coinbase2;
char *version; char *in_version;
char *bits; char *in_bits;
char ntime[TXT_SML+1]; char ntime[TXT_SML+1];
int64_t reward; int64_t reward;
int32_t height; // non-DB field int32_t height; // non-DB field

8
src/ckdb_cmd.c

@ -6232,7 +6232,7 @@ static char *cmd_marks(PGconn *conn, char *cmd, char *id,
return strdup(reply); return strdup(reply);
} }
DATA_WORKINFO(workinfo, w_item); DATA_WORKINFO(workinfo, w_item);
ok = marks_process(conn, true, workinfo->poolinstance, ok = marks_process(conn, true, workinfo->in_poolinstance,
workinfoid, description, extra, marktype, workinfoid, description, extra, marktype,
status, by, code, inet, cd, trf_root); status, by, code, inet, cd, trf_root);
} else if (strcasecmp(action, "expire") == 0) { } else if (strcasecmp(action, "expire") == 0) {
@ -7145,7 +7145,7 @@ static char *cmd_query(__maybe_unused PGconn *conn, char *cmd, char *id,
APPEND_REALLOC(buf, off, len, tmp); APPEND_REALLOC(buf, off, len, tmp);
snprintf(tmp, sizeof(tmp), snprintf(tmp, sizeof(tmp),
"prevhash:%d=%s%c", "prevhash:%d=%s%c",
rows, workinfo->prevhash, FLDSEP); rows, workinfo->in_prevhash, FLDSEP);
APPEND_REALLOC(buf, off, len, tmp); APPEND_REALLOC(buf, off, len, tmp);
tv_to_buf(&(workinfo->expirydate), cd_buf, tv_to_buf(&(workinfo->expirydate), cd_buf,
sizeof(cd_buf)); sizeof(cd_buf));
@ -7354,7 +7354,7 @@ static char *cmd_query(__maybe_unused PGconn *conn, char *cmd, char *id,
this_height = workinfo->height; this_height = workinfo->height;
if (this_height == height) { if (this_height == height) {
// We have our starting point // We have our starting point
STRNCPY(bits, workinfo->bits); STRNCPY(bits, workinfo->in_bits);
got = true; got = true;
bigint_to_buf(workinfo->workinfoid, bigint_to_buf(workinfo->workinfoid,
@ -7371,7 +7371,7 @@ static char *cmd_query(__maybe_unused PGconn *conn, char *cmd, char *id,
while (wi_item) { while (wi_item) {
if (CURRENT(&(workinfo->expirydate))) { if (CURRENT(&(workinfo->expirydate))) {
if (strcmp(bits, workinfo->bits) != 0) if (strcmp(bits, workinfo->in_bits) != 0)
break; break;
} }
wi_item = next_in_ktree(ctx); wi_item = next_in_ktree(ctx);

8
src/ckdb_data.c

@ -2612,14 +2612,14 @@ bool workinfo_age(int64_t workinfoid, char *poolinstance, tv_t *cd,
} }
DATA_WORKINFO(workinfo, wi_item); DATA_WORKINFO(workinfo, wi_item);
if (strcmp(poolinstance, workinfo->poolinstance) != 0) { if (strcmp(poolinstance, workinfo->in_poolinstance) != 0) {
tv_to_buf(cd, cd_buf, sizeof(cd_buf)); tv_to_buf(cd, cd_buf, sizeof(cd_buf));
LOGERR("%s() %"PRId64"/%s/%ld,%ld %.19s Poolinstance changed " LOGERR("%s() %"PRId64"/%s/%ld,%ld %.19s Poolinstance changed "
// "(from %s)! Age discarded!", // "(from %s)! Age discarded!",
"(from %s)! Age not discarded", "(from %s)! Age not discarded",
__func__, workinfoid, poolinstance, __func__, workinfoid, poolinstance,
cd->tv_sec, cd->tv_usec, cd_buf, cd->tv_sec, cd->tv_usec, cd_buf,
workinfo->poolinstance); workinfo->in_poolinstance);
// TODO: ckdb only supports one, so until multiple support is written: // TODO: ckdb only supports one, so until multiple support is written:
// goto bye; // goto bye;
} }
@ -6608,7 +6608,7 @@ static bool gen_workmarkers(PGconn *conn, MARKS *stt, bool after, MARKS *fin,
fin->description, before ? "--" : ""); fin->description, before ? "--" : "");
ok = workmarkers_process(conn, false, true, 0, ok = workmarkers_process(conn, false, true, 0,
wi_fin->poolinstance, wi_fin->in_poolinstance,
wi_fin->workinfoid, wi_stt->workinfoid, wi_fin->workinfoid, wi_stt->workinfoid,
description, MARKER_READY_STR, description, MARKER_READY_STR,
by, code, inet, cd, trf_root); by, code, inet, cd, trf_root);
@ -6617,7 +6617,7 @@ static bool gen_workmarkers(PGconn *conn, MARKS *stt, bool after, MARKS *fin,
return false; return false;
} }
ok = marks_process(conn, true, wi_fin->poolinstance, fin->workinfoid, ok = marks_process(conn, true, wi_fin->in_poolinstance, fin->workinfoid,
fin->description, fin->extra, fin->marktype, fin->description, fin->extra, fin->marktype,
MARK_USED_STR, by, code, inet, cd, trf_root); MARK_USED_STR, by, code, inet, cd, trf_root);

28
src/ckdb_dbio.c

@ -3158,14 +3158,14 @@ int64_t workinfo_add(PGconn *conn, char *workinfoidstr,
bzero(row, sizeof(*row)); bzero(row, sizeof(*row));
TXT_TO_BIGINT("workinfoid", workinfoidstr, row->workinfoid); TXT_TO_BIGINT("workinfoid", workinfoidstr, row->workinfoid);
row->poolinstance = in_poolinstance->str; row->in_poolinstance = in_poolinstance->str;
DUP_POINTER(workinfo_free, row->transactiontree, transactiontree); DUP_POINTER(workinfo_free, row->transactiontree, transactiontree);
DUP_POINTER(workinfo_free, row->merklehash, merklehash); DUP_POINTER(workinfo_free, row->merklehash, merklehash);
row->prevhash = in_prevhash->str; row->in_prevhash = in_prevhash->str;
DUP_POINTER(workinfo_free, row->coinbase1, coinbase1); DUP_POINTER(workinfo_free, row->coinbase1, coinbase1);
DUP_POINTER(workinfo_free, row->coinbase2, coinbase2); DUP_POINTER(workinfo_free, row->coinbase2, coinbase2);
row->version = in_version->str; row->in_version = in_version->str;
row->bits = in_bits->str; row->in_bits = in_bits->str;
STRNCPY(row->ntime, ntime); STRNCPY(row->ntime, ntime);
TXT_TO_BIGINT("reward", reward, row->reward); TXT_TO_BIGINT("reward", reward, row->reward);
pool.reward = row->reward; pool.reward = row->reward;
@ -3193,14 +3193,14 @@ int64_t workinfo_add(PGconn *conn, char *workinfoidstr,
if (!confirm_sharesummary) { if (!confirm_sharesummary) {
par = 0; par = 0;
params[par++] = bigint_to_buf(row->workinfoid, NULL, 0); params[par++] = bigint_to_buf(row->workinfoid, NULL, 0);
params[par++] = str_to_buf(row->poolinstance, NULL, 0); params[par++] = str_to_buf(row->in_poolinstance, NULL, 0);
params[par++] = str_to_buf(row->transactiontree, NULL, 0); params[par++] = str_to_buf(row->transactiontree, NULL, 0);
params[par++] = str_to_buf(row->merklehash, NULL, 0); params[par++] = str_to_buf(row->merklehash, NULL, 0);
params[par++] = str_to_buf(row->prevhash, NULL, 0); params[par++] = str_to_buf(row->in_prevhash, NULL, 0);
params[par++] = str_to_buf(row->coinbase1, NULL, 0); params[par++] = str_to_buf(row->coinbase1, NULL, 0);
params[par++] = str_to_buf(row->coinbase2, NULL, 0); params[par++] = str_to_buf(row->coinbase2, NULL, 0);
params[par++] = str_to_buf(row->version, NULL, 0); params[par++] = str_to_buf(row->in_version, NULL, 0);
params[par++] = str_to_buf(row->bits, NULL, 0); params[par++] = str_to_buf(row->in_bits, NULL, 0);
params[par++] = str_to_buf(row->ntime, NULL, 0); params[par++] = str_to_buf(row->ntime, NULL, 0);
params[par++] = bigint_to_buf(row->reward, NULL, 0); params[par++] = bigint_to_buf(row->reward, NULL, 0);
HISTORYDATEPARAMS(params, par, row); HISTORYDATEPARAMS(params, par, row);
@ -3247,7 +3247,7 @@ unparam:
FREENULL(row->merklehash); FREENULL(row->merklehash);
row->height = coinbase1height(row); row->height = coinbase1height(row);
hex2bin(ndiffbin, row->bits, 4); hex2bin(ndiffbin, row->in_bits, 4);
row->diff_target = current_ndiff = diff_from_nbits(ndiffbin); row->diff_target = current_ndiff = diff_from_nbits(ndiffbin);
add_to_ktree(workinfo_root, item); add_to_ktree(workinfo_root, item);
@ -3392,7 +3392,7 @@ bool workinfo_fill(PGconn *conn)
POOLINSTANCE_DBLOAD_SET(workinfo, field); POOLINSTANCE_DBLOAD_SET(workinfo, field);
continue; continue;
} }
row->poolinstance = intransient_str("poolinstance", field); row->in_poolinstance = intransient_str("poolinstance", field);
PQ_GET_FLD(res, i, "workinfoid", field, ok); PQ_GET_FLD(res, i, "workinfoid", field, ok);
if (!ok) if (!ok)
@ -3405,7 +3405,7 @@ bool workinfo_fill(PGconn *conn)
PQ_GET_FLD(res, i, "prevhash", field, ok); PQ_GET_FLD(res, i, "prevhash", field, ok);
if (!ok) if (!ok)
break; break;
row->prevhash = intransient_str("prevhash", field); row->in_prevhash = intransient_str("prevhash", field);
PQ_GET_FLD(res, i, "coinbase1", field, ok); PQ_GET_FLD(res, i, "coinbase1", field, ok);
if (!ok) if (!ok)
@ -3422,12 +3422,12 @@ bool workinfo_fill(PGconn *conn)
PQ_GET_FLD(res, i, "version", field, ok); PQ_GET_FLD(res, i, "version", field, ok);
if (!ok) if (!ok)
break; break;
row->version = intransient_str("version", field); row->in_version = intransient_str("version", field);
PQ_GET_FLD(res, i, "bits", field, ok); PQ_GET_FLD(res, i, "bits", field, ok);
if (!ok) if (!ok)
break; break;
row->bits = intransient_str("bits", field); row->in_bits = intransient_str("bits", field);
PQ_GET_FLD(res, i, "ntime", field, ok); PQ_GET_FLD(res, i, "ntime", field, ok);
if (!ok) if (!ok)
@ -3445,7 +3445,7 @@ bool workinfo_fill(PGconn *conn)
break; break;
row->height = coinbase1height(row); row->height = coinbase1height(row);
hex2bin(ndiffbin, row->bits, 4); hex2bin(ndiffbin, row->in_bits, 4);
row->diff_target = diff_from_nbits(ndiffbin); row->diff_target = diff_from_nbits(ndiffbin);
add_to_ktree(workinfo_root, item); add_to_ktree(workinfo_root, item);

Loading…
Cancel
Save