Skip to content

Commit

Permalink
Update proposal_voting_summary.sql
Browse files Browse the repository at this point in the history
More efficient way of calculating last tx id in epoch
  • Loading branch information
hodlonaut authored Nov 9, 2024
1 parent 10f136f commit c339fac
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions files/grest/rpc/governance/proposal_voting_summary.sql
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,9 @@ BEGIN
INNER JOIN public.stake_address AS sa ON pu.reward_addr_id = sa.id
INNER JOIN delegation_vote AS dv on dv.addr_id = sa.id
AND dv.tx_id = (SELECT max(tx_id) FROM delegation_vote dv2 WHERE dv2.addr_id = sa.id
AND tx_id <= (SELECT COALESCE(max(t.id), (SELECT max(t2.id) FROM tx t2)) FROM tx t INNER JOIN block b ON t.block_id = b.id
AND b.epoch_no = ped.epoch_of_interest))
AND tx_id <=
(SELECT COALESCE(t.id, (SELECT id FROM tx t2 ORDER BY id DESC LIMIT 1)) FROM tx t INNER JOIN block b
ON t.block_id = b.id AND b.epoch_no = ped.epoch_of_interest ORDER BY t.id DESC LIMIT 1))
INNER JOIN drep_hash AS dh on dh.id = dv.drep_hash_id
and dh.view like 'drep_always%'
INNER JOIN pool_stat AS pstat ON api.pool_hash_id = pstat.pool_hash_id
Expand Down

0 comments on commit c339fac

Please sign in to comment.