Skip to content

Commit

Permalink
fix: fix findBalanceByAddressAndBlock query
Browse files Browse the repository at this point in the history
  • Loading branch information
Juan Cruz committed Nov 24, 2020
1 parent 504e5b5 commit 6691086
Showing 1 changed file with 6 additions and 3 deletions.
Expand Up @@ -170,13 +170,16 @@ const findBalanceByAddressAndBlock = `SELECT (SELECT COALESCE(SUM(r.amount),0)
JOIN stake_address ON
stake_address.id = r.addr_id AND
stake_address.view = $1
WHERE r.epoch_no < (SELECT epoch_no FROM block WHERE hash = $2)) -
JOIN block ON
block.id = r.block_id
WHERE stake_address.view = $1
AND block.epoch_no < (SELECT epoch_no FROM block WHERE hash = $2))-
(SELECT COALESCE(SUM(w.amount),0)
FROM withdrawal w
JOIN tx ON tx.id = w.tx_id AND
tx.block_id <= (SELECT id FROM block WHERE hash = $2)
JOIN stake_address ON stake_address.id = w.addr_id AND
stake_address.view = $1)
JOIN stake_address ON stake_address.id = w.addr_id
WHERE stake_address.view = $1)
AS balance
`;

Expand Down

0 comments on commit 6691086

Please sign in to comment.