Skip to content

Commit

Permalink
Formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
sisou committed Apr 20, 2018
1 parent fb6dfa5 commit f46046b
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 28 deletions.
54 changes: 27 additions & 27 deletions Helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,33 +21,33 @@ class Helper {
*/
static async getUserBalance(config, connectionPool, userId, currChainHeight, includeVirtual = false) {
const query = `
SELECT t1.user AS user, IFNULL(payin_sum, 0) - IFNULL(payout_sum, 0) AS balance
FROM (
(
SELECT user, SUM(amount) AS payin_sum
FROM (
(
SELECT user, block, amount
FROM payin
WHERE user=?
) t3
INNER JOIN
(
SELECT id, height
FROM block
WHERE height <= ?
) t4
ON t4.id = t3.block
)
) t1
LEFT JOIN
(
SELECT user, SUM(amount) AS payout_sum
FROM payout
WHERE user=?
) t2
ON t1.user = t2.user
)
SELECT t1.user AS user, IFNULL(payin_sum, 0) - IFNULL(payout_sum, 0) AS balance
FROM (
(
SELECT user, SUM(amount) AS payin_sum
FROM (
(
SELECT user, block, amount
FROM payin
WHERE user=?
) t3
INNER JOIN
(
SELECT id, height
FROM block
WHERE height <= ?
) t4
ON t4.id = t3.block
)
) t1
LEFT JOIN
(
SELECT user, SUM(amount) AS payout_sum
FROM payout
WHERE user=?
) t2
ON t1.user = t2.user
)
`;
const queryHeight = includeVirtual ? currChainHeight : currChainHeight - config.payoutConfirmations;
const queryArgs = [userId, queryHeight, userId];
Expand Down
2 changes: 1 addition & 1 deletion PoolService.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class PoolService extends Nimiq.Observable {
LIMIT ?
) t3
GROUP BY user
`;
`;
const queryArgs = [lastBlock.height, n];
const [rows, fields] = await this.connectionPool.execute(query, queryArgs);

Expand Down

0 comments on commit f46046b

Please sign in to comment.