Fix state leaf key removed query.

This commit is contained in:
Arijit Das 2021-09-09 17:42:26 +05:30
parent 000c0ef066
commit 1467ea3924

View File

@ -18,14 +18,14 @@ $$ LANGUAGE SQL;
-- +goose StatementEnd -- +goose StatementEnd
-- +goose StatementBegin -- +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 CREATE OR REPLACE FUNCTION was_state_removed(path BYTEA, height BIGINT, hash VARCHAR(66)) RETURNS BOOLEAN
AS $$ AS $$
SELECT exists(SELECT 1 SELECT exists(SELECT 1
FROM eth.state_cids FROM eth.state_cids
INNER JOIN eth.header_cids ON (state_cids.header_id = header_cids.id) INNER JOIN eth.header_cids ON (state_cids.header_id = header_cids.id)
WHERE state_path = path WHERE state_path = path
AND block_number > height AND block_number >= height
AND block_number <= (SELECT block_number AND block_number <= (SELECT block_number
FROM eth.header_cids FROM eth.header_cids
WHERE block_hash = hash) WHERE block_hash = hash)