-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from vulcanize/state_leaf_remove
Add function to check for state node removal.
- Loading branch information
Showing
2 changed files
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
-- +goose Up | ||
-- +goose StatementBegin | ||
-- returns if a state leaf node was removed within the provided block number | ||
CREATE OR REPLACE FUNCTION was_state_leaf_removed(key character varying, hash character varying) | ||
RETURNS boolean AS $$ | ||
SELECT state_cids.node_type = 3 | ||
FROM eth.state_cids | ||
INNER JOIN eth.header_cids ON (state_cids.header_id = header_cids.id) | ||
WHERE state_leaf_key = key | ||
AND block_number <= (SELECT block_number | ||
FROM eth.header_cids | ||
WHERE block_hash = hash) | ||
ORDER BY block_number DESC LIMIT 1; | ||
$$ | ||
language sql; | ||
-- +goose StatementEnd | ||
|
||
|
||
-- +goose Down | ||
DROP FUNCTION was_state_leaf_removed; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters