diff options
-rw-r--r-- | src/exchangedb/0003-aml_history.sql | 4 | ||||
-rw-r--r-- | src/exchangedb/0003-aml_staff.sql | 2 | ||||
-rw-r--r-- | src/exchangedb/0003-purse_deletion.sql | 18 | ||||
-rw-r--r-- | src/exchangedb/Makefile.am | 1 | ||||
-rw-r--r-- | src/exchangedb/drop.sql | 1 | ||||
-rw-r--r-- | src/exchangedb/exchange_do_purse_deposit.sql | 13 | ||||
-rw-r--r-- | src/lib/exchange_api_handle.c | 2 |
7 files changed, 25 insertions, 16 deletions
diff --git a/src/exchangedb/0003-aml_history.sql b/src/exchangedb/0003-aml_history.sql index 2d6298ed8..009f79d89 100644 --- a/src/exchangedb/0003-aml_history.sql +++ b/src/exchangedb/0003-aml_history.sql @@ -32,8 +32,8 @@ BEGIN ',new_status INT4 NOT NULL DEFAULT(0)' ',decision_time INT8 NOT NULL DEFAULT(0)' ',justification VARCHAR NOT NULL' - ',decider_pub BYTEA PRIMARY KEY CHECK (LENGTH(decider_pub)=32)' - ',decider_sig BYTEA PRIMARY KEY CHECK (LENGTH(decider_sig)=64)' + ',decider_pub BYTEA CHECK (LENGTH(decider_pub)=32)' + ',decider_sig BYTEA CHECK (LENGTH(decider_sig)=64)' ') %s ;' ,table_name ,'PARTITION BY HASH (h_payto)' diff --git a/src/exchangedb/0003-aml_staff.sql b/src/exchangedb/0003-aml_staff.sql index 9015c7803..dca0fc8d5 100644 --- a/src/exchangedb/0003-aml_staff.sql +++ b/src/exchangedb/0003-aml_staff.sql @@ -18,7 +18,7 @@ CREATE TABLE aml_staff (aml_staff_uuid BIGINT GENERATED BY DEFAULT AS IDENTITY UNIQUE ,decider_pub BYTEA PRIMARY KEY CHECK (LENGTH(decider_pub)=32) - ,master_sig BYTEA PRIMARY KEY CHECK (LENGTH(master_sig)=64) + ,master_sig BYTEA CHECK (LENGTH(master_sig)=64) ,decider_name VARCHAR NOT NULL ,is_active BOOLEAN NOT NULL ,last_change INT8 NOT NULL diff --git a/src/exchangedb/0003-purse_deletion.sql b/src/exchangedb/0003-purse_deletion.sql index 5434a334e..69db4293c 100644 --- a/src/exchangedb/0003-purse_deletion.sql +++ b/src/exchangedb/0003-purse_deletion.sql @@ -51,7 +51,7 @@ COMMENT ON FUNCTION create_table_purse_deletion CREATE OR REPLACE FUNCTION constrain_table_purse_deletion( - IN partition_suffix VARCHAR + IN partition_suffix VARCHAR DEFAULT NULL ) RETURNS void LANGUAGE plpgsql @@ -68,8 +68,7 @@ BEGIN END $$; -CREATE OR REPLACE FUNCTION create_table_purse_requests_was_deleted ( - IN partition_suffix VARCHAR +CREATE OR REPLACE FUNCTION master_table_purse_requests_was_deleted ( ) RETURNS void LANGUAGE plpgsql @@ -77,18 +76,13 @@ AS $$ DECLARE table_name VARCHAR DEFAULT 'purse_requests'; BEGIN - table_name = concat_ws('_', table_name, partition_suffix); EXECUTE FORMAT ( - 'ALTER TABLE ' || table_name || + 'ALTER TABLE exchange.' || table_name || ' ADD COLUMN' ' was_deleted BOOLEAN NOT NULL DEFAULT(FALSE)' ); - PERFORM comment_partitioned_column( - 'TRUE if the purse was explicitly deleted (purse must have an entry in the purse_deletion table)' - ,'was_deleted' - ,table_name - ,partition_suffix - ); + COMMENT ON COLUMN purse_requests.was_deleted + IS 'TRUE if the purse was explicitly deleted (purse must have an entry in the purse_deletion table)'; END $$; @@ -111,6 +105,6 @@ INSERT INTO exchange_tables ,FALSE), ('purse_requests_was_deleted' ,'exchange-0003' - ,'create' + ,'master' ,TRUE ,FALSE); diff --git a/src/exchangedb/Makefile.am b/src/exchangedb/Makefile.am index 6955a0af9..4adb4180c 100644 --- a/src/exchangedb/Makefile.am +++ b/src/exchangedb/Makefile.am @@ -27,6 +27,7 @@ sql_DATA = \ versioning.sql \ exchange-0001.sql \ exchange-0002.sql \ + exchange-0003.sql \ drop.sql \ procedures.sql diff --git a/src/exchangedb/drop.sql b/src/exchangedb/drop.sql index ff383d743..ecebde6f5 100644 --- a/src/exchangedb/drop.sql +++ b/src/exchangedb/drop.sql @@ -20,6 +20,7 @@ BEGIN; SELECT _v.unregister_patch('exchange-0001'); SELECT _v.unregister_patch('exchange-0002'); +SELECT _v.unregister_patch('exchange-0003'); DROP SCHEMA exchange CASCADE; diff --git a/src/exchangedb/exchange_do_purse_deposit.sql b/src/exchangedb/exchange_do_purse_deposit.sql index 0ca4126af..62fcb3b12 100644 --- a/src/exchangedb/exchange_do_purse_deposit.sql +++ b/src/exchangedb/exchange_do_purse_deposit.sql @@ -83,6 +83,19 @@ THEN END IF; +-- Check if purse was deleted, if so, abort and prevent deposit. +PERFORM + FROM exchange.purse_deletion + WHERE purse_pub = in_purse_pub; +IF FOUND +THEN + out_late=TRUE; + out_balance_ok=FALSE; + out_conflict=FALSE; + RETURN; +END IF; + + -- Debit the coin -- Check and update balance of the coin. UPDATE known_coins diff --git a/src/lib/exchange_api_handle.c b/src/lib/exchange_api_handle.c index 3a23508c2..8501ed11d 100644 --- a/src/lib/exchange_api_handle.c +++ b/src/lib/exchange_api_handle.c @@ -1276,7 +1276,7 @@ TALER_EXCHANGE_check_keys_current (struct TALER_EXCHANGE_Handle *exchange, { GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Forcing re-download of all exchange keys\n"); - GNUNET_break (GNUNET_YES == force_download); + GNUNET_break (force_download); exchange->state = MHS_INIT; } if ( (! force_download) && |