Fix state leaf key removed query #98

Merged
arijitAD merged 3 commits from fix-state-remove into master 2021-09-17 12:02:35 +00:00
Showing only changes of commit 1467ea3924 - Show all commits

View File

@ -18,14 +18,14 @@ $$ LANGUAGE SQL;
-- +goose StatementEnd
-- +goose StatementBegin
-- returns if a state node at the provided path was removed in the range > the provided height and <= the provided block hash
-- returns if a state node at the provided path was removed in the range >= the provided height and <= the provided block hash
CREATE OR REPLACE FUNCTION was_state_removed(path BYTEA, height BIGINT, hash VARCHAR(66)) RETURNS BOOLEAN
AS $$
SELECT exists(SELECT 1
FROM eth.state_cids
INNER JOIN eth.header_cids ON (state_cids.header_id = header_cids.id)
WHERE state_path = path
AND block_number > height
AND block_number >= height
AND block_number <= (SELECT block_number
FROM eth.header_cids
WHERE block_hash = hash)