|
|
@ -3187,11 +3187,9 @@ static char *cmd_homepage(__maybe_unused PGconn *conn, char *cmd, char *id, |
|
|
|
K_RLOCK(workinfo_free); |
|
|
|
K_RLOCK(workinfo_free); |
|
|
|
if (workinfo_current) { |
|
|
|
if (workinfo_current) { |
|
|
|
WORKINFO *wic; |
|
|
|
WORKINFO *wic; |
|
|
|
int32_t hi; |
|
|
|
|
|
|
|
DATA_WORKINFO(wic, workinfo_current); |
|
|
|
DATA_WORKINFO(wic, workinfo_current); |
|
|
|
hi = coinbase1height(wic->coinbase1); |
|
|
|
|
|
|
|
snprintf(tmp, sizeof(tmp), "lastheight=%d%c", |
|
|
|
snprintf(tmp, sizeof(tmp), "lastheight=%d%c", |
|
|
|
hi-1, FLDSEP); |
|
|
|
wic->height-1, FLDSEP); |
|
|
|
APPEND_REALLOC(buf, off, len, tmp); |
|
|
|
APPEND_REALLOC(buf, off, len, tmp); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
snprintf(tmp, sizeof(tmp), "lastheight=?%c", FLDSEP); |
|
|
|
snprintf(tmp, sizeof(tmp), "lastheight=?%c", FLDSEP); |
|
|
@ -4066,7 +4064,6 @@ static char *cmd_pplns(__maybe_unused PGconn *conn, char *cmd, char *id, |
|
|
|
double diff_add = 0.0; |
|
|
|
double diff_add = 0.0; |
|
|
|
double diff_want; |
|
|
|
double diff_want; |
|
|
|
bool allow_aged = false, countbacklimit; |
|
|
|
bool allow_aged = false, countbacklimit; |
|
|
|
char ndiffbin[TXT_SML+1]; |
|
|
|
|
|
|
|
size_t len, off; |
|
|
|
size_t len, off; |
|
|
|
int rows; |
|
|
|
int rows; |
|
|
|
|
|
|
|
|
|
|
@ -4156,8 +4153,7 @@ static char *cmd_pplns(__maybe_unused PGconn *conn, char *cmd, char *id, |
|
|
|
} |
|
|
|
} |
|
|
|
DATA_WORKINFO(workinfo, w_item); |
|
|
|
DATA_WORKINFO(workinfo, w_item); |
|
|
|
|
|
|
|
|
|
|
|
hex2bin(ndiffbin, workinfo->bits, 4); |
|
|
|
ndiff = workinfo->diff_target; |
|
|
|
ndiff = diff_from_nbits(ndiffbin); |
|
|
|
|
|
|
|
diff_want = ndiff * diff_times + diff_add; |
|
|
|
diff_want = ndiff * diff_times + diff_add; |
|
|
|
if (diff_want < 1.0) { |
|
|
|
if (diff_want < 1.0) { |
|
|
|
snprintf(reply, siz, |
|
|
|
snprintf(reply, siz, |
|
|
@ -4527,8 +4523,6 @@ static char *cmd_pplns2(__maybe_unused PGconn *conn, char *cmd, char *id, |
|
|
|
PAYOUTS *payouts; |
|
|
|
PAYOUTS *payouts; |
|
|
|
BLOCKS lookblocks, *blocks; |
|
|
|
BLOCKS lookblocks, *blocks; |
|
|
|
WORKINFO *bworkinfo, *workinfo; |
|
|
|
WORKINFO *bworkinfo, *workinfo; |
|
|
|
char ndiffbin[TXT_SML+1]; |
|
|
|
|
|
|
|
double ndiff; |
|
|
|
|
|
|
|
USERS *users; |
|
|
|
USERS *users; |
|
|
|
int32_t height; |
|
|
|
int32_t height; |
|
|
|
K_TREE_CTX b_ctx[1], mp_ctx[1], pay_ctx[1]; |
|
|
|
K_TREE_CTX b_ctx[1], mp_ctx[1], pay_ctx[1]; |
|
|
@ -4759,9 +4753,8 @@ static char *cmd_pplns2(__maybe_unused PGconn *conn, char *cmd, char *id, |
|
|
|
APPEND_REALLOC(buf, off, len, tmp); |
|
|
|
APPEND_REALLOC(buf, off, len, tmp); |
|
|
|
snprintf(tmp, sizeof(tmp), "%s%c", payouts->stats, FLDSEP); |
|
|
|
snprintf(tmp, sizeof(tmp), "%s%c", payouts->stats, FLDSEP); |
|
|
|
APPEND_REALLOC(buf, off, len, tmp); |
|
|
|
APPEND_REALLOC(buf, off, len, tmp); |
|
|
|
hex2bin(ndiffbin, bworkinfo->bits, 4); |
|
|
|
snprintf(tmp, sizeof(tmp), "block_ndiff=%f%c", |
|
|
|
ndiff = diff_from_nbits(ndiffbin); |
|
|
|
bworkinfo->diff_target, FLDSEP); |
|
|
|
snprintf(tmp, sizeof(tmp), "block_ndiff=%f%c", ndiff, FLDSEP); |
|
|
|
|
|
|
|
APPEND_REALLOC(buf, off, len, tmp); |
|
|
|
APPEND_REALLOC(buf, off, len, tmp); |
|
|
|
snprintf(tmp, sizeof(tmp), "diff_want=%.1f%c", |
|
|
|
snprintf(tmp, sizeof(tmp), "diff_want=%.1f%c", |
|
|
|
payouts->diffwanted, FLDSEP); |
|
|
|
payouts->diffwanted, FLDSEP); |
|
|
@ -6738,7 +6731,6 @@ static char *cmd_query(__maybe_unused PGconn *conn, char *cmd, char *id, |
|
|
|
* pgsql scripts would do that to the DB, then ckdb would |
|
|
|
* pgsql scripts would do that to the DB, then ckdb would |
|
|
|
* load them the next time it (re)starts */ |
|
|
|
* load them the next time it (re)starts */ |
|
|
|
K_ITEM *i_wid, *i_expired, *wi_item, *wm_item; |
|
|
|
K_ITEM *i_wid, *i_expired, *wi_item, *wm_item; |
|
|
|
char ndiffbin[TXT_SML+1]; |
|
|
|
|
|
|
|
bool expired = false; |
|
|
|
bool expired = false; |
|
|
|
WORKINFO *workinfo; |
|
|
|
WORKINFO *workinfo; |
|
|
|
WORKMARKERS *wm; |
|
|
|
WORKMARKERS *wm; |
|
|
@ -6776,7 +6768,7 @@ static char *cmd_query(__maybe_unused PGconn *conn, char *cmd, char *id, |
|
|
|
"workinfoid:%d=%s%c", |
|
|
|
"workinfoid:%d=%s%c", |
|
|
|
rows, reply, FLDSEP); |
|
|
|
rows, reply, FLDSEP); |
|
|
|
APPEND_REALLOC(buf, off, len, tmp); |
|
|
|
APPEND_REALLOC(buf, off, len, tmp); |
|
|
|
int_to_buf(coinbase1height(workinfo->coinbase1), |
|
|
|
int_to_buf(workinfo->height, |
|
|
|
reply, sizeof(reply)); |
|
|
|
reply, sizeof(reply)); |
|
|
|
snprintf(tmp, sizeof(tmp), |
|
|
|
snprintf(tmp, sizeof(tmp), |
|
|
|
"height:%d=%s%c", |
|
|
|
"height:%d=%s%c", |
|
|
@ -6798,10 +6790,9 @@ static char *cmd_query(__maybe_unused PGconn *conn, char *cmd, char *id, |
|
|
|
CDDB"_str:%d=%s%c", |
|
|
|
CDDB"_str:%d=%s%c", |
|
|
|
rows, cd_buf, FLDSEP); |
|
|
|
rows, cd_buf, FLDSEP); |
|
|
|
APPEND_REALLOC(buf, off, len, tmp); |
|
|
|
APPEND_REALLOC(buf, off, len, tmp); |
|
|
|
hex2bin(ndiffbin, workinfo->bits, 4); |
|
|
|
|
|
|
|
snprintf(tmp, sizeof(tmp), |
|
|
|
snprintf(tmp, sizeof(tmp), |
|
|
|
"ndiff:%d=%.1f%c", rows, |
|
|
|
"ndiff:%d=%.1f%c", rows, |
|
|
|
diff_from_nbits(ndiffbin), |
|
|
|
workinfo->diff_target, |
|
|
|
FLDSEP); |
|
|
|
FLDSEP); |
|
|
|
APPEND_REALLOC(buf, off, len, tmp); |
|
|
|
APPEND_REALLOC(buf, off, len, tmp); |
|
|
|
snprintf(tmp, sizeof(tmp), |
|
|
|
snprintf(tmp, sizeof(tmp), |
|
|
@ -6899,7 +6890,7 @@ static char *cmd_query(__maybe_unused PGconn *conn, char *cmd, char *id, |
|
|
|
wi_item = last_in_ktree(workinfo_root, ctx); |
|
|
|
wi_item = last_in_ktree(workinfo_root, ctx); |
|
|
|
DATA_WORKINFO_NULL(workinfo, wi_item); |
|
|
|
DATA_WORKINFO_NULL(workinfo, wi_item); |
|
|
|
while (wi_item) { |
|
|
|
while (wi_item) { |
|
|
|
this_height = coinbase1height(workinfo->coinbase1); |
|
|
|
this_height = workinfo->height; |
|
|
|
if (this_height < height) |
|
|
|
if (this_height < height) |
|
|
|
break; |
|
|
|
break; |
|
|
|
if (CURRENT(&(workinfo->expirydate)) && |
|
|
|
if (CURRENT(&(workinfo->expirydate)) && |
|
|
@ -6946,7 +6937,6 @@ static char *cmd_query(__maybe_unused PGconn *conn, char *cmd, char *id, |
|
|
|
K_ITEM *i_height, *wi_item; |
|
|
|
K_ITEM *i_height, *wi_item; |
|
|
|
WORKINFO *workinfo = NULL; |
|
|
|
WORKINFO *workinfo = NULL; |
|
|
|
int32_t height, this_height; |
|
|
|
int32_t height, this_height; |
|
|
|
char ndiffbin[TXT_SML+1]; |
|
|
|
|
|
|
|
char bits[TXT_SML+1]; |
|
|
|
char bits[TXT_SML+1]; |
|
|
|
bool got = false; |
|
|
|
bool got = false; |
|
|
|
|
|
|
|
|
|
|
@ -6971,7 +6961,7 @@ static char *cmd_query(__maybe_unused PGconn *conn, char *cmd, char *id, |
|
|
|
DATA_WORKINFO_NULL(workinfo, wi_item); |
|
|
|
DATA_WORKINFO_NULL(workinfo, wi_item); |
|
|
|
while (wi_item) { |
|
|
|
while (wi_item) { |
|
|
|
if (CURRENT(&(workinfo->expirydate))) { |
|
|
|
if (CURRENT(&(workinfo->expirydate))) { |
|
|
|
this_height = coinbase1height(workinfo->coinbase1); |
|
|
|
this_height = workinfo->height; |
|
|
|
if (this_height < height) |
|
|
|
if (this_height < height) |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
@ -6984,7 +6974,7 @@ static char *cmd_query(__maybe_unused PGconn *conn, char *cmd, char *id, |
|
|
|
DATA_WORKINFO_NULL(workinfo, wi_item); |
|
|
|
DATA_WORKINFO_NULL(workinfo, wi_item); |
|
|
|
while (wi_item) { |
|
|
|
while (wi_item) { |
|
|
|
if (CURRENT(&(workinfo->expirydate))) { |
|
|
|
if (CURRENT(&(workinfo->expirydate))) { |
|
|
|
this_height = coinbase1height(workinfo->coinbase1); |
|
|
|
this_height = workinfo->height; |
|
|
|
if (this_height >= height) |
|
|
|
if (this_height >= height) |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
@ -6993,7 +6983,7 @@ static char *cmd_query(__maybe_unused PGconn *conn, char *cmd, char *id, |
|
|
|
} |
|
|
|
} |
|
|
|
if (wi_item) { |
|
|
|
if (wi_item) { |
|
|
|
DATA_WORKINFO(workinfo, wi_item); |
|
|
|
DATA_WORKINFO(workinfo, wi_item); |
|
|
|
this_height = coinbase1height(workinfo->coinbase1); |
|
|
|
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->bits); |
|
|
@ -7005,10 +6995,9 @@ static char *cmd_query(__maybe_unused PGconn *conn, char *cmd, char *id, |
|
|
|
"workinfoid0:%d=%s%c", |
|
|
|
"workinfoid0:%d=%s%c", |
|
|
|
rows, reply, FLDSEP); |
|
|
|
rows, reply, FLDSEP); |
|
|
|
APPEND_REALLOC(buf, off, len, tmp); |
|
|
|
APPEND_REALLOC(buf, off, len, tmp); |
|
|
|
hex2bin(ndiffbin, workinfo->bits, 4); |
|
|
|
|
|
|
|
snprintf(tmp, sizeof(tmp), |
|
|
|
snprintf(tmp, sizeof(tmp), |
|
|
|
"ndiff0:%d=%.1f%c", rows, |
|
|
|
"ndiff0:%d=%.1f%c", rows, |
|
|
|
diff_from_nbits(ndiffbin), |
|
|
|
workinfo->diff_target, |
|
|
|
FLDSEP); |
|
|
|
FLDSEP); |
|
|
|
APPEND_REALLOC(buf, off, len, tmp); |
|
|
|
APPEND_REALLOC(buf, off, len, tmp); |
|
|
|
|
|
|
|
|
|
|
@ -7045,7 +7034,7 @@ static char *cmd_query(__maybe_unused PGconn *conn, char *cmd, char *id, |
|
|
|
rows, FLDSEP); |
|
|
|
rows, FLDSEP); |
|
|
|
APPEND_REALLOC(buf, off, len, tmp); |
|
|
|
APPEND_REALLOC(buf, off, len, tmp); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
this_height = coinbase1height(workinfo->coinbase1); |
|
|
|
this_height = workinfo->height; |
|
|
|
int_to_buf(this_height, reply, sizeof(reply)); |
|
|
|
int_to_buf(this_height, reply, sizeof(reply)); |
|
|
|
snprintf(tmp, sizeof(tmp), "height:%d=%s%c", |
|
|
|
snprintf(tmp, sizeof(tmp), "height:%d=%s%c", |
|
|
|
rows, reply, FLDSEP); |
|
|
|
rows, reply, FLDSEP); |
|
|
@ -7055,10 +7044,9 @@ static char *cmd_query(__maybe_unused PGconn *conn, char *cmd, char *id, |
|
|
|
snprintf(tmp, sizeof(tmp), "workinfoid:%d=%s%c", |
|
|
|
snprintf(tmp, sizeof(tmp), "workinfoid:%d=%s%c", |
|
|
|
rows, reply, FLDSEP); |
|
|
|
rows, reply, FLDSEP); |
|
|
|
APPEND_REALLOC(buf, off, len, tmp); |
|
|
|
APPEND_REALLOC(buf, off, len, tmp); |
|
|
|
hex2bin(ndiffbin, workinfo->bits, 4); |
|
|
|
|
|
|
|
snprintf(tmp, sizeof(tmp), "ndiff:%d=%.1f%c", |
|
|
|
snprintf(tmp, sizeof(tmp), "ndiff:%d=%.1f%c", |
|
|
|
rows, |
|
|
|
rows, |
|
|
|
diff_from_nbits(ndiffbin), |
|
|
|
workinfo->diff_target, |
|
|
|
FLDSEP); |
|
|
|
FLDSEP); |
|
|
|
APPEND_REALLOC(buf, off, len, tmp); |
|
|
|
APPEND_REALLOC(buf, off, len, tmp); |
|
|
|
} |
|
|
|
} |
|
|
|