Remove get_child function
Was only used in canonical_header_from_array
This commit is contained in:
parent
5b92e02ebd
commit
323ed2da00
@ -29,62 +29,6 @@ $$
|
|||||||
language sql;
|
language sql;
|
||||||
-- +goose StatementEnd
|
-- +goose StatementEnd
|
||||||
|
|
||||||
-- +goose StatementBegin
|
|
||||||
-- duplicate of eth.header_cids as a separate type: if we use the table directly, dropping the hypertables
|
|
||||||
-- on downgrade of step 00018 will fail due to the dependency on this type.
|
|
||||||
CREATE TYPE header_result AS (
|
|
||||||
block_number bigint,
|
|
||||||
block_hash character varying(66),
|
|
||||||
parent_hash character varying(66),
|
|
||||||
cid text,
|
|
||||||
td numeric,
|
|
||||||
node_ids character varying(128)[],
|
|
||||||
reward numeric,
|
|
||||||
state_root character varying(66),
|
|
||||||
tx_root character varying(66),
|
|
||||||
receipt_root character varying(66),
|
|
||||||
uncles_hash character varying(66),
|
|
||||||
bloom bytea,
|
|
||||||
"timestamp" bigint,
|
|
||||||
coinbase character varying(66),
|
|
||||||
canonical bool
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TYPE child_result AS (
|
|
||||||
has_child BOOLEAN,
|
|
||||||
children header_result[]
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE OR REPLACE FUNCTION get_child(hash VARCHAR(66), height BIGINT) RETURNS child_result AS
|
|
||||||
$BODY$
|
|
||||||
DECLARE
|
|
||||||
child_height INT;
|
|
||||||
temp_child header_result;
|
|
||||||
new_child_result child_result;
|
|
||||||
BEGIN
|
|
||||||
child_height = height + 1;
|
|
||||||
-- short circuit if there are no children
|
|
||||||
SELECT exists(SELECT 1
|
|
||||||
FROM eth.header_cids
|
|
||||||
WHERE parent_hash = hash
|
|
||||||
AND block_number = child_height
|
|
||||||
AND canonical = true
|
|
||||||
LIMIT 1)
|
|
||||||
INTO new_child_result.has_child;
|
|
||||||
-- collect all the children for this header
|
|
||||||
IF new_child_result.has_child THEN
|
|
||||||
FOR temp_child IN
|
|
||||||
SELECT * FROM eth.header_cids WHERE parent_hash = hash AND block_number = child_height AND canonical = true
|
|
||||||
LOOP
|
|
||||||
new_child_result.children = array_append(new_child_result.children, temp_child);
|
|
||||||
END LOOP;
|
|
||||||
END IF;
|
|
||||||
RETURN new_child_result;
|
|
||||||
END
|
|
||||||
$BODY$
|
|
||||||
LANGUAGE 'plpgsql';
|
|
||||||
-- +goose StatementEnd
|
|
||||||
|
|
||||||
-- +goose StatementBegin
|
-- +goose StatementBegin
|
||||||
CREATE OR REPLACE FUNCTION canonical_header_hash(height BIGINT) RETURNS character varying AS
|
CREATE OR REPLACE FUNCTION canonical_header_hash(height BIGINT) RETURNS character varying AS
|
||||||
$BODY$
|
$BODY$
|
||||||
@ -97,5 +41,3 @@ LANGUAGE sql;
|
|||||||
DROP FUNCTION was_state_leaf_removed;
|
DROP FUNCTION was_state_leaf_removed;
|
||||||
DROP FUNCTION was_state_leaf_removed_by_number;
|
DROP FUNCTION was_state_leaf_removed_by_number;
|
||||||
DROP FUNCTION canonical_header_hash;
|
DROP FUNCTION canonical_header_hash;
|
||||||
DROP FUNCTION get_child;
|
|
||||||
DROP TYPE child_result;
|
|
||||||
|
67
schema.sql
67
schema.sql
@ -51,39 +51,6 @@ CREATE SCHEMA eth_meta;
|
|||||||
CREATE SCHEMA ipld;
|
CREATE SCHEMA ipld;
|
||||||
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Name: header_result; Type: TYPE; Schema: public; Owner: -
|
|
||||||
--
|
|
||||||
|
|
||||||
CREATE TYPE public.header_result AS (
|
|
||||||
block_number bigint,
|
|
||||||
block_hash character varying(66),
|
|
||||||
parent_hash character varying(66),
|
|
||||||
cid text,
|
|
||||||
td numeric,
|
|
||||||
node_ids character varying(128)[],
|
|
||||||
reward numeric,
|
|
||||||
state_root character varying(66),
|
|
||||||
tx_root character varying(66),
|
|
||||||
receipt_root character varying(66),
|
|
||||||
uncles_hash character varying(66),
|
|
||||||
bloom bytea,
|
|
||||||
"timestamp" bigint,
|
|
||||||
coinbase character varying(66),
|
|
||||||
canonical boolean
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Name: child_result; Type: TYPE; Schema: public; Owner: -
|
|
||||||
--
|
|
||||||
|
|
||||||
CREATE TYPE public.child_result AS (
|
|
||||||
has_child boolean,
|
|
||||||
children public.header_result[]
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Name: canonical_header_hash(bigint); Type: FUNCTION; Schema: public; Owner: -
|
-- Name: canonical_header_hash(bigint); Type: FUNCTION; Schema: public; Owner: -
|
||||||
--
|
--
|
||||||
@ -95,40 +62,6 @@ CREATE FUNCTION public.canonical_header_hash(height bigint) RETURNS character va
|
|||||||
$$;
|
$$;
|
||||||
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Name: get_child(character varying, bigint); Type: FUNCTION; Schema: public; Owner: -
|
|
||||||
--
|
|
||||||
|
|
||||||
CREATE FUNCTION public.get_child(hash character varying, height bigint) RETURNS public.child_result
|
|
||||||
LANGUAGE plpgsql
|
|
||||||
AS $$
|
|
||||||
DECLARE
|
|
||||||
child_height INT;
|
|
||||||
temp_child header_result;
|
|
||||||
new_child_result child_result;
|
|
||||||
BEGIN
|
|
||||||
child_height = height + 1;
|
|
||||||
-- short circuit if there are no children
|
|
||||||
SELECT exists(SELECT 1
|
|
||||||
FROM eth.header_cids
|
|
||||||
WHERE parent_hash = hash
|
|
||||||
AND block_number = child_height
|
|
||||||
AND canonical = true
|
|
||||||
LIMIT 1)
|
|
||||||
INTO new_child_result.has_child;
|
|
||||||
-- collect all the children for this header
|
|
||||||
IF new_child_result.has_child THEN
|
|
||||||
FOR temp_child IN
|
|
||||||
SELECT * FROM eth.header_cids WHERE parent_hash = hash AND block_number = child_height AND canonical = true
|
|
||||||
LOOP
|
|
||||||
new_child_result.children = array_append(new_child_result.children, temp_child);
|
|
||||||
END LOOP;
|
|
||||||
END IF;
|
|
||||||
RETURN new_child_result;
|
|
||||||
END
|
|
||||||
$$;
|
|
||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Name: get_storage_at_by_hash(text, text, text); Type: FUNCTION; Schema: public; Owner: -
|
-- Name: get_storage_at_by_hash(text, text, text); Type: FUNCTION; Schema: public; Owner: -
|
||||||
--
|
--
|
||||||
|
Loading…
Reference in New Issue
Block a user