|
|
@ -1424,7 +1424,9 @@ bool workers_fill(PGconn *conn) |
|
|
|
return ok; |
|
|
|
return ok; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Whatever the current paymentaddresses are, replace them with this one
|
|
|
|
/* Whatever the current paymentaddresses are, replace them with this one
|
|
|
|
|
|
|
|
* Code allows for zero, one or more current payment address |
|
|
|
|
|
|
|
* even though there currently can only be zero or one */ |
|
|
|
K_ITEM *paymentaddresses_set(PGconn *conn, int64_t userid, char *payaddress, |
|
|
|
K_ITEM *paymentaddresses_set(PGconn *conn, int64_t userid, char *payaddress, |
|
|
|
char *by, char *code, char *inet, tv_t *cd, |
|
|
|
char *by, char *code, char *inet, tv_t *cd, |
|
|
|
K_TREE *trf_root) |
|
|
|
K_TREE *trf_root) |
|
|
@ -1529,12 +1531,13 @@ unitem: |
|
|
|
if (!ok) |
|
|
|
if (!ok) |
|
|
|
k_add_head(paymentaddresses_free, item); |
|
|
|
k_add_head(paymentaddresses_free, item); |
|
|
|
else { |
|
|
|
else { |
|
|
|
// Remove from ram, old (unneeded) records
|
|
|
|
// Change the expiry on all the old ones
|
|
|
|
pa.userid = userid; |
|
|
|
pa.userid = userid; |
|
|
|
pa.expirydate.tv_sec = DATE_S_EOT; |
|
|
|
pa.expirydate.tv_sec = DATE_S_EOT; |
|
|
|
pa.payaddress[0] = '\0'; |
|
|
|
pa.payaddress[0] = '\0'; |
|
|
|
INIT_PAYMENTADDRESSES(&look); |
|
|
|
INIT_PAYMENTADDRESSES(&look); |
|
|
|
look.data = (void *)(&pa); |
|
|
|
look.data = (void *)(&pa); |
|
|
|
|
|
|
|
// Tree order is expirydate desc
|
|
|
|
old = find_after_in_ktree(paymentaddresses_root, &look, |
|
|
|
old = find_after_in_ktree(paymentaddresses_root, &look, |
|
|
|
cmp_paymentaddresses, ctx); |
|
|
|
cmp_paymentaddresses, ctx); |
|
|
|
while (old) { |
|
|
|
while (old) { |
|
|
@ -1543,9 +1546,15 @@ unitem: |
|
|
|
if (thispa->userid != userid) |
|
|
|
if (thispa->userid != userid) |
|
|
|
break; |
|
|
|
break; |
|
|
|
old = next_in_ktree(ctx); |
|
|
|
old = next_in_ktree(ctx); |
|
|
|
paymentaddresses_root = remove_from_ktree(paymentaddresses_root, this, |
|
|
|
/* Tree remove+add below doesn't matter since
|
|
|
|
cmp_paymentaddresses, ctx2); |
|
|
|
* this test will avoid reprocessing */ |
|
|
|
k_add_head(paymentaddresses_free, this); |
|
|
|
if (CURRENT(&(thispa->expirydate))) { |
|
|
|
|
|
|
|
paymentaddresses_root = remove_from_ktree(paymentaddresses_root, this, |
|
|
|
|
|
|
|
cmp_paymentaddresses, ctx2); |
|
|
|
|
|
|
|
copy_tv(&(thispa->expirydate), cd); |
|
|
|
|
|
|
|
paymentaddresses_root = add_to_ktree(paymentaddresses_root, this, |
|
|
|
|
|
|
|
cmp_paymentaddresses); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
paymentaddresses_root = add_to_ktree(paymentaddresses_root, item, |
|
|
|
paymentaddresses_root = add_to_ktree(paymentaddresses_root, item, |
|
|
|
cmp_paymentaddresses); |
|
|
|
cmp_paymentaddresses); |
|
|
@ -1565,8 +1574,7 @@ bool paymentaddresses_fill(PGconn *conn) |
|
|
|
PGresult *res; |
|
|
|
PGresult *res; |
|
|
|
K_ITEM *item; |
|
|
|
K_ITEM *item; |
|
|
|
PAYMENTADDRESSES *row; |
|
|
|
PAYMENTADDRESSES *row; |
|
|
|
char *params[1]; |
|
|
|
int n, i; |
|
|
|
int n, i, par = 0; |
|
|
|
|
|
|
|
char *field; |
|
|
|
char *field; |
|
|
|
char *sel; |
|
|
|
char *sel; |
|
|
|
int fields = 4; |
|
|
|
int fields = 4; |
|
|
@ -1577,11 +1585,8 @@ bool paymentaddresses_fill(PGconn *conn) |
|
|
|
sel = "select " |
|
|
|
sel = "select " |
|
|
|
"paymentaddressid,userid,payaddress,payratio" |
|
|
|
"paymentaddressid,userid,payaddress,payratio" |
|
|
|
HISTORYDATECONTROL |
|
|
|
HISTORYDATECONTROL |
|
|
|
" from paymentaddresses where expirydate=$1"; |
|
|
|
" from paymentaddresses"; |
|
|
|
par = 0; |
|
|
|
res = PQexec(conn, sel, CKPQ_READ); |
|
|
|
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); |
|
|
|
rescode = PQresultStatus(res); |
|
|
|
if (!PGOK(rescode)) { |
|
|
|
if (!PGOK(rescode)) { |
|
|
|
PGLOGERR("Select", rescode, conn); |
|
|
|
PGLOGERR("Select", rescode, conn); |
|
|
|