forked from cerc-io/ipld-eth-server
Associate receipts with blocks instead of transactions
- Allows us to fetch receipts by block and persist even when associated transaction is unknown. (The associated transaction can still be derived from the tx_hash column at query time, but is an expensive operation to require for inserts).
This commit is contained in:
+10
-17
@@ -206,13 +206,13 @@ ALTER SEQUENCE public.nodes_id_seq OWNED BY public.eth_nodes.id;
|
||||
|
||||
CREATE TABLE public.receipts (
|
||||
id integer NOT NULL,
|
||||
transaction_id integer NOT NULL,
|
||||
contract_address character varying(42),
|
||||
cumulative_gas_used numeric,
|
||||
gas_used numeric,
|
||||
state_root character varying(66),
|
||||
status integer,
|
||||
tx_hash character varying(66)
|
||||
tx_hash character varying(66),
|
||||
block_id integer NOT NULL
|
||||
);
|
||||
|
||||
|
||||
@@ -496,13 +496,6 @@ CREATE INDEX block_number_index ON public.blocks USING btree (number);
|
||||
CREATE INDEX node_id_index ON public.blocks USING btree (eth_node_id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: transaction_id_index; Type: INDEX; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
CREATE INDEX transaction_id_index ON public.receipts USING btree (transaction_id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: tx_from_index; Type: INDEX; Schema: public; Owner: -
|
||||
--
|
||||
@@ -525,6 +518,14 @@ ALTER TABLE ONLY public.transactions
|
||||
ADD CONSTRAINT blocks_fk FOREIGN KEY (block_id) REFERENCES public.blocks(id) ON DELETE CASCADE;
|
||||
|
||||
|
||||
--
|
||||
-- Name: receipts blocks_fk; Type: FK CONSTRAINT; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY public.receipts
|
||||
ADD CONSTRAINT blocks_fk FOREIGN KEY (block_id) REFERENCES public.blocks(id) ON DELETE CASCADE;
|
||||
|
||||
|
||||
--
|
||||
-- Name: blocks node_fk; Type: FK CONSTRAINT; Schema: public; Owner: -
|
||||
--
|
||||
@@ -541,14 +542,6 @@ ALTER TABLE ONLY public.logs
|
||||
ADD CONSTRAINT receipts_fk FOREIGN KEY (receipt_id) REFERENCES public.receipts(id) ON DELETE CASCADE;
|
||||
|
||||
|
||||
--
|
||||
-- Name: receipts transaction_fk; Type: FK CONSTRAINT; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY public.receipts
|
||||
ADD CONSTRAINT transaction_fk FOREIGN KEY (transaction_id) REFERENCES public.transactions(id) ON DELETE CASCADE;
|
||||
|
||||
|
||||
--
|
||||
-- PostgreSQL database dump complete
|
||||
--
|
||||
|
||||
Reference in New Issue
Block a user