aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2022-04-04 17:04:31 +0200
committerChristian Grothoff <christian@grothoff.org>2022-04-04 17:04:31 +0200
commitdf8ff01f2924f557096ec24ff650aefbf7931784 (patch)
tree7a798226ed71a22e6ebc7c9813b8166e8e524520 /src
parent914a77b5a7fefd19cddac1308ab1f16ca25cebbb (diff)
add contract_sig field
Diffstat (limited to 'src')
-rw-r--r--src/exchangedb/common-0001.sql63
-rw-r--r--src/exchangedb/exchange-0001-part.sql14
2 files changed, 40 insertions, 37 deletions
diff --git a/src/exchangedb/common-0001.sql b/src/exchangedb/common-0001.sql
index 01e68dfb5..11386b22e 100644
--- a/src/exchangedb/common-0001.sql
+++ b/src/exchangedb/common-0001.sql
@@ -30,7 +30,7 @@ LANGUAGE plpgsql
AS $$
BEGIN
- IF shard_suffix IS NOT NULL THEN
+ IF shard_suffix IS NOT NULL THEN
table_name=table_name || '_' || shard_suffix;
main_table_partition_str = '';
END IF;
@@ -41,7 +41,7 @@ BEGIN
main_table_partition_str
);
-END
+END
$$;
----------------------- wire_targets ---------------------------
@@ -165,7 +165,7 @@ BEGIN
',wire_reference INT8 NOT NULL'
',credit_val INT8 NOT NULL'
',credit_frac INT4 NOT NULL'
- ',wire_source_h_payto BYTEA CHECK (LENGTH(wire_source_h_payto)=32)'
+ ',wire_source_h_payto BYTEA CHECK (LENGTH(wire_source_h_payto)=32)'
',exchange_account_section TEXT NOT NULL'
',execution_date INT8 NOT NULL'
') %s ;'
@@ -175,7 +175,7 @@ BEGIN
);
table_name = concat_ws('_', table_name, shard_suffix);
-
+
EXECUTE FORMAT (
'CREATE INDEX IF NOT EXISTS ' || table_name || '_by_reserve_in_serial_id_index '
'ON ' || table_name || ' '
@@ -504,7 +504,7 @@ BEGIN
);
table_name = concat_ws('_', table_name, shard_suffix);
-
+
EXECUTE FORMAT (
'CREATE INDEX IF NOT EXISTS ' || table_name || '_coins_by_melt_serial_id_index '
'ON ' || table_name || ' '
@@ -618,7 +618,7 @@ BEGIN
EXECUTE FORMAT (
'CREATE INDEX IF NOT EXISTS ' || table_name || '_by_coin_pub_index '
- 'ON ' || table_name || ' '
+ 'ON ' || table_name || ' '
'(coin_pub);'
);
@@ -928,7 +928,7 @@ BEGIN
);
table_name = concat_ws('_', table_name, shard_suffix);
-
+
EXECUTE FORMAT (
'CREATE INDEX IF NOT EXISTS ' || table_name || '_by_coin_pub_index '
'ON ' || table_name || ' '
@@ -1014,7 +1014,7 @@ BEGIN
);
table_name = concat_ws('_', table_name, shard_suffix);
-
+
-- FIXME: any query using this index will be slow. Materialize index or change query?
-- Also: which query uses this index?
EXECUTE FORMAT (
@@ -1326,6 +1326,7 @@ BEGIN
'(contract_serial_id BIGINT GENERATED BY DEFAULT AS IDENTITY' --UNIQUE
',purse_pub BYTEA NOT NULL CHECK (LENGTH(purse_pub)=32)'
',pub_ckey BYTEA NOT NULL CHECK (LENGTH(pub_ckey)=32)'
+ ',contract_sig BYTEA NOT NULL CHECK (LENGTH(contract_sig)=64)'
',e_contract BYTEA NOT NULL'
',purse_expiration INT8 NOT NULL'
',PRIMARY KEY (purse_pub)'
@@ -1744,28 +1745,28 @@ BEGIN
ALTER TABLE IF EXISTS reserves_in
DETACH PARTITION reserves_in_default;
-
+
ALTER TABLE IF EXISTS reserves_close
DETACH PARTITION reserves_close_default;
-
+
ALTER TABLE IF EXISTS reserves_out
DETACH PARTITION reserves_out_default;
ALTER TABLE IF EXISTS reserves_out_by_reserve
DETACH PARTITION reserves_out_by_reserve_default;
-
+
ALTER TABLE IF EXISTS known_coins
DETACH PARTITION known_coins_default;
-
+
ALTER TABLE IF EXISTS refresh_commitments
DETACH PARTITION refresh_commitments_default;
-
+
ALTER TABLE IF EXISTS refresh_revealed_coins
DETACH PARTITION refresh_revealed_coins_default;
-
+
ALTER TABLE IF EXISTS refresh_transfer_keys
DETACH PARTITION refresh_transfer_keys_default;
-
+
ALTER TABLE IF EXISTS deposits
DETACH PARTITION deposits_default;
@@ -1778,28 +1779,28 @@ BEGIN
ALTER TABLE IF EXISTS refunds
DETACH PARTITION refunds_default;
-
+
ALTER TABLE IF EXISTS wire_out
DETACH PARTITION wire_out_default;
ALTER TABLE IF EXISTS aggregation_transient
DETACH PARTITION aggregation_transient_default;
-
+
ALTER TABLE IF EXISTS aggregation_tracking
DETACH PARTITION aggregation_tracking_default;
-
+
ALTER TABLE IF EXISTS recoup
DETACH PARTITION recoup_default;
ALTER TABLE IF EXISTS recoup_by_reserve
DETACH PARTITION recoup_by_reserve_default;
-
+
ALTER TABLE IF EXISTS recoup_refresh
DETACH PARTITION recoup_refresh_default;
-
+
ALTER TABLE IF EXISTS prewire
DETACH PARTITION prewire_default;
-
+
ALTER TABLE IF EXISTS cs_nonce_locks
DETACH partition cs_nonce_locks_default;
@@ -1808,7 +1809,7 @@ BEGIN
ALTER TABLE IF EXISTS purse_merges
DETACH partition purse_merges_default;
-
+
ALTER TABLE IF EXISTS account_merges
DETACH partition account_merges_default;
@@ -1817,10 +1818,10 @@ BEGIN
ALTER TABLE IF EXISTS history_requests
DETACH partition history_requests_default;
-
+
ALTER TABLE IF EXISTS close_requests
DETACH partition close_requests_default;
-
+
ALTER TABLE IF EXISTS purse_deposits
DETACH partition purse_deposits_default;
@@ -1951,7 +1952,7 @@ BEGIN
,num_partitions
);
PERFORM add_constraints_to_known_coins_partition(num_partitions::varchar);
-
+
PERFORM create_hash_partition(
'refresh_commitments'
,modulus
@@ -2096,7 +2097,7 @@ BEGIN
,num_partitions
);
PERFORM add_constraints_to_account_merges_partition(num_partitions::varchar);
-
+
PERFORM create_hash_partition(
'contracts'
,modulus
@@ -2136,7 +2137,7 @@ BEGIN
,num_partitions
);
PERFORM add_constraints_to_wads_in_partition(num_partitions::varchar);
-
+
PERFORM create_hash_partition(
'wad_in_entries'
,modulus
@@ -2308,7 +2309,7 @@ BEGIN
END
$$;
-
+
CREATE OR REPLACE FUNCTION create_shard_server(
shard_suffix VARCHAR
@@ -2587,7 +2588,7 @@ BEGIN
END
$$;
-COMMENT ON FUNCTION create_shard_server
+COMMENT ON FUNCTION create_shard_server
IS 'Create a shard server on the master
node with all foreign tables and user mappings';
@@ -2613,10 +2614,10 @@ BEGIN
,'taler-exchange'
,'5432'
,'taler-exchange-httpd'
- );
+ );
END LOOP;
END
$$;
-COMMIT; \ No newline at end of file
+COMMIT;
diff --git a/src/exchangedb/exchange-0001-part.sql b/src/exchangedb/exchange-0001-part.sql
index b35348235..c068ff6f9 100644
--- a/src/exchangedb/exchange-0001-part.sql
+++ b/src/exchangedb/exchange-0001-part.sql
@@ -183,7 +183,7 @@ BEGIN
(NEW.reserve_uuid
,NEW.h_blind_ev);
RETURN NEW;
-END $$;
+END $$;
COMMENT ON FUNCTION reserves_out_by_reserve_insert_trigger()
IS 'Replicate reserve_out inserts into reserve_out_by_reserve table.';
@@ -200,7 +200,7 @@ BEGIN
DELETE FROM reserves_out_by_reserve
WHERE reserve_uuid = OLD.reserve_uuid;
RETURN OLD;
-END $$;
+END $$;
COMMENT ON FUNCTION reserves_out_by_reserve_delete_trigger()
IS 'Replicate reserve_out deletions into reserve_out_by_reserve table.';
@@ -457,7 +457,7 @@ COMMENT ON TABLE deposits_for_matching
CREATE TABLE IF NOT EXISTS deposits_for_matching_default
PARTITION OF deposits_for_matching
DEFAULT;
-
+
CREATE OR REPLACE FUNCTION deposits_insert_trigger()
RETURNS trigger
@@ -492,7 +492,7 @@ BEGIN
,NEW.deposit_serial_id);
END IF;
RETURN NEW;
-END $$;
+END $$;
COMMENT ON FUNCTION deposits_insert_trigger()
IS 'Replicate deposit inserts into materialized indices.';
@@ -777,7 +777,7 @@ BEGIN
(NEW.reserve_out_serial_id
,NEW.coin_pub);
RETURN NEW;
-END $$;
+END $$;
COMMENT ON FUNCTION recoup_insert_trigger()
IS 'Replicate recoup inserts into recoup_by_reserve table.';
@@ -795,7 +795,7 @@ BEGIN
WHERE reserve_out_serial_id = OLD.reserve_out_serial_id
AND coin_pub = OLD.coin_pub;
RETURN OLD;
-END $$;
+END $$;
COMMENT ON FUNCTION recoup_delete_trigger()
IS 'Replicate recoup deletions into recoup_by_reserve table.';
@@ -1068,6 +1068,8 @@ COMMENT ON TABLE contracts
IS 'encrypted contracts associated with purses';
COMMENT ON COLUMN contracts.purse_pub
IS 'public key of the purse that the contract is associated with';
+COMMENT ON COLUMN contracts.contract_sig
+ IS 'signature over the encrypted contract by the purse contract key';
COMMENT ON COLUMN contracts.pub_ckey
IS 'Public ECDH key used to encrypt the contract, to be used with the purse private key for decryption';
COMMENT ON COLUMN contracts.e_contract