adjust partition and primary keys commitments and reveals in withdraw-age
This commit is contained in:
parent
8992c30631
commit
eafe3435e9
@ -36,7 +36,7 @@ BEGIN
|
|||||||
',timestamp INT8 NOT NULL'
|
',timestamp INT8 NOT NULL'
|
||||||
') %s ;'
|
') %s ;'
|
||||||
,table_name
|
,table_name
|
||||||
,'PARTITION BY HASH (h_commitment)'
|
,'PARTITION BY HASH (reserve_pub)'
|
||||||
,partition_suffix
|
,partition_suffix
|
||||||
);
|
);
|
||||||
PERFORM comment_partitioned_table(
|
PERFORM comment_partitioned_table(
|
||||||
@ -96,9 +96,8 @@ BEGIN
|
|||||||
table_name = concat_ws('_', table_name, partition_suffix);
|
table_name = concat_ws('_', table_name, partition_suffix);
|
||||||
|
|
||||||
EXECUTE FORMAT (
|
EXECUTE FORMAT (
|
||||||
'CREATE INDEX ' || table_name || '_by_reserve_pub'
|
'ALTER TABLE ' || table_name ||
|
||||||
' ON ' || table_name ||
|
' ADD PRIMARY KEY (h_commitment, reserve_pub);'
|
||||||
' (reserve_pub);'
|
|
||||||
);
|
);
|
||||||
EXECUTE FORMAT (
|
EXECUTE FORMAT (
|
||||||
'ALTER TABLE ' || table_name ||
|
'ALTER TABLE ' || table_name ||
|
||||||
|
@ -25,7 +25,8 @@ DECLARE
|
|||||||
BEGIN
|
BEGIN
|
||||||
PERFORM create_partitioned_table(
|
PERFORM create_partitioned_table(
|
||||||
'CREATE TABLE %I'
|
'CREATE TABLE %I'
|
||||||
'(h_commitment BYTEA NOT NULL CHECK (LENGTH(h_commitment)=32)'
|
'(withdraw_age_reveals_id BIGINT GENERATED BY DEFAULT AS IDENTITY' -- UNIQUE
|
||||||
|
',h_commitment BYTEA NOT NULL CHECK (LENGTH(h_commitment)=32)'
|
||||||
',freshcoin_index INT4 NOT NULL'
|
',freshcoin_index INT4 NOT NULL'
|
||||||
',denominations_serial INT8 NOT NULL'
|
',denominations_serial INT8 NOT NULL'
|
||||||
',h_coin_ev BYTEA CHECK (LENGTH(h_coin_ev)=32)'
|
',h_coin_ev BYTEA CHECK (LENGTH(h_coin_ev)=32)'
|
||||||
@ -66,6 +67,29 @@ BEGIN
|
|||||||
END
|
END
|
||||||
$$;
|
$$;
|
||||||
|
|
||||||
|
CREATE FUNCTION constrain_table_withdraw_age_reveals(
|
||||||
|
IN partition_suffix VARCHAR
|
||||||
|
)
|
||||||
|
RETURNS void
|
||||||
|
LANGUAGE plpgsql
|
||||||
|
AS $$
|
||||||
|
DECLARE
|
||||||
|
table_name VARCHAR DEFAULT 'withdraw_age_reveals';
|
||||||
|
BEGIN
|
||||||
|
table_name = concat_ws('_', table_name, partition_suffix);
|
||||||
|
|
||||||
|
EXECUTE FORMAT (
|
||||||
|
'ALTER TABLE ' || table_name ||
|
||||||
|
' ADD CONSTRAINT ' || table_name || '_withdraw_age_reveals_id_key'
|
||||||
|
' UNIQUE (withdraw_age_reveals_id);'
|
||||||
|
);
|
||||||
|
EXECUTE FORMAT (
|
||||||
|
'ALTER TABLE ' || table_name ||
|
||||||
|
' ADD CONSTRAINT ' || table_name || '_freshcoin_index_and_h_commitment_uniqueness'
|
||||||
|
' UNIQUE (freshcoin_index, h_commitment);'
|
||||||
|
);
|
||||||
|
END
|
||||||
|
$$;
|
||||||
|
|
||||||
CREATE FUNCTION foreign_table_withdraw_age_reveals()
|
CREATE FUNCTION foreign_table_withdraw_age_reveals()
|
||||||
RETURNS void
|
RETURNS void
|
||||||
@ -104,6 +128,11 @@ INSERT INTO exchange_tables
|
|||||||
,FALSE),
|
,FALSE),
|
||||||
('withdraw_age_reveals'
|
('withdraw_age_reveals'
|
||||||
,'exchange-0003'
|
,'exchange-0003'
|
||||||
|
,'constrain'
|
||||||
|
,TRUE
|
||||||
|
,FALSE),
|
||||||
|
('withdraw_age_reveals'
|
||||||
|
,'exchange-0003'
|
||||||
,'foreign'
|
,'foreign'
|
||||||
,TRUE
|
,TRUE
|
||||||
,FALSE);
|
,FALSE);
|
||||||
|
Loading…
Reference in New Issue
Block a user