Skip to content

Commit

Permalink
fix: historical slots query (#618)
Browse files Browse the repository at this point in the history
  • Loading branch information
carneiro-cw authored Apr 17, 2024
1 parent 9f18b6b commit 6f19c0c
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 32 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

This file was deleted.

15 changes: 13 additions & 2 deletions src/eth/storage/postgres_permanent/sql/select_historical_slots.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
SELECT idx as "index: _", value as "value: _"
WITH max_block_number AS (
SELECT idx,
MAX(block_number) as num
FROM historical_slots
WHERE block_number <= $3
AND account_address = $2
AND idx = ANY($1)
GROUP BY idx
)
SELECT historical_slots.idx as "index: _",
value as "value: _"
FROM historical_slots
WHERE idx = ANY($1) AND account_address = $2 AND block_number = $3
JOIN max_block_number ON max_block_number.idx = historical_slots.idx
AND max_block_number.num = historical_slots.block_number

0 comments on commit 6f19c0c

Please sign in to comment.