diff --git a/db/migrations/00033_add_times_validated.sql b/db/migrations/00033_add_times_validated.sql new file mode 100644 index 00000000..2502b195 --- /dev/null +++ b/db/migrations/00033_add_times_validated.sql @@ -0,0 +1,13 @@ +-- +goose Up +ALTER TABLE eth.header_cids +ADD COLUMN times_validated INTEGER NOT NULL DEFAULT 0; + +ALTER TABLE btc.header_cids +ADD COLUMN times_validated INTEGER NOT NULL DEFAULT 0; + +-- +goose Down +ALTER TABLE btc.header_cids +DROP COLUMN times_validated; + +ALTER TABLE eth.header_cids +DROP COLUMN times_validated; \ No newline at end of file diff --git a/db/schema.sql b/db/schema.sql index 4b287ed9..e69de29b 100644 --- a/db/schema.sql +++ b/db/schema.sql @@ -1,1714 +0,0 @@ --- --- PostgreSQL database dump --- - --- Dumped from database version 10.10 --- Dumped by pg_dump version 10.10 - -SET statement_timeout = 0; -SET lock_timeout = 0; -SET idle_in_transaction_session_timeout = 0; -SET client_encoding = 'UTF8'; -SET standard_conforming_strings = on; -SELECT pg_catalog.set_config('search_path', '', false); -SET check_function_bodies = false; -SET xmloption = content; -SET client_min_messages = warning; -SET row_security = off; - --- --- Name: btc; Type: SCHEMA; Schema: -; Owner: - --- - -CREATE SCHEMA btc; - - --- --- Name: eth; Type: SCHEMA; Schema: -; Owner: - --- - -CREATE SCHEMA eth; - - --- --- Name: plpgsql; Type: EXTENSION; Schema: -; Owner: - --- - -CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog; - - --- --- Name: EXTENSION plpgsql; Type: COMMENT; Schema: -; Owner: - --- - -COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language'; - - -SET default_tablespace = ''; - -SET default_with_oids = false; - --- --- Name: header_cids; Type: TABLE; Schema: btc; Owner: - --- - -CREATE TABLE btc.header_cids ( - id integer NOT NULL, - block_number bigint NOT NULL, - block_hash character varying(66) NOT NULL, - parent_hash character varying(66) NOT NULL, - cid text NOT NULL, - "timestamp" numeric NOT NULL, - bits bigint NOT NULL, - node_id integer NOT NULL -); - - --- --- Name: TABLE header_cids; Type: COMMENT; Schema: btc; Owner: - --- - -COMMENT ON TABLE btc.header_cids IS '@name BtcHeaderCids'; - - --- --- Name: COLUMN header_cids.node_id; Type: COMMENT; Schema: btc; Owner: - --- - -COMMENT ON COLUMN btc.header_cids.node_id IS '@name BtcNodeID'; - - --- --- Name: header_cids_id_seq; Type: SEQUENCE; Schema: btc; Owner: - --- - -CREATE SEQUENCE btc.header_cids_id_seq - AS integer - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - --- --- Name: header_cids_id_seq; Type: SEQUENCE OWNED BY; Schema: btc; Owner: - --- - -ALTER SEQUENCE btc.header_cids_id_seq OWNED BY btc.header_cids.id; - - --- --- Name: queue_data; Type: TABLE; Schema: btc; Owner: - --- - -CREATE TABLE btc.queue_data ( - id integer NOT NULL, - data bytea NOT NULL, - height bigint NOT NULL -); - - --- --- Name: TABLE queue_data; Type: COMMENT; Schema: btc; Owner: - --- - -COMMENT ON TABLE btc.queue_data IS '@name BtcQueueData'; - - --- --- Name: queue_data_id_seq; Type: SEQUENCE; Schema: btc; Owner: - --- - -CREATE SEQUENCE btc.queue_data_id_seq - AS integer - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - --- --- Name: queue_data_id_seq; Type: SEQUENCE OWNED BY; Schema: btc; Owner: - --- - -ALTER SEQUENCE btc.queue_data_id_seq OWNED BY btc.queue_data.id; - - --- --- Name: transaction_cids; Type: TABLE; Schema: btc; Owner: - --- - -CREATE TABLE btc.transaction_cids ( - id integer NOT NULL, - header_id integer NOT NULL, - index integer NOT NULL, - tx_hash character varying(66) NOT NULL, - cid text NOT NULL, - segwit boolean NOT NULL, - witness_hash character varying(66) -); - - --- --- Name: TABLE transaction_cids; Type: COMMENT; Schema: btc; Owner: - --- - -COMMENT ON TABLE btc.transaction_cids IS '@name BtcTransactionCids'; - - --- --- Name: transaction_cids_id_seq; Type: SEQUENCE; Schema: btc; Owner: - --- - -CREATE SEQUENCE btc.transaction_cids_id_seq - AS integer - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - --- --- Name: transaction_cids_id_seq; Type: SEQUENCE OWNED BY; Schema: btc; Owner: - --- - -ALTER SEQUENCE btc.transaction_cids_id_seq OWNED BY btc.transaction_cids.id; - - --- --- Name: tx_inputs; Type: TABLE; Schema: btc; Owner: - --- - -CREATE TABLE btc.tx_inputs ( - id integer NOT NULL, - tx_id integer NOT NULL, - index integer NOT NULL, - witness character varying[], - sig_script bytea NOT NULL, - outpoint_tx_hash character varying(66) NOT NULL, - outpoint_index numeric NOT NULL -); - - --- --- Name: tx_inputs_id_seq; Type: SEQUENCE; Schema: btc; Owner: - --- - -CREATE SEQUENCE btc.tx_inputs_id_seq - AS integer - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - --- --- Name: tx_inputs_id_seq; Type: SEQUENCE OWNED BY; Schema: btc; Owner: - --- - -ALTER SEQUENCE btc.tx_inputs_id_seq OWNED BY btc.tx_inputs.id; - - --- --- Name: tx_outputs; Type: TABLE; Schema: btc; Owner: - --- - -CREATE TABLE btc.tx_outputs ( - id integer NOT NULL, - tx_id integer NOT NULL, - index integer NOT NULL, - value bigint NOT NULL, - pk_script bytea NOT NULL, - script_class integer NOT NULL, - addresses character varying(66)[], - required_sigs integer NOT NULL -); - - --- --- Name: tx_outputs_id_seq; Type: SEQUENCE; Schema: btc; Owner: - --- - -CREATE SEQUENCE btc.tx_outputs_id_seq - AS integer - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - --- --- Name: tx_outputs_id_seq; Type: SEQUENCE OWNED BY; Schema: btc; Owner: - --- - -ALTER SEQUENCE btc.tx_outputs_id_seq OWNED BY btc.tx_outputs.id; - - --- --- Name: header_cids; Type: TABLE; Schema: eth; Owner: - --- - -CREATE TABLE eth.header_cids ( - id integer NOT NULL, - block_number bigint NOT NULL, - block_hash character varying(66) NOT NULL, - parent_hash character varying(66) NOT NULL, - cid text NOT NULL, - td numeric NOT NULL, - node_id integer NOT NULL, - reward numeric NOT NULL, - state_root character varying(66), - tx_root character varying(66), - receipt_root character varying(66), - uncle_root character varying(66), - bloom bytea, - "timestamp" numeric -); - - --- --- Name: TABLE header_cids; Type: COMMENT; Schema: eth; Owner: - --- - -COMMENT ON TABLE eth.header_cids IS '@name EthHeaderCids'; - - --- --- Name: COLUMN header_cids.node_id; Type: COMMENT; Schema: eth; Owner: - --- - -COMMENT ON COLUMN eth.header_cids.node_id IS '@name EthNodeID'; - - --- --- Name: header_cids_id_seq; Type: SEQUENCE; Schema: eth; Owner: - --- - -CREATE SEQUENCE eth.header_cids_id_seq - AS integer - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - --- --- Name: header_cids_id_seq; Type: SEQUENCE OWNED BY; Schema: eth; Owner: - --- - -ALTER SEQUENCE eth.header_cids_id_seq OWNED BY eth.header_cids.id; - - --- --- Name: queue_data; Type: TABLE; Schema: eth; Owner: - --- - -CREATE TABLE eth.queue_data ( - id integer NOT NULL, - data bytea NOT NULL, - height bigint NOT NULL -); - - --- --- Name: TABLE queue_data; Type: COMMENT; Schema: eth; Owner: - --- - -COMMENT ON TABLE eth.queue_data IS '@name EthQueueData'; - - --- --- Name: queue_data_id_seq; Type: SEQUENCE; Schema: eth; Owner: - --- - -CREATE SEQUENCE eth.queue_data_id_seq - AS integer - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - --- --- Name: queue_data_id_seq; Type: SEQUENCE OWNED BY; Schema: eth; Owner: - --- - -ALTER SEQUENCE eth.queue_data_id_seq OWNED BY eth.queue_data.id; - - --- --- Name: receipt_cids; Type: TABLE; Schema: eth; Owner: - --- - -CREATE TABLE eth.receipt_cids ( - id integer NOT NULL, - tx_id integer NOT NULL, - cid text NOT NULL, - contract character varying(66), - topic0s character varying(66)[], - topic1s character varying(66)[], - topic2s character varying(66)[], - topic3s character varying(66)[] -); - - --- --- Name: receipt_cids_id_seq; Type: SEQUENCE; Schema: eth; Owner: - --- - -CREATE SEQUENCE eth.receipt_cids_id_seq - AS integer - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - --- --- Name: receipt_cids_id_seq; Type: SEQUENCE OWNED BY; Schema: eth; Owner: - --- - -ALTER SEQUENCE eth.receipt_cids_id_seq OWNED BY eth.receipt_cids.id; - - --- --- Name: state_accounts; Type: TABLE; Schema: eth; Owner: - --- - -CREATE TABLE eth.state_accounts ( - id integer NOT NULL, - state_id integer NOT NULL, - balance numeric NOT NULL, - nonce integer NOT NULL, - code_hash bytea NOT NULL, - storage_root character varying(66) NOT NULL -); - - --- --- Name: state_accounts_id_seq; Type: SEQUENCE; Schema: eth; Owner: - --- - -CREATE SEQUENCE eth.state_accounts_id_seq - AS integer - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - --- --- Name: state_accounts_id_seq; Type: SEQUENCE OWNED BY; Schema: eth; Owner: - --- - -ALTER SEQUENCE eth.state_accounts_id_seq OWNED BY eth.state_accounts.id; - - --- --- Name: state_cids; Type: TABLE; Schema: eth; Owner: - --- - -CREATE TABLE eth.state_cids ( - id integer NOT NULL, - header_id integer NOT NULL, - state_leaf_key character varying(66), - cid text NOT NULL, - state_path bytea, - node_type integer -); - - --- --- Name: state_cids_id_seq; Type: SEQUENCE; Schema: eth; Owner: - --- - -CREATE SEQUENCE eth.state_cids_id_seq - AS integer - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - --- --- Name: state_cids_id_seq; Type: SEQUENCE OWNED BY; Schema: eth; Owner: - --- - -ALTER SEQUENCE eth.state_cids_id_seq OWNED BY eth.state_cids.id; - - --- --- Name: storage_cids; Type: TABLE; Schema: eth; Owner: - --- - -CREATE TABLE eth.storage_cids ( - id integer NOT NULL, - state_id integer NOT NULL, - storage_leaf_key character varying(66), - cid text NOT NULL, - storage_path bytea, - node_type integer -); - - --- --- Name: storage_cids_id_seq; Type: SEQUENCE; Schema: eth; Owner: - --- - -CREATE SEQUENCE eth.storage_cids_id_seq - AS integer - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - --- --- Name: storage_cids_id_seq; Type: SEQUENCE OWNED BY; Schema: eth; Owner: - --- - -ALTER SEQUENCE eth.storage_cids_id_seq OWNED BY eth.storage_cids.id; - - --- --- Name: transaction_cids; Type: TABLE; Schema: eth; Owner: - --- - -CREATE TABLE eth.transaction_cids ( - id integer NOT NULL, - header_id integer NOT NULL, - tx_hash character varying(66) NOT NULL, - index integer NOT NULL, - cid text NOT NULL, - dst character varying(66) NOT NULL, - src character varying(66) NOT NULL -); - - --- --- Name: TABLE transaction_cids; Type: COMMENT; Schema: eth; Owner: - --- - -COMMENT ON TABLE eth.transaction_cids IS '@name EthTransactionCids'; - - --- --- Name: transaction_cids_id_seq; Type: SEQUENCE; Schema: eth; Owner: - --- - -CREATE SEQUENCE eth.transaction_cids_id_seq - AS integer - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - --- --- Name: transaction_cids_id_seq; Type: SEQUENCE OWNED BY; Schema: eth; Owner: - --- - -ALTER SEQUENCE eth.transaction_cids_id_seq OWNED BY eth.transaction_cids.id; - - --- --- Name: uncle_cids; Type: TABLE; Schema: eth; Owner: - --- - -CREATE TABLE eth.uncle_cids ( - id integer NOT NULL, - header_id integer NOT NULL, - block_hash character varying(66) NOT NULL, - parent_hash character varying(66) NOT NULL, - cid text NOT NULL, - reward numeric NOT NULL -); - - --- --- Name: uncle_cids_id_seq; Type: SEQUENCE; Schema: eth; Owner: - --- - -CREATE SEQUENCE eth.uncle_cids_id_seq - AS integer - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - --- --- Name: uncle_cids_id_seq; Type: SEQUENCE OWNED BY; Schema: eth; Owner: - --- - -ALTER SEQUENCE eth.uncle_cids_id_seq OWNED BY eth.uncle_cids.id; - - --- --- Name: addresses; Type: TABLE; Schema: public; Owner: - --- - -CREATE TABLE public.addresses ( - id integer NOT NULL, - address character varying(42), - hashed_address character varying(66) -); - - --- --- Name: addresses_id_seq; Type: SEQUENCE; Schema: public; Owner: - --- - -CREATE SEQUENCE public.addresses_id_seq - AS integer - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - --- --- Name: addresses_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - --- - -ALTER SEQUENCE public.addresses_id_seq OWNED BY public.addresses.id; - - --- --- Name: blocks; Type: TABLE; Schema: public; Owner: - --- - -CREATE TABLE public.blocks ( - key text NOT NULL, - data bytea NOT NULL -); - - --- --- Name: checked_headers; Type: TABLE; Schema: public; Owner: - --- - -CREATE TABLE public.checked_headers ( - id integer NOT NULL, - header_id integer NOT NULL -); - - --- --- Name: checked_headers_id_seq; Type: SEQUENCE; Schema: public; Owner: - --- - -CREATE SEQUENCE public.checked_headers_id_seq - AS integer - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - --- --- Name: checked_headers_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - --- - -ALTER SEQUENCE public.checked_headers_id_seq OWNED BY public.checked_headers.id; - - --- --- Name: goose_db_version; Type: TABLE; Schema: public; Owner: - --- - -CREATE TABLE public.goose_db_version ( - id integer NOT NULL, - version_id bigint NOT NULL, - is_applied boolean NOT NULL, - tstamp timestamp without time zone DEFAULT now() -); - - --- --- Name: goose_db_version_id_seq; Type: SEQUENCE; Schema: public; Owner: - --- - -CREATE SEQUENCE public.goose_db_version_id_seq - AS integer - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - --- --- Name: goose_db_version_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - --- - -ALTER SEQUENCE public.goose_db_version_id_seq OWNED BY public.goose_db_version.id; - - --- --- Name: header_sync_logs; Type: TABLE; Schema: public; Owner: - --- - -CREATE TABLE public.header_sync_logs ( - id integer NOT NULL, - header_id integer NOT NULL, - address integer NOT NULL, - topics bytea[], - data bytea, - block_number bigint, - block_hash character varying(66), - tx_hash character varying(66), - tx_index integer, - log_index integer, - raw jsonb, - transformed boolean DEFAULT false NOT NULL -); - - --- --- Name: header_sync_logs_id_seq; Type: SEQUENCE; Schema: public; Owner: - --- - -CREATE SEQUENCE public.header_sync_logs_id_seq - AS integer - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - --- --- Name: header_sync_logs_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - --- - -ALTER SEQUENCE public.header_sync_logs_id_seq OWNED BY public.header_sync_logs.id; - - --- --- Name: header_sync_receipts; Type: TABLE; Schema: public; Owner: - --- - -CREATE TABLE public.header_sync_receipts ( - id integer NOT NULL, - transaction_id integer NOT NULL, - header_id integer NOT NULL, - contract_address_id integer NOT NULL, - cumulative_gas_used numeric, - gas_used numeric, - state_root character varying(66), - status integer, - tx_hash character varying(66), - rlp bytea -); - - --- --- Name: header_sync_receipts_id_seq; Type: SEQUENCE; Schema: public; Owner: - --- - -CREATE SEQUENCE public.header_sync_receipts_id_seq - AS integer - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - --- --- Name: header_sync_receipts_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - --- - -ALTER SEQUENCE public.header_sync_receipts_id_seq OWNED BY public.header_sync_receipts.id; - - --- --- Name: header_sync_transactions; Type: TABLE; Schema: public; Owner: - --- - -CREATE TABLE public.header_sync_transactions ( - id integer NOT NULL, - header_id integer NOT NULL, - hash character varying(66), - gas_limit numeric, - gas_price numeric, - input_data bytea, - nonce numeric, - raw bytea, - tx_from character varying(44), - tx_index integer, - tx_to character varying(44), - value numeric -); - - --- --- Name: header_sync_transactions_id_seq; Type: SEQUENCE; Schema: public; Owner: - --- - -CREATE SEQUENCE public.header_sync_transactions_id_seq - AS integer - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - --- --- Name: header_sync_transactions_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - --- - -ALTER SEQUENCE public.header_sync_transactions_id_seq OWNED BY public.header_sync_transactions.id; - - --- --- Name: headers; Type: TABLE; Schema: public; Owner: - --- - -CREATE TABLE public.headers ( - id integer NOT NULL, - hash character varying(66), - block_number bigint, - raw jsonb, - block_timestamp numeric, - check_count integer DEFAULT 0 NOT NULL, - node_id integer NOT NULL, - eth_node_fingerprint character varying(128) -); - - --- --- Name: TABLE headers; Type: COMMENT; Schema: public; Owner: - --- - -COMMENT ON TABLE public.headers IS '@name EthHeaders'; - - --- --- Name: COLUMN headers.node_id; Type: COMMENT; Schema: public; Owner: - --- - -COMMENT ON COLUMN public.headers.node_id IS '@name EthNodeID'; - - --- --- Name: headers_id_seq; Type: SEQUENCE; Schema: public; Owner: - --- - -CREATE SEQUENCE public.headers_id_seq - AS integer - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - --- --- Name: headers_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - --- - -ALTER SEQUENCE public.headers_id_seq OWNED BY public.headers.id; - - --- --- Name: nodes; Type: TABLE; Schema: public; Owner: - --- - -CREATE TABLE public.nodes ( - id integer NOT NULL, - client_name character varying, - genesis_block character varying(66), - network_id character varying, - node_id character varying(128) -); - - --- --- Name: TABLE nodes; Type: COMMENT; Schema: public; Owner: - --- - -COMMENT ON TABLE public.nodes IS '@name NodeInfo'; - - --- --- Name: COLUMN nodes.node_id; Type: COMMENT; Schema: public; Owner: - --- - -COMMENT ON COLUMN public.nodes.node_id IS '@name ChainNodeID'; - - --- --- Name: nodes_id_seq; Type: SEQUENCE; Schema: public; Owner: - --- - -CREATE SEQUENCE public.nodes_id_seq - AS integer - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - --- --- Name: nodes_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - --- - -ALTER SEQUENCE public.nodes_id_seq OWNED BY public.nodes.id; - - --- --- Name: queued_storage; Type: TABLE; Schema: public; Owner: - --- - -CREATE TABLE public.queued_storage ( - id integer NOT NULL, - diff_id bigint NOT NULL -); - - --- --- Name: queued_storage_id_seq; Type: SEQUENCE; Schema: public; Owner: - --- - -CREATE SEQUENCE public.queued_storage_id_seq - AS integer - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - --- --- Name: queued_storage_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - --- - -ALTER SEQUENCE public.queued_storage_id_seq OWNED BY public.queued_storage.id; - - --- --- Name: storage_diff; Type: TABLE; Schema: public; Owner: - --- - -CREATE TABLE public.storage_diff ( - id integer NOT NULL, - block_height bigint, - block_hash bytea, - hashed_address bytea, - storage_key bytea, - storage_value bytea -); - - --- --- Name: storage_diff_id_seq; Type: SEQUENCE; Schema: public; Owner: - --- - -CREATE SEQUENCE public.storage_diff_id_seq - AS integer - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - --- --- Name: storage_diff_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - --- - -ALTER SEQUENCE public.storage_diff_id_seq OWNED BY public.storage_diff.id; - - --- --- Name: watched_logs; Type: TABLE; Schema: public; Owner: - --- - -CREATE TABLE public.watched_logs ( - id integer NOT NULL, - contract_address character varying(42), - topic_zero character varying(66) -); - - --- --- Name: watched_logs_id_seq; Type: SEQUENCE; Schema: public; Owner: - --- - -CREATE SEQUENCE public.watched_logs_id_seq - AS integer - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - --- --- Name: watched_logs_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - --- - -ALTER SEQUENCE public.watched_logs_id_seq OWNED BY public.watched_logs.id; - - --- --- Name: header_cids id; Type: DEFAULT; Schema: btc; Owner: - --- - -ALTER TABLE ONLY btc.header_cids ALTER COLUMN id SET DEFAULT nextval('btc.header_cids_id_seq'::regclass); - - --- --- Name: queue_data id; Type: DEFAULT; Schema: btc; Owner: - --- - -ALTER TABLE ONLY btc.queue_data ALTER COLUMN id SET DEFAULT nextval('btc.queue_data_id_seq'::regclass); - - --- --- Name: transaction_cids id; Type: DEFAULT; Schema: btc; Owner: - --- - -ALTER TABLE ONLY btc.transaction_cids ALTER COLUMN id SET DEFAULT nextval('btc.transaction_cids_id_seq'::regclass); - - --- --- Name: tx_inputs id; Type: DEFAULT; Schema: btc; Owner: - --- - -ALTER TABLE ONLY btc.tx_inputs ALTER COLUMN id SET DEFAULT nextval('btc.tx_inputs_id_seq'::regclass); - - --- --- Name: tx_outputs id; Type: DEFAULT; Schema: btc; Owner: - --- - -ALTER TABLE ONLY btc.tx_outputs ALTER COLUMN id SET DEFAULT nextval('btc.tx_outputs_id_seq'::regclass); - - --- --- Name: header_cids id; Type: DEFAULT; Schema: eth; Owner: - --- - -ALTER TABLE ONLY eth.header_cids ALTER COLUMN id SET DEFAULT nextval('eth.header_cids_id_seq'::regclass); - - --- --- Name: queue_data id; Type: DEFAULT; Schema: eth; Owner: - --- - -ALTER TABLE ONLY eth.queue_data ALTER COLUMN id SET DEFAULT nextval('eth.queue_data_id_seq'::regclass); - - --- --- Name: receipt_cids id; Type: DEFAULT; Schema: eth; Owner: - --- - -ALTER TABLE ONLY eth.receipt_cids ALTER COLUMN id SET DEFAULT nextval('eth.receipt_cids_id_seq'::regclass); - - --- --- Name: state_accounts id; Type: DEFAULT; Schema: eth; Owner: - --- - -ALTER TABLE ONLY eth.state_accounts ALTER COLUMN id SET DEFAULT nextval('eth.state_accounts_id_seq'::regclass); - - --- --- Name: state_cids id; Type: DEFAULT; Schema: eth; Owner: - --- - -ALTER TABLE ONLY eth.state_cids ALTER COLUMN id SET DEFAULT nextval('eth.state_cids_id_seq'::regclass); - - --- --- Name: storage_cids id; Type: DEFAULT; Schema: eth; Owner: - --- - -ALTER TABLE ONLY eth.storage_cids ALTER COLUMN id SET DEFAULT nextval('eth.storage_cids_id_seq'::regclass); - - --- --- Name: transaction_cids id; Type: DEFAULT; Schema: eth; Owner: - --- - -ALTER TABLE ONLY eth.transaction_cids ALTER COLUMN id SET DEFAULT nextval('eth.transaction_cids_id_seq'::regclass); - - --- --- Name: uncle_cids id; Type: DEFAULT; Schema: eth; Owner: - --- - -ALTER TABLE ONLY eth.uncle_cids ALTER COLUMN id SET DEFAULT nextval('eth.uncle_cids_id_seq'::regclass); - - --- --- Name: addresses id; Type: DEFAULT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.addresses ALTER COLUMN id SET DEFAULT nextval('public.addresses_id_seq'::regclass); - - --- --- Name: checked_headers id; Type: DEFAULT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.checked_headers ALTER COLUMN id SET DEFAULT nextval('public.checked_headers_id_seq'::regclass); - - --- --- Name: goose_db_version id; Type: DEFAULT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.goose_db_version ALTER COLUMN id SET DEFAULT nextval('public.goose_db_version_id_seq'::regclass); - - --- --- Name: header_sync_logs id; Type: DEFAULT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.header_sync_logs ALTER COLUMN id SET DEFAULT nextval('public.header_sync_logs_id_seq'::regclass); - - --- --- Name: header_sync_receipts id; Type: DEFAULT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.header_sync_receipts ALTER COLUMN id SET DEFAULT nextval('public.header_sync_receipts_id_seq'::regclass); - - --- --- Name: header_sync_transactions id; Type: DEFAULT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.header_sync_transactions ALTER COLUMN id SET DEFAULT nextval('public.header_sync_transactions_id_seq'::regclass); - - --- --- Name: headers id; Type: DEFAULT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.headers ALTER COLUMN id SET DEFAULT nextval('public.headers_id_seq'::regclass); - - --- --- Name: nodes id; Type: DEFAULT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.nodes ALTER COLUMN id SET DEFAULT nextval('public.nodes_id_seq'::regclass); - - --- --- Name: queued_storage id; Type: DEFAULT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.queued_storage ALTER COLUMN id SET DEFAULT nextval('public.queued_storage_id_seq'::regclass); - - --- --- Name: storage_diff id; Type: DEFAULT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.storage_diff ALTER COLUMN id SET DEFAULT nextval('public.storage_diff_id_seq'::regclass); - - --- --- Name: watched_logs id; Type: DEFAULT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.watched_logs ALTER COLUMN id SET DEFAULT nextval('public.watched_logs_id_seq'::regclass); - - --- --- Name: header_cids header_cids_block_number_block_hash_key; Type: CONSTRAINT; Schema: btc; Owner: - --- - -ALTER TABLE ONLY btc.header_cids - ADD CONSTRAINT header_cids_block_number_block_hash_key UNIQUE (block_number, block_hash); - - --- --- Name: header_cids header_cids_pkey; Type: CONSTRAINT; Schema: btc; Owner: - --- - -ALTER TABLE ONLY btc.header_cids - ADD CONSTRAINT header_cids_pkey PRIMARY KEY (id); - - --- --- Name: queue_data queue_data_height_key; Type: CONSTRAINT; Schema: btc; Owner: - --- - -ALTER TABLE ONLY btc.queue_data - ADD CONSTRAINT queue_data_height_key UNIQUE (height); - - --- --- Name: queue_data queue_data_pkey; Type: CONSTRAINT; Schema: btc; Owner: - --- - -ALTER TABLE ONLY btc.queue_data - ADD CONSTRAINT queue_data_pkey PRIMARY KEY (id); - - --- --- Name: transaction_cids transaction_cids_pkey; Type: CONSTRAINT; Schema: btc; Owner: - --- - -ALTER TABLE ONLY btc.transaction_cids - ADD CONSTRAINT transaction_cids_pkey PRIMARY KEY (id); - - --- --- Name: transaction_cids transaction_cids_tx_hash_key; Type: CONSTRAINT; Schema: btc; Owner: - --- - -ALTER TABLE ONLY btc.transaction_cids - ADD CONSTRAINT transaction_cids_tx_hash_key UNIQUE (tx_hash); - - --- --- Name: tx_inputs tx_inputs_pkey; Type: CONSTRAINT; Schema: btc; Owner: - --- - -ALTER TABLE ONLY btc.tx_inputs - ADD CONSTRAINT tx_inputs_pkey PRIMARY KEY (id); - - --- --- Name: tx_inputs tx_inputs_tx_id_index_key; Type: CONSTRAINT; Schema: btc; Owner: - --- - -ALTER TABLE ONLY btc.tx_inputs - ADD CONSTRAINT tx_inputs_tx_id_index_key UNIQUE (tx_id, index); - - --- --- Name: tx_outputs tx_outputs_pkey; Type: CONSTRAINT; Schema: btc; Owner: - --- - -ALTER TABLE ONLY btc.tx_outputs - ADD CONSTRAINT tx_outputs_pkey PRIMARY KEY (id); - - --- --- Name: tx_outputs tx_outputs_tx_id_index_key; Type: CONSTRAINT; Schema: btc; Owner: - --- - -ALTER TABLE ONLY btc.tx_outputs - ADD CONSTRAINT tx_outputs_tx_id_index_key UNIQUE (tx_id, index); - - --- --- Name: header_cids header_cids_block_number_block_hash_key; Type: CONSTRAINT; Schema: eth; Owner: - --- - -ALTER TABLE ONLY eth.header_cids - ADD CONSTRAINT header_cids_block_number_block_hash_key UNIQUE (block_number, block_hash); - - --- --- Name: header_cids header_cids_pkey; Type: CONSTRAINT; Schema: eth; Owner: - --- - -ALTER TABLE ONLY eth.header_cids - ADD CONSTRAINT header_cids_pkey PRIMARY KEY (id); - - --- --- Name: queue_data queue_data_height_key; Type: CONSTRAINT; Schema: eth; Owner: - --- - -ALTER TABLE ONLY eth.queue_data - ADD CONSTRAINT queue_data_height_key UNIQUE (height); - - --- --- Name: queue_data queue_data_pkey; Type: CONSTRAINT; Schema: eth; Owner: - --- - -ALTER TABLE ONLY eth.queue_data - ADD CONSTRAINT queue_data_pkey PRIMARY KEY (id); - - --- --- Name: receipt_cids receipt_cids_pkey; Type: CONSTRAINT; Schema: eth; Owner: - --- - -ALTER TABLE ONLY eth.receipt_cids - ADD CONSTRAINT receipt_cids_pkey PRIMARY KEY (id); - - --- --- Name: state_accounts state_accounts_pkey; Type: CONSTRAINT; Schema: eth; Owner: - --- - -ALTER TABLE ONLY eth.state_accounts - ADD CONSTRAINT state_accounts_pkey PRIMARY KEY (id); - - --- --- Name: state_accounts state_accounts_state_id_key; Type: CONSTRAINT; Schema: eth; Owner: - --- - -ALTER TABLE ONLY eth.state_accounts - ADD CONSTRAINT state_accounts_state_id_key UNIQUE (state_id); - - --- --- Name: state_cids state_cids_header_id_state_path_key; Type: CONSTRAINT; Schema: eth; Owner: - --- - -ALTER TABLE ONLY eth.state_cids - ADD CONSTRAINT state_cids_header_id_state_path_key UNIQUE (header_id, state_path); - - --- --- Name: state_cids state_cids_pkey; Type: CONSTRAINT; Schema: eth; Owner: - --- - -ALTER TABLE ONLY eth.state_cids - ADD CONSTRAINT state_cids_pkey PRIMARY KEY (id); - - --- --- Name: storage_cids storage_cids_pkey; Type: CONSTRAINT; Schema: eth; Owner: - --- - -ALTER TABLE ONLY eth.storage_cids - ADD CONSTRAINT storage_cids_pkey PRIMARY KEY (id); - - --- --- Name: storage_cids storage_cids_state_id_storage_path_key; Type: CONSTRAINT; Schema: eth; Owner: - --- - -ALTER TABLE ONLY eth.storage_cids - ADD CONSTRAINT storage_cids_state_id_storage_path_key UNIQUE (state_id, storage_path); - - --- --- Name: transaction_cids transaction_cids_header_id_tx_hash_key; Type: CONSTRAINT; Schema: eth; Owner: - --- - -ALTER TABLE ONLY eth.transaction_cids - ADD CONSTRAINT transaction_cids_header_id_tx_hash_key UNIQUE (header_id, tx_hash); - - --- --- Name: transaction_cids transaction_cids_pkey; Type: CONSTRAINT; Schema: eth; Owner: - --- - -ALTER TABLE ONLY eth.transaction_cids - ADD CONSTRAINT transaction_cids_pkey PRIMARY KEY (id); - - --- --- Name: uncle_cids uncle_cids_header_id_block_hash_key; Type: CONSTRAINT; Schema: eth; Owner: - --- - -ALTER TABLE ONLY eth.uncle_cids - ADD CONSTRAINT uncle_cids_header_id_block_hash_key UNIQUE (header_id, block_hash); - - --- --- Name: uncle_cids uncle_cids_pkey; Type: CONSTRAINT; Schema: eth; Owner: - --- - -ALTER TABLE ONLY eth.uncle_cids - ADD CONSTRAINT uncle_cids_pkey PRIMARY KEY (id); - - --- --- Name: addresses addresses_address_key; Type: CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.addresses - ADD CONSTRAINT addresses_address_key UNIQUE (address); - - --- --- Name: addresses addresses_pkey; Type: CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.addresses - ADD CONSTRAINT addresses_pkey PRIMARY KEY (id); - - --- --- Name: blocks blocks_key_key; Type: CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.blocks - ADD CONSTRAINT blocks_key_key UNIQUE (key); - - --- --- Name: checked_headers checked_headers_header_id_key; Type: CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.checked_headers - ADD CONSTRAINT checked_headers_header_id_key UNIQUE (header_id); - - --- --- Name: checked_headers checked_headers_pkey; Type: CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.checked_headers - ADD CONSTRAINT checked_headers_pkey PRIMARY KEY (id); - - --- --- Name: goose_db_version goose_db_version_pkey; Type: CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.goose_db_version - ADD CONSTRAINT goose_db_version_pkey PRIMARY KEY (id); - - --- --- Name: header_sync_logs header_sync_logs_header_id_tx_index_log_index_key; Type: CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.header_sync_logs - ADD CONSTRAINT header_sync_logs_header_id_tx_index_log_index_key UNIQUE (header_id, tx_index, log_index); - - --- --- Name: header_sync_logs header_sync_logs_pkey; Type: CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.header_sync_logs - ADD CONSTRAINT header_sync_logs_pkey PRIMARY KEY (id); - - --- --- Name: header_sync_receipts header_sync_receipts_header_id_transaction_id_key; Type: CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.header_sync_receipts - ADD CONSTRAINT header_sync_receipts_header_id_transaction_id_key UNIQUE (header_id, transaction_id); - - --- --- Name: header_sync_receipts header_sync_receipts_pkey; Type: CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.header_sync_receipts - ADD CONSTRAINT header_sync_receipts_pkey PRIMARY KEY (id); - - --- --- Name: header_sync_transactions header_sync_transactions_header_id_hash_key; Type: CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.header_sync_transactions - ADD CONSTRAINT header_sync_transactions_header_id_hash_key UNIQUE (header_id, hash); - - --- --- Name: header_sync_transactions header_sync_transactions_pkey; Type: CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.header_sync_transactions - ADD CONSTRAINT header_sync_transactions_pkey PRIMARY KEY (id); - - --- --- Name: headers headers_block_number_hash_eth_node_fingerprint_key; Type: CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.headers - ADD CONSTRAINT headers_block_number_hash_eth_node_fingerprint_key UNIQUE (block_number, hash, eth_node_fingerprint); - - --- --- Name: headers headers_pkey; Type: CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.headers - ADD CONSTRAINT headers_pkey PRIMARY KEY (id); - - --- --- Name: nodes node_uc; Type: CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.nodes - ADD CONSTRAINT node_uc UNIQUE (genesis_block, network_id, node_id); - - --- --- Name: nodes nodes_pkey; Type: CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.nodes - ADD CONSTRAINT nodes_pkey PRIMARY KEY (id); - - --- --- Name: queued_storage queued_storage_diff_id_key; Type: CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.queued_storage - ADD CONSTRAINT queued_storage_diff_id_key UNIQUE (diff_id); - - --- --- Name: queued_storage queued_storage_pkey; Type: CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.queued_storage - ADD CONSTRAINT queued_storage_pkey PRIMARY KEY (id); - - --- --- Name: storage_diff storage_diff_block_height_block_hash_hashed_address_storage_key; Type: CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.storage_diff - ADD CONSTRAINT storage_diff_block_height_block_hash_hashed_address_storage_key UNIQUE (block_height, block_hash, hashed_address, storage_key, storage_value); - - --- --- Name: storage_diff storage_diff_pkey; Type: CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.storage_diff - ADD CONSTRAINT storage_diff_pkey PRIMARY KEY (id); - - --- --- Name: watched_logs watched_logs_pkey; Type: CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.watched_logs - ADD CONSTRAINT watched_logs_pkey PRIMARY KEY (id); - - --- --- Name: header_sync_receipts_header; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX header_sync_receipts_header ON public.header_sync_receipts USING btree (header_id); - - --- --- Name: header_sync_receipts_transaction; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX header_sync_receipts_transaction ON public.header_sync_receipts USING btree (transaction_id); - - --- --- Name: header_sync_transactions_header; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX header_sync_transactions_header ON public.header_sync_transactions USING btree (header_id); - - --- --- Name: header_sync_transactions_tx_index; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX header_sync_transactions_tx_index ON public.header_sync_transactions USING btree (tx_index); - - --- --- Name: headers_block_number; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX headers_block_number ON public.headers USING btree (block_number); - - --- --- Name: headers_block_timestamp; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX headers_block_timestamp ON public.headers USING btree (block_timestamp); - - --- --- Name: header_cids header_cids_node_id_fkey; Type: FK CONSTRAINT; Schema: btc; Owner: - --- - -ALTER TABLE ONLY btc.header_cids - ADD CONSTRAINT header_cids_node_id_fkey FOREIGN KEY (node_id) REFERENCES public.nodes(id) ON DELETE CASCADE; - - --- --- Name: transaction_cids transaction_cids_header_id_fkey; Type: FK CONSTRAINT; Schema: btc; Owner: - --- - -ALTER TABLE ONLY btc.transaction_cids - ADD CONSTRAINT transaction_cids_header_id_fkey FOREIGN KEY (header_id) REFERENCES btc.header_cids(id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED; - - --- --- Name: tx_inputs tx_inputs_tx_id_fkey; Type: FK CONSTRAINT; Schema: btc; Owner: - --- - -ALTER TABLE ONLY btc.tx_inputs - ADD CONSTRAINT tx_inputs_tx_id_fkey FOREIGN KEY (tx_id) REFERENCES btc.transaction_cids(id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED; - - --- --- Name: tx_outputs tx_outputs_tx_id_fkey; Type: FK CONSTRAINT; Schema: btc; Owner: - --- - -ALTER TABLE ONLY btc.tx_outputs - ADD CONSTRAINT tx_outputs_tx_id_fkey FOREIGN KEY (tx_id) REFERENCES btc.transaction_cids(id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED; - - --- --- Name: header_cids header_cids_node_id_fkey; Type: FK CONSTRAINT; Schema: eth; Owner: - --- - -ALTER TABLE ONLY eth.header_cids - ADD CONSTRAINT header_cids_node_id_fkey FOREIGN KEY (node_id) REFERENCES public.nodes(id) ON DELETE CASCADE; - - --- --- Name: receipt_cids receipt_cids_tx_id_fkey; Type: FK CONSTRAINT; Schema: eth; Owner: - --- - -ALTER TABLE ONLY eth.receipt_cids - ADD CONSTRAINT receipt_cids_tx_id_fkey FOREIGN KEY (tx_id) REFERENCES eth.transaction_cids(id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED; - - --- --- Name: state_accounts state_accounts_state_id_fkey; Type: FK CONSTRAINT; Schema: eth; Owner: - --- - -ALTER TABLE ONLY eth.state_accounts - ADD CONSTRAINT state_accounts_state_id_fkey FOREIGN KEY (state_id) REFERENCES eth.state_cids(id) ON DELETE CASCADE; - - --- --- Name: state_cids state_cids_header_id_fkey; Type: FK CONSTRAINT; Schema: eth; Owner: - --- - -ALTER TABLE ONLY eth.state_cids - ADD CONSTRAINT state_cids_header_id_fkey FOREIGN KEY (header_id) REFERENCES eth.header_cids(id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED; - - --- --- Name: storage_cids storage_cids_state_id_fkey; Type: FK CONSTRAINT; Schema: eth; Owner: - --- - -ALTER TABLE ONLY eth.storage_cids - ADD CONSTRAINT storage_cids_state_id_fkey FOREIGN KEY (state_id) REFERENCES eth.state_cids(id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED; - - --- --- Name: transaction_cids transaction_cids_header_id_fkey; Type: FK CONSTRAINT; Schema: eth; Owner: - --- - -ALTER TABLE ONLY eth.transaction_cids - ADD CONSTRAINT transaction_cids_header_id_fkey FOREIGN KEY (header_id) REFERENCES eth.header_cids(id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED; - - --- --- Name: uncle_cids uncle_cids_header_id_fkey; Type: FK CONSTRAINT; Schema: eth; Owner: - --- - -ALTER TABLE ONLY eth.uncle_cids - ADD CONSTRAINT uncle_cids_header_id_fkey FOREIGN KEY (header_id) REFERENCES eth.header_cids(id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED; - - --- --- Name: checked_headers checked_headers_header_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.checked_headers - ADD CONSTRAINT checked_headers_header_id_fkey FOREIGN KEY (header_id) REFERENCES public.headers(id) ON DELETE CASCADE; - - --- --- Name: header_sync_logs header_sync_logs_address_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.header_sync_logs - ADD CONSTRAINT header_sync_logs_address_fkey FOREIGN KEY (address) REFERENCES public.addresses(id) ON DELETE CASCADE; - - --- --- Name: header_sync_logs header_sync_logs_header_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.header_sync_logs - ADD CONSTRAINT header_sync_logs_header_id_fkey FOREIGN KEY (header_id) REFERENCES public.headers(id) ON DELETE CASCADE; - - --- --- Name: header_sync_receipts header_sync_receipts_contract_address_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.header_sync_receipts - ADD CONSTRAINT header_sync_receipts_contract_address_id_fkey FOREIGN KEY (contract_address_id) REFERENCES public.addresses(id) ON DELETE CASCADE; - - --- --- Name: header_sync_receipts header_sync_receipts_header_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.header_sync_receipts - ADD CONSTRAINT header_sync_receipts_header_id_fkey FOREIGN KEY (header_id) REFERENCES public.headers(id) ON DELETE CASCADE; - - --- --- Name: header_sync_receipts header_sync_receipts_transaction_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.header_sync_receipts - ADD CONSTRAINT header_sync_receipts_transaction_id_fkey FOREIGN KEY (transaction_id) REFERENCES public.header_sync_transactions(id) ON DELETE CASCADE; - - --- --- Name: header_sync_transactions header_sync_transactions_header_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.header_sync_transactions - ADD CONSTRAINT header_sync_transactions_header_id_fkey FOREIGN KEY (header_id) REFERENCES public.headers(id) ON DELETE CASCADE; - - --- --- Name: headers headers_node_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.headers - ADD CONSTRAINT headers_node_id_fkey FOREIGN KEY (node_id) REFERENCES public.nodes(id) ON DELETE CASCADE; - - --- --- Name: queued_storage queued_storage_diff_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.queued_storage - ADD CONSTRAINT queued_storage_diff_id_fkey FOREIGN KEY (diff_id) REFERENCES public.storage_diff(id); - - --- --- PostgreSQL database dump complete --- - diff --git a/pkg/super_node/btc/indexer.go b/pkg/super_node/btc/indexer.go index b042ce74..a6dda9cf 100644 --- a/pkg/super_node/btc/indexer.go +++ b/pkg/super_node/btc/indexer.go @@ -61,11 +61,11 @@ func (in *CIDIndexer) Index(cids shared.CIDsForIndexing) error { func (in *CIDIndexer) indexHeaderCID(tx *sqlx.Tx, header HeaderModel, nodeID int64) (int64, error) { var headerID int64 - err := tx.QueryRowx(`INSERT INTO btc.header_cids (block_number, block_hash, parent_hash, cid, timestamp, bits, node_id) - VALUES ($1, $2, $3, $4, $5, $6, $7) - ON CONFLICT (block_number, block_hash) DO UPDATE SET (parent_hash, cid, timestamp, bits, node_id) = ($3, $4, $5, $6, $7) + err := tx.QueryRowx(`INSERT INTO btc.header_cids (block_number, block_hash, parent_hash, cid, timestamp, bits, node_id, times_validated) + VALUES ($1, $2, $3, $4, $5, $6, $7, $8) + ON CONFLICT (block_number, block_hash) DO UPDATE SET (parent_hash, cid, timestamp, bits, node_id, times_validated) = ($3, $4, $5, $6, $7, btc.header_cids.times_validated + 1) RETURNING id`, - header.BlockNumber, header.BlockHash, header.ParentHash, header.CID, header.Timestamp, header.Bits, nodeID).Scan(&headerID) + header.BlockNumber, header.BlockHash, header.ParentHash, header.CID, header.Timestamp, header.Bits, nodeID, 1).Scan(&headerID) return headerID, err } diff --git a/pkg/super_node/btc/models.go b/pkg/super_node/btc/models.go index 66a1d221..1317a1bc 100644 --- a/pkg/super_node/btc/models.go +++ b/pkg/super_node/btc/models.go @@ -20,14 +20,15 @@ import "github.com/lib/pq" // HeaderModel is the db model for btc.header_cids table type HeaderModel struct { - ID int64 `db:"id"` - BlockNumber string `db:"block_number"` - BlockHash string `db:"block_hash"` - ParentHash string `db:"parent_hash"` - CID string `db:"cid"` - Timestamp int64 `db:"timestamp"` - Bits uint32 `db:"bits"` - NodeID int64 `db:"node_id"` + ID int64 `db:"id"` + BlockNumber string `db:"block_number"` + BlockHash string `db:"block_hash"` + ParentHash string `db:"parent_hash"` + CID string `db:"cid"` + Timestamp int64 `db:"timestamp"` + Bits uint32 `db:"bits"` + NodeID int64 `db:"node_id"` + TimesValidated int64 `db:"times_validated"` } // TxModel is the db model for btc.transaction_cids table diff --git a/pkg/super_node/eth/indexer.go b/pkg/super_node/eth/indexer.go index 6c16d058..533d0443 100644 --- a/pkg/super_node/eth/indexer.go +++ b/pkg/super_node/eth/indexer.go @@ -90,12 +90,12 @@ func (in *CIDIndexer) Index(cids shared.CIDsForIndexing) error { func (in *CIDIndexer) indexHeaderCID(tx *sqlx.Tx, header HeaderModel, nodeID int64) (int64, error) { var headerID int64 - err := tx.QueryRowx(`INSERT INTO eth.header_cids (block_number, block_hash, parent_hash, cid, td, node_id, reward, state_root, tx_root, receipt_root, uncle_root, bloom, timestamp) - VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13) - ON CONFLICT (block_number, block_hash) DO UPDATE SET (parent_hash, cid, td, node_id, reward, state_root, tx_root, receipt_root, uncle_root, bloom, timestamp) = ($3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13) + err := tx.QueryRowx(`INSERT INTO eth.header_cids (block_number, block_hash, parent_hash, cid, td, node_id, reward, state_root, tx_root, receipt_root, uncle_root, bloom, timestamp, times_validated) + VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14) + ON CONFLICT (block_number, block_hash) DO UPDATE SET (parent_hash, cid, td, node_id, reward, state_root, tx_root, receipt_root, uncle_root, bloom, timestamp, times_validated) = ($3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, eth.header_cids.times_validated + 1) RETURNING id`, header.BlockNumber, header.BlockHash, header.ParentHash, header.CID, header.TotalDifficulty, nodeID, header.Reward, header.StateRoot, header.TxRoot, - header.RctRoot, header.UncleRoot, header.Bloom, header.Timestamp).Scan(&headerID) + header.RctRoot, header.UncleRoot, header.Bloom, header.Timestamp, 1).Scan(&headerID) return headerID, err } diff --git a/pkg/super_node/eth/mocks/test_data.go b/pkg/super_node/eth/mocks/test_data.go index 8e981a51..0c578446 100644 --- a/pkg/super_node/eth/mocks/test_data.go +++ b/pkg/super_node/eth/mocks/test_data.go @@ -395,6 +395,7 @@ var ( UncleRoot: MockBlock.UncleHash().String(), Bloom: MockBlock.Bloom().Bytes(), Timestamp: MockBlock.Time(), + TimesValidated: 1, }, Transactions: MockTrxMetaPostPublsh, Receipts: MockRctMetaPostPublish,