Canonical blocks (#108)

* Update Block w/ newest Block

* Add cascading delete to blocks and transactions tables

* Add handling for new conflicting blocks

* Command line version of sliding window n behind HEAD
This commit is contained in:
Matt K
2017-12-19 14:14:41 -06:00
committed by GitHub
parent 84e77f259d
commit 266c9587c8
19 changed files with 352 additions and 70 deletions
@@ -0,0 +1,11 @@
BEGIN;
ALTER TABLE transactions
DROP CONSTRAINT blocks_fk;
ALTER TABLE transactions
ADD CONSTRAINT fk_test
FOREIGN KEY (block_id)
REFERENCES blocks (id);
COMMIT;
@@ -0,0 +1,12 @@
BEGIN;
ALTER TABLE transactions
DROP CONSTRAINT fk_test;
ALTER TABLE transactions
ADD CONSTRAINT blocks_fk
FOREIGN KEY (block_id)
REFERENCES blocks (id)
ON DELETE CASCADE;
COMMIT;
@@ -0,0 +1,11 @@
BEGIN;
ALTER TABLE blocks
DROP CONSTRAINT node_fk;
ALTER TABLE blocks
ADD CONSTRAINT node_fk
FOREIGN KEY (node_id)
REFERENCES nodes (id);
COMMIT;
@@ -0,0 +1,12 @@
BEGIN;
ALTER TABLE blocks
DROP CONSTRAINT node_fk;
ALTER TABLE blocks
ADD CONSTRAINT node_fk
FOREIGN KEY (node_id)
REFERENCES nodes (id)
ON DELETE CASCADE;
COMMIT;
+3 -3
View File
@@ -331,11 +331,11 @@ CREATE INDEX block_number_index ON blocks USING btree (block_number);
--
-- Name: transactions fk_test; Type: FK CONSTRAINT; Schema: public; Owner: -
-- Name: transactions blocks_fk; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY transactions
ADD CONSTRAINT fk_test FOREIGN KEY (block_id) REFERENCES blocks(id);
ADD CONSTRAINT blocks_fk FOREIGN KEY (block_id) REFERENCES blocks(id) ON DELETE CASCADE;
--
@@ -343,7 +343,7 @@ ALTER TABLE ONLY transactions
--
ALTER TABLE ONLY blocks
ADD CONSTRAINT node_fk FOREIGN KEY (node_id) REFERENCES nodes(id);
ADD CONSTRAINT node_fk FOREIGN KEY (node_id) REFERENCES nodes(id) ON DELETE CASCADE;
--