aboutsummaryrefslogtreecommitdiff
path: root/src/exchangedb/exchange-0001-part.sql
diff options
context:
space:
mode:
Diffstat (limited to 'src/exchangedb/exchange-0001-part.sql')
-rw-r--r--src/exchangedb/exchange-0001-part.sql68
1 files changed, 46 insertions, 22 deletions
diff --git a/src/exchangedb/exchange-0001-part.sql b/src/exchangedb/exchange-0001-part.sql
index c9c3e2f0..ba54f6f7 100644
--- a/src/exchangedb/exchange-0001-part.sql
+++ b/src/exchangedb/exchange-0001-part.sql
@@ -432,14 +432,14 @@ COMMENT ON TABLE signkey_revocations
CREATE TABLE IF NOT EXISTS extensions
(extension_id BIGINT GENERATED BY DEFAULT AS IDENTITY UNIQUE
,name VARCHAR NOT NULL UNIQUE
- ,config BYTEA
+ ,manifest BYTEA
);
COMMENT ON TABLE extensions
IS 'Configurations of the activated extensions';
COMMENT ON COLUMN extensions.name
IS 'Name of the extension';
-COMMENT ON COLUMN extensions.config
- IS 'Configuration of the extension as JSON-blob, maybe NULL';
+COMMENT ON COLUMN extensions.manifest
+ IS 'Manifest of the extension as JSON-blob, maybe NULL';
-- ------------------------------ known_coins ----------------------------------------
@@ -536,22 +536,46 @@ CREATE TABLE IF NOT EXISTS refresh_transfer_keys_default
SELECT add_constraints_to_refresh_transfer_keys_partition('default');
--- ------------------------------ extension_details ----------------------------------------
+-- ------------------------------ policy_fulfilments -------------------------------------
-CREATE TABLE IF NOT EXISTS extension_details
- (extension_details_serial_id BIGINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY
- ,extension_options VARCHAR)
- PARTITION BY HASH (extension_details_serial_id);
-COMMENT ON TABLE extension_details
- IS 'Extensions that were provided with deposits (not yet used).';
-COMMENT ON COLUMN extension_details.extension_options
- IS 'JSON object with options set that the exchange needs to consider when executing a deposit. Supported details depend on the extensions supported by the exchange.';
+CREATE TABLE IF NOT EXISTS policy_fulfilments
+ (policy_fulfilments_serial_id BIGINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY
+ ,fulfilment_timestamp INT8 NOT NULL
+ ,fulfilment_proof VARCHAR)
+ PARTITION BY HASH (policy_fulfilments_serial_id);
+COMMENT ON TABLE policy_fulfilments
+ IS 'Proofs of fulfilment of policies that were set in deposits';
+COMMENT ON COLUMN policy_fulfilments.fulfilment_timestamp
+ IS 'Timestamp of the arrival of a proof of fulfilment';
+COMMENT ON COLUMN policy_fulfilments.fulfilment_proof
+ IS 'JSON object with a proof of the fulfilment of a policy. Supported details depend on the policy extensions supported by the exchange.';
-CREATE TABLE IF NOT EXISTS extension_details_default
- PARTITION OF extension_details
+CREATE TABLE IF NOT EXISTS policy_fulfilments_default
+ PARTITION OF policy_fulfilments
FOR VALUES WITH (MODULUS 1, REMAINDER 0);
+-- ------------------------------ policy_details ----------------------------------------
+
+CREATE TABLE IF NOT EXISTS policy_details
+ (policy_details_serial_id BIGINT GENERATED BY DEFAULT AS IDENTITY
+ ,serial_id BYTEA PRIMARY KEY CHECK(LENGTH(serial_id)=64)
+ ,policy_options VARCHAR
+ ,fulfilment_serial_id BIGINT REFERENCES policy_fulfilments(policy_fulfilments_serial_id) ON DELETE CASCADE)
+ PARTITION BY HASH (serial_id);
+COMMENT ON TABLE policy_details
+ IS 'Policies that were provided with deposits via policy extensions.';
+COMMENT ON COLUMN policy_details.serial_id
+ IS 'ID (GNUNET_HashCode) that identifies a policy. Will be calculated by the policy extension based on the content';
+COMMENT ON COLUMN policy_details.policy_options
+ IS 'JSON object with options set that the exchange needs to consider when executing a deposit. Supported details depend on the policy extensions supported by the exchange.';
+COMMENT ON COLUMN policy_details.fulfilment_serial_id
+ IS 'If not NULL, refers to the proof of fulfilment of this policy';
+
+CREATE TABLE IF NOT EXISTS policy_details_default
+ PARTITION OF policy_details
+ FOR VALUES WITH (MODULUS 1, REMAINDER 0);
+
-- ------------------------------ deposits ----------------------------------------
SELECT create_table_deposits();
@@ -568,10 +592,10 @@ COMMENT ON COLUMN deposits.wire_salt
IS 'Salt used when hashing the payto://-URI to get the h_wire';
COMMENT ON COLUMN deposits.done
IS 'Set to TRUE once we have included this deposit in some aggregate wire transfer to the merchant';
-COMMENT ON COLUMN deposits.extension_blocked
- IS 'True if the aggregation of the deposit is currently blocked by some extension mechanism. Used to filter out deposits that must not be processed by the canonical deposit logic.';
-COMMENT ON COLUMN deposits.extension_details_serial_id
- IS 'References extensions table, NULL if extensions are not used';
+COMMENT ON COLUMN deposits.policy_blocked
+ IS 'True if the aggregation of the deposit is currently blocked by some policy extension mechanism. Used to filter out deposits that must not be processed by the canonical deposit logic.';
+COMMENT ON COLUMN deposits.policy_details_serial_id
+ IS 'References policy extensions table, NULL if policy extensions are not used';
CREATE TABLE IF NOT EXISTS deposits_default
PARTITION OF deposits
@@ -607,7 +631,7 @@ CREATE OR REPLACE FUNCTION deposits_insert_trigger()
DECLARE
is_ready BOOLEAN;
BEGIN
- is_ready = NOT (NEW.done OR NEW.extension_blocked);
+ is_ready = NOT (NEW.done OR NEW.policy_blocked);
IF (is_ready)
THEN
@@ -651,8 +675,8 @@ DECLARE
DECLARE
is_ready BOOLEAN;
BEGIN
- was_ready = NOT (OLD.done OR OLD.extension_blocked);
- is_ready = NOT (NEW.done OR NEW.extension_blocked);
+ was_ready = NOT (OLD.done OR OLD.policy_blocked);
+ is_ready = NOT (NEW.done OR NEW.policy_blocked);
IF (was_ready AND NOT is_ready)
THEN
DELETE FROM exchange.deposits_by_ready
@@ -706,7 +730,7 @@ CREATE OR REPLACE FUNCTION deposits_delete_trigger()
DECLARE
was_ready BOOLEAN;
BEGIN
- was_ready = NOT (OLD.done OR OLD.extension_blocked);
+ was_ready = NOT (OLD.done OR OLD.policy_blocked);
IF (was_ready)
THEN