|
|
@ -3390,43 +3390,72 @@ static char *cmd_pplns(__maybe_unused PGconn *conn, char *cmd, char *id, |
|
|
|
K_RLOCK(users_free); |
|
|
|
K_RLOCK(users_free); |
|
|
|
u_item = find_userid(miningpayouts->userid); |
|
|
|
u_item = find_userid(miningpayouts->userid); |
|
|
|
K_RUNLOCK(users_free); |
|
|
|
K_RUNLOCK(users_free); |
|
|
|
if (u_item) { |
|
|
|
if (!u_item) { |
|
|
|
|
|
|
|
snprintf(reply, siz, |
|
|
|
|
|
|
|
"ERR.unknown userid %"PRId64, |
|
|
|
|
|
|
|
miningpayouts->userid); |
|
|
|
|
|
|
|
goto shazbot; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DATA_USERS(users, u_item); |
|
|
|
|
|
|
|
|
|
|
|
K_ITEM *pa_item; |
|
|
|
K_ITEM *pa_item; |
|
|
|
PAYMENTADDRESSES *pa; |
|
|
|
PAYMENTADDRESSES *pa; |
|
|
|
char *payaddress; |
|
|
|
int64_t paytotal; |
|
|
|
|
|
|
|
double amount; |
|
|
|
|
|
|
|
int count; |
|
|
|
|
|
|
|
|
|
|
|
// TODO: handle multiple addresses for one user
|
|
|
|
K_RLOCK(paymentaddresses_free); |
|
|
|
pa_item = find_paymentaddresses(miningpayouts->userid, pay_ctx); |
|
|
|
pa_item = find_paymentaddresses(miningpayouts->userid, pay_ctx); |
|
|
|
if (pa_item) { |
|
|
|
if (pa_item) { |
|
|
|
|
|
|
|
paytotal = 0; |
|
|
|
DATA_PAYMENTADDRESSES(pa, pa_item); |
|
|
|
DATA_PAYMENTADDRESSES(pa, pa_item); |
|
|
|
payaddress = pa->payaddress; |
|
|
|
while (pa_item && CURRENT(&(pa->expirydate)) && |
|
|
|
} else |
|
|
|
pa->userid == miningpayouts->userid) { |
|
|
|
payaddress = "none"; |
|
|
|
paytotal += pa->payratio; |
|
|
|
|
|
|
|
pa_item = prev_in_ktree(pay_ctx); |
|
|
|
|
|
|
|
DATA_PAYMENTADDRESSES_NULL(pa, pa_item); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
count = 0; |
|
|
|
|
|
|
|
pa_item = find_paymentaddresses(miningpayouts->userid, pay_ctx); |
|
|
|
|
|
|
|
DATA_PAYMENTADDRESSES_NULL(pa, pa_item); |
|
|
|
|
|
|
|
while (pa_item && CURRENT(&(pa->expirydate)) && |
|
|
|
|
|
|
|
pa->userid == miningpayouts->userid) { |
|
|
|
|
|
|
|
amount = (double)(miningpayouts->amount) * |
|
|
|
|
|
|
|
(double)pa->payratio / (double)paytotal; |
|
|
|
|
|
|
|
|
|
|
|
DATA_USERS(users, u_item); |
|
|
|
|
|
|
|
snprintf(tmp, sizeof(tmp), |
|
|
|
snprintf(tmp, sizeof(tmp), |
|
|
|
"user:%d=%s%cpayaddress:%d=%s%c", |
|
|
|
"user:%d=%s.%d%cpayaddress:%d=%s%c", |
|
|
|
rows, users->username, FLDSEP, |
|
|
|
rows, users->username, ++count, FLDSEP, |
|
|
|
rows, payaddress, FLDSEP); |
|
|
|
rows, pa->payaddress, FLDSEP); |
|
|
|
|
|
|
|
APPEND_REALLOC(buf, off, len, tmp); |
|
|
|
|
|
|
|
snprintf(tmp, sizeof(tmp), |
|
|
|
|
|
|
|
"diffacc_user:%d=%.1f%c", |
|
|
|
|
|
|
|
rows, amount, FLDSEP); |
|
|
|
|
|
|
|
APPEND_REALLOC(buf, off, len, tmp); |
|
|
|
|
|
|
|
rows++; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pa_item = prev_in_ktree(pay_ctx); |
|
|
|
|
|
|
|
DATA_PAYMENTADDRESSES_NULL(pa, pa_item); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
K_RUNLOCK(paymentaddresses_free); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
|
|
|
|
K_RUNLOCK(paymentaddresses_free); |
|
|
|
snprintf(tmp, sizeof(tmp), |
|
|
|
snprintf(tmp, sizeof(tmp), |
|
|
|
"user:%d=%"PRId64"%cpayaddress:%d=none%c", |
|
|
|
"user:%d=%s.0%cpayaddress:%d=%s%c", |
|
|
|
rows, miningpayouts->userid, FLDSEP, |
|
|
|
rows, users->username, FLDSEP, |
|
|
|
rows, FLDSEP); |
|
|
|
rows, "none", FLDSEP); |
|
|
|
} |
|
|
|
|
|
|
|
APPEND_REALLOC(buf, off, len, tmp); |
|
|
|
APPEND_REALLOC(buf, off, len, tmp); |
|
|
|
|
|
|
|
|
|
|
|
snprintf(tmp, sizeof(tmp), |
|
|
|
snprintf(tmp, sizeof(tmp), |
|
|
|
"diffacc_user:%d=%"PRId64"%c", |
|
|
|
"diffacc_user:%d=%"PRId64"%c", |
|
|
|
rows, |
|
|
|
rows, |
|
|
|
miningpayouts->amount, |
|
|
|
miningpayouts->amount, |
|
|
|
FLDSEP); |
|
|
|
FLDSEP); |
|
|
|
APPEND_REALLOC(buf, off, len, tmp); |
|
|
|
APPEND_REALLOC(buf, off, len, tmp); |
|
|
|
|
|
|
|
|
|
|
|
mu_item = next_in_ktree(ctx); |
|
|
|
|
|
|
|
rows++; |
|
|
|
rows++; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
mu_item = next_in_ktree(ctx); |
|
|
|
|
|
|
|
} |
|
|
|
snprintf(tmp, sizeof(tmp), |
|
|
|
snprintf(tmp, sizeof(tmp), |
|
|
|
"rows=%d%cflds=%s%c", |
|
|
|
"rows=%d%cflds=%s%c", |
|
|
|
rows, FLDSEP, |
|
|
|
rows, FLDSEP, |
|
|
|