-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathschema_new.sql
More file actions
822 lines (589 loc) · 23.7 KB
/
schema_new.sql
File metadata and controls
822 lines (589 loc) · 23.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
--
-- PostgreSQL database dump
--
SET statement_timeout = 0;
SET lock_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SET check_function_bodies = false;
SET client_min_messages = warning;
--
-- 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 search_path = public, pg_catalog;
--
-- Name: add_blk_statics(integer); Type: FUNCTION; Schema: public; Owner: postgres
--
CREATE FUNCTION add_blk_statics(blkid integer) RETURNS void
LANGUAGE plpgsql
AS $_$
BEGIN
update blk set total_in_count=t.a, total_out_count=t.b, total_in_value=t.c, total_out_value=t.d, fees=t.e from (select sum(in_count) as a,sum(out_count) as b, sum(in_value) as c, sum(out_value) as d, sum(fee) as e from tx where id in (select tx_id from blk_tx where blk_id=$1)) as t where blk.id=$1;
delete from utx where id in (select tx_id from blk_tx where blk_id=$1);
END;
$_$;
ALTER FUNCTION public.add_blk_statics(blkid integer) OWNER TO postgres;
--
-- Name: add_tx_statics(integer, integer, integer, bigint, bigint); Type: FUNCTION; Schema: public; Owner: postgres
--
CREATE FUNCTION add_tx_statics(txid integer, inc integer, outc integer, inv bigint, outv bigint) RETURNS void
LANGUAGE plpgsql
AS $_$
BEGIN
IF (inv = 0) THEN
update tx set in_count=$2, out_count=$3, in_value=$4, out_value=$5, fee=0 where id=$1;
else
update tx set in_count=$2, out_count=$3, in_value=$4, out_value=$5, fee=($4-$5) where id=$1;
END IF;
perform update_addr_balance($1);
END
$_$;
ALTER FUNCTION public.add_tx_statics(txid integer, inc integer, outc integer, inv bigint, outv bigint) OWNER TO postgres;
--
-- Name: delete_blk(bytea); Type: FUNCTION; Schema: public; Owner: postgres
--
CREATE FUNCTION delete_blk(blkhash bytea) RETURNS void
LANGUAGE plpgsql
AS $$
declare blkid integer;
declare txid integer;
BEGIN
blkid=(select id from blk where hash=blkhash);
txid=(select tx_id from blk_tx where blk_id=blkid and idx=0);
insert into utx select tx_id from blk_tx where blk_id=blkid;
delete from blk_tx where blk_id=blkid;
delete from blk where id=blkid;
perform delete_tx(txid);
END
$$;
ALTER FUNCTION public.delete_blk(blkhash bytea) OWNER TO postgres;
--
-- Name: delete_height(integer); Type: FUNCTION; Schema: public; Owner: postgres
--
CREATE FUNCTION delete_height(blkheight integer) RETURNS void
LANGUAGE plpgsql
AS $$
declare blkhash bytea;
BEGIN
blkhash = (select hash from blk where height=blkheight);
perform delete_blk(blkhash);
END
$$;
ALTER FUNCTION public.delete_height(blkheight integer) OWNER TO postgres;
--
-- Name: delete_tx(integer); Type: FUNCTION; Schema: public; Owner: postgres
--
CREATE FUNCTION delete_tx(txid integer) RETURNS void
LANGUAGE plpgsql
AS $_$
DECLARE ntx RECORD;
BEGIN
FOR ntx IN select txin_tx_id from vout where txout_tx_id=$1 LOOP
perform delete_tx(ntx.txin_tx_id);
END LOOP;
perform rollback_addr_balance($1);
delete from addr_txout where txout_id in (select id from txout where tx_id=$1);
delete from txin where tx_id=$1;
delete from txout where tx_id=$1;
delete from tx where id=$1;
delete from utx where id=$1;
END;
$_$;
ALTER FUNCTION public.delete_tx(txid integer) OWNER TO postgres;
--
-- Name: get_confirm(integer); Type: FUNCTION; Schema: public; Owner: postgres
--
CREATE FUNCTION get_confirm(txid integer) RETURNS integer
LANGUAGE plpgsql
AS $_$
DECLARE tx_height integer;
DECLARE max_height integer;
BEGIN
tx_height=(select c.height from tx a join blk_tx b on(b.tx_id=a.id) join blk c on (c.id=b.blk_id) where a.id=$1);
max_height=(select max(height) from blk);
return (max_height-tx_height+1);
END;
$_$;
ALTER FUNCTION public.get_confirm(txid integer) OWNER TO postgres;
--
-- Name: insert_addr(text, text); Type: FUNCTION; Schema: public; Owner: postgres
--
CREATE FUNCTION insert_addr(a text, h text) RETURNS integer
LANGUAGE plpgsql
AS $$
declare addrid integer;
BEGIN
addrid = (select id from addr where address = a);
IF addrid is NULL THEN
insert into addr (address, hash160) values(a, h) RETURNING id into addrid;
END IF;
return addrid;
END
$$;
ALTER FUNCTION public.insert_addr(a text, h text) OWNER TO postgres;
--
-- Name: rollback_addr_balance(integer); Type: FUNCTION; Schema: public; Owner: postgres
--
CREATE FUNCTION rollback_addr_balance(txid integer) RETURNS void
LANGUAGE plpgsql
AS $$
DECLARE o RECORD;
BEGIN
FOR o IN select addr_id, value from vout where txin_tx_id=txid and addr_id is not NULL LOOP
update addr set balance=(balance + o.value), spent_value=(spent_value-o.value) where id=o.addr_id;
END LOOP;
FOR o IN select addr_id, value from vout where txout_tx_id=txid and addr_id is not NULL LOOP
update addr set balance=(balance - o.value), recv_value=(recv_value-o.value) where id=o.addr_id;
END LOOP;
FOR o IN select distinct addr_id from vout where txin_tx_id=txid and addr_id is not NULL LOOP
update addr set spent_count=(spent_count-1) where id=o.addr_id;
delete from addr_tx where addr_id=o.addr_id and tx_id=txid;
END LOOP;
FOR o IN select distinct addr_id from vout where txout_tx_id=txid and addr_id is not NULL LOOP
update addr set recv_count=(recv_count-1) where id=o.addr_id;
delete from addr_tx where addr_id=o.addr_id and tx_id=txid;
END LOOP;
END;
$$;
ALTER FUNCTION public.rollback_addr_balance(txid integer) OWNER TO postgres;
--
-- Name: tru_utx(); Type: FUNCTION; Schema: public; Owner: postgres
--
CREATE FUNCTION tru_utx() RETURNS void
LANGUAGE plpgsql
AS $$
declare did integer;
BEGIN
FOR did IN select id from utx LOOP
perform delete_tx(did);
END LOOP;
truncate table utx;
END;
$$;
ALTER FUNCTION public.tru_utx() OWNER TO postgres;
--
-- Name: update_addr_balance(integer); Type: FUNCTION; Schema: public; Owner: postgres
--
CREATE FUNCTION update_addr_balance(txid integer) RETURNS void
LANGUAGE plpgsql
AS $$
DECLARE o RECORD;
BEGIN
FOR o IN select addr_id, value from vout where txin_tx_id=txid and addr_id is not NULL LOOP
update addr set balance=(balance - o.value), spent_value=(spent_value+o.value) where id=o.addr_id;
END LOOP;
FOR o IN select addr_id, value from vout where txout_tx_id=txid and addr_id is not NULL LOOP
update addr set balance=(balance + o.value), recv_value=(recv_value+o.value) where id=o.addr_id;
END LOOP;
FOR o IN select distinct addr_id from vout where txin_tx_id=txid and addr_id is not NULL LOOP
update addr set spent_count=(spent_count+1) where id=o.addr_id;
insert into addr_tx (addr_id,tx_id) values(o.addr_id, txid);
END LOOP;
FOR o IN select distinct addr_id from vout where txout_tx_id=txid and addr_id is not NULL LOOP
update addr set recv_count=(recv_count+1) where id=o.addr_id;
insert into addr_tx (addr_id,tx_id) values(o.addr_id, txid);
END LOOP;
END;
$$;
ALTER FUNCTION public.update_addr_balance(txid integer) OWNER TO postgres;
SET default_tablespace = '';
SET default_with_oids = false;
--
-- Name: addr; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
--
CREATE TABLE addr (
id integer NOT NULL,
address text NOT NULL,
hash160 text NOT NULL,
balance bigint DEFAULT 0,
recv_value bigint DEFAULT 0,
recv_count integer DEFAULT 0,
spent_value bigint DEFAULT 0,
spent_count integer DEFAULT 0
);
ALTER TABLE public.addr OWNER TO postgres;
--
-- Name: addr_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE addr_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE public.addr_id_seq OWNER TO postgres;
--
-- Name: addr_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE addr_id_seq OWNED BY addr.id;
--
-- Name: addr_tx; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
--
CREATE TABLE addr_tx (
addr_id integer NOT NULL,
tx_id integer NOT NULL
);
ALTER TABLE public.addr_tx OWNER TO postgres;
--
-- Name: addr_txout; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
--
CREATE TABLE addr_txout (
addr_id integer NOT NULL,
txout_id integer NOT NULL
);
ALTER TABLE public.addr_txout OWNER TO postgres;
--
-- Name: tx; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
--
CREATE TABLE tx (
id integer NOT NULL,
hash bytea NOT NULL,
version bigint NOT NULL,
lock_time bigint NOT NULL,
coinbase boolean NOT NULL,
tx_size integer NOT NULL,
in_count integer,
in_value bigint,
out_count integer,
out_value bigint,
fee bigint,
recv_time bigint,
ip text
);
ALTER TABLE public.tx OWNER TO postgres;
--
-- Name: txin; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
--
CREATE TABLE txin (
id integer NOT NULL,
tx_id integer NOT NULL,
tx_idx integer NOT NULL,
prev_out_index bigint NOT NULL,
sequence bigint NOT NULL,
script_sig bytea,
prev_out bytea
);
ALTER TABLE public.txin OWNER TO postgres;
--
-- Name: txout; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
--
CREATE TABLE txout (
id integer NOT NULL,
tx_id integer NOT NULL,
tx_idx integer NOT NULL,
pk_script bytea NOT NULL,
value bigint,
type integer NOT NULL
);
ALTER TABLE public.txout OWNER TO postgres;
--
-- Name: vout; Type: VIEW; Schema: public; Owner: postgres
--
CREATE VIEW vout AS
SELECT g.address,
g.id AS addr_id,
a.id AS txout_id,
c.id AS txin_id,
e.id AS txin_tx_id,
b.id AS txout_tx_id,
a.value,
a.tx_idx AS out_idx,
c.tx_idx AS in_idx
FROM (((((txout a
LEFT JOIN tx b ON ((b.id = a.tx_id)))
LEFT JOIN txin c ON (((c.prev_out = b.hash) AND (c.prev_out_index = a.tx_idx))))
LEFT JOIN tx e ON ((e.id = c.tx_id)))
LEFT JOIN addr_txout f ON ((f.txout_id = a.id)))
LEFT JOIN addr g ON ((g.id = f.addr_id)));
ALTER TABLE public.vout OWNER TO postgres;
--
-- Name: balance; Type: VIEW; Schema: public; Owner: postgres
--
CREATE VIEW balance AS
SELECT vout.addr_id,
sum(vout.value) AS value
FROM vout
WHERE (vout.txin_id IS NULL)
GROUP BY vout.addr_id;
ALTER TABLE public.balance OWNER TO postgres;
--
-- Name: blk; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
--
CREATE TABLE blk (
id integer NOT NULL,
hash bytea NOT NULL,
height integer NOT NULL,
version bigint NOT NULL,
prev_hash bytea NOT NULL,
mrkl_root bytea NOT NULL,
"time" bigint NOT NULL,
bits bigint NOT NULL,
nonce bigint NOT NULL,
blk_size integer NOT NULL,
work bytea,
total_in_count integer,
total_in_value bigint,
fees bigint,
total_out_count integer,
total_out_value bigint,
tx_count integer
);
ALTER TABLE public.blk OWNER TO postgres;
--
-- Name: blk_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE blk_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE public.blk_id_seq OWNER TO postgres;
--
-- Name: blk_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE blk_id_seq OWNED BY blk.id;
--
-- Name: blk_tx; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
--
CREATE TABLE blk_tx (
blk_id integer NOT NULL,
tx_id integer NOT NULL,
idx integer NOT NULL
);
ALTER TABLE public.blk_tx OWNER TO postgres;
--
-- Name: tx_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE tx_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE public.tx_id_seq OWNER TO postgres;
--
-- Name: tx_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE tx_id_seq OWNED BY tx.id;
--
-- Name: txin_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE txin_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE public.txin_id_seq OWNER TO postgres;
--
-- Name: txin_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE txin_id_seq OWNED BY txin.id;
--
-- Name: txout_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE txout_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE public.txout_id_seq OWNER TO postgres;
--
-- Name: txout_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE txout_id_seq OWNED BY txout.id;
--
-- Name: utx; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
--
CREATE TABLE utx (
id integer
);
ALTER TABLE public.utx OWNER TO postgres;
--
-- Name: utxo; Type: VIEW; Schema: public; Owner: postgres
--
CREATE VIEW utxo AS
SELECT g.address,
g.id AS addr_id,
a.id AS txout_id,
c.id AS txin_id,
e.id AS txin_tx_id,
b.id AS txout_tx_id,
b.hash AS txout_txhash,
a.value,
a.tx_idx,
blk.height,
blk."time",
a.pk_script
FROM (((((((txout a
LEFT JOIN tx b ON ((b.id = a.tx_id)))
LEFT JOIN txin c ON (((c.prev_out = b.hash) AND (c.prev_out_index = a.tx_idx))))
LEFT JOIN tx e ON ((e.id = c.tx_id)))
LEFT JOIN addr_txout f ON ((f.txout_id = a.id)))
LEFT JOIN addr g ON ((g.id = f.addr_id)))
JOIN blk_tx ON ((blk_tx.tx_id = a.tx_id)))
JOIN blk ON ((blk.id = blk_tx.blk_id)))
WHERE (c.id IS NULL);
ALTER TABLE public.utxo OWNER TO postgres;
--
-- Name: vtx; Type: VIEW; Schema: public; Owner: postgres
--
CREATE VIEW vtx AS
SELECT a.id,
a.hash,
a.version,
a.lock_time,
a.coinbase,
a.tx_size,
a.in_count,
a.in_value,
a.out_count,
a.out_value,
a.fee,
a.recv_time,
a.ip,
b.idx,
c.height,
c."time"
FROM ((tx a
LEFT JOIN blk_tx b ON ((b.tx_id = a.id)))
LEFT JOIN blk c ON ((c.id = b.blk_id)));
ALTER TABLE public.vtx OWNER TO postgres;
--
-- Name: id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY addr ALTER COLUMN id SET DEFAULT nextval('addr_id_seq'::regclass);
--
-- Name: id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY blk ALTER COLUMN id SET DEFAULT nextval('blk_id_seq'::regclass);
--
-- Name: id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY tx ALTER COLUMN id SET DEFAULT nextval('tx_id_seq'::regclass);
--
-- Name: id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY txin ALTER COLUMN id SET DEFAULT nextval('txin_id_seq'::regclass);
--
-- Name: id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY txout ALTER COLUMN id SET DEFAULT nextval('txout_id_seq'::regclass);
--
-- Name: blk_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace:
--
ALTER TABLE ONLY blk
ADD CONSTRAINT blk_pkey PRIMARY KEY (id);
--
-- Name: naddr_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace:
--
ALTER TABLE ONLY addr
ADD CONSTRAINT naddr_pkey PRIMARY KEY (id);
--
-- Name: tx_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace:
--
ALTER TABLE ONLY tx
ADD CONSTRAINT tx_pkey PRIMARY KEY (id);
--
-- Name: txin_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace:
--
ALTER TABLE ONLY txin
ADD CONSTRAINT txin_pkey PRIMARY KEY (id);
--
-- Name: txout_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace:
--
ALTER TABLE ONLY txout
ADD CONSTRAINT txout_pkey PRIMARY KEY (id);
--
-- Name: u_constrainte; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace:
--
ALTER TABLE ONLY addr_tx
ADD CONSTRAINT u_constrainte UNIQUE (addr_id, tx_id);
--
-- Name: uniq_addr_address; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace:
--
ALTER TABLE ONLY addr
ADD CONSTRAINT uniq_addr_address UNIQUE (address);
--
-- Name: uniq_blk_hash; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace:
--
ALTER TABLE ONLY blk
ADD CONSTRAINT uniq_blk_hash UNIQUE (hash);
--
-- Name: uniq_tx_hash; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace:
--
ALTER TABLE ONLY tx
ADD CONSTRAINT uniq_tx_hash UNIQUE (hash);
--
-- Name: addr_txout_index; Type: INDEX; Schema: public; Owner: postgres; Tablespace:
--
CREATE UNIQUE INDEX addr_txout_index ON addr_txout USING btree (addr_id, txout_id);
--
-- Name: blk_hash_index; Type: INDEX; Schema: public; Owner: postgres; Tablespace:
--
CREATE INDEX blk_hash_index ON blk USING btree (hash);
--
-- Name: blk_height_index; Type: INDEX; Schema: public; Owner: postgres; Tablespace:
--
CREATE INDEX blk_height_index ON blk USING btree (height);
--
-- Name: blk_prev_hash_index; Type: INDEX; Schema: public; Owner: postgres; Tablespace:
--
CREATE INDEX blk_prev_hash_index ON blk USING btree (prev_hash);
--
-- Name: blk_tx_blk_id_index; Type: INDEX; Schema: public; Owner: postgres; Tablespace:
--
CREATE INDEX blk_tx_blk_id_index ON blk_tx USING btree (blk_id);
--
-- Name: blk_tx_tx_id_index; Type: INDEX; Schema: public; Owner: postgres; Tablespace:
--
CREATE INDEX blk_tx_tx_id_index ON blk_tx USING btree (tx_id);
--
-- Name: inaddr_txout_index; Type: INDEX; Schema: public; Owner: postgres; Tablespace:
--
CREATE INDEX inaddr_txout_index ON addr_txout USING btree (txout_id);
--
-- Name: tx_hash_index; Type: INDEX; Schema: public; Owner: postgres; Tablespace:
--
CREATE INDEX tx_hash_index ON tx USING btree (hash);
--
-- Name: txin_prev_out_index; Type: INDEX; Schema: public; Owner: postgres; Tablespace:
--
CREATE INDEX txin_prev_out_index ON txin USING btree (prev_out);
--
-- Name: txin_txid_index; Type: INDEX; Schema: public; Owner: postgres; Tablespace:
--
CREATE INDEX txin_txid_index ON txin USING btree (tx_id);
--
-- Name: txout_txid_idx_index; Type: INDEX; Schema: public; Owner: postgres; Tablespace:
--
CREATE INDEX txout_txid_idx_index ON txout USING btree (tx_id, tx_idx);
--
-- Name: txout_txid_index; Type: INDEX; Schema: public; Owner: postgres; Tablespace:
--
CREATE INDEX txout_txid_index ON txout USING btree (tx_id);
--
-- Name: addr_tx_on_duplicate_ignore; Type: RULE; Schema: public; Owner: postgres
--
CREATE RULE addr_tx_on_duplicate_ignore AS
ON INSERT TO addr_tx
WHERE (EXISTS ( SELECT 1
FROM addr_tx
WHERE ((addr_tx.addr_id = new.addr_id) AND (addr_tx.tx_id = new.tx_id)))) DO INSTEAD NOTHING;
--
-- Name: public; Type: ACL; Schema: -; Owner: postgres
--
REVOKE ALL ON SCHEMA public FROM PUBLIC;
REVOKE ALL ON SCHEMA public FROM postgres;
GRANT ALL ON SCHEMA public TO postgres;
GRANT ALL ON SCHEMA public TO PUBLIC;
--
-- PostgreSQL database dump complete
--