aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2023-11-17 08:53:04 +0100
committerChristian Grothoff <christian@grothoff.org>2023-11-17 08:53:04 +0100
commitfcd3493558dafd0bd667c3918e4a4d583bdc2e08 (patch)
treefd4027de91e9b56277269e7022eaa4657829c893
parent8956edbef483dace07800bca4885954f01134032 (diff)
downloadexchange-fcd3493558dafd0bd667c3918e4a4d583bdc2e08.tar.xz
-on conflict update
-rw-r--r--src/exchangedb/exchange_do_insert_aml_decision.sql16
-rw-r--r--src/include/taler_crypto_lib.h96
2 files changed, 58 insertions, 54 deletions
diff --git a/src/exchangedb/exchange_do_insert_aml_decision.sql b/src/exchangedb/exchange_do_insert_aml_decision.sql
index 1598a4073..f46a73d07 100644
--- a/src/exchangedb/exchange_do_insert_aml_decision.sql
+++ b/src/exchangedb/exchange_do_insert_aml_decision.sql
@@ -32,7 +32,7 @@ AS $$
BEGIN
-- Check officer is eligible to make decisions.
PERFORM
- FROM exchange.aml_staff
+ FROM aml_staff
WHERE decider_pub=in_decider_pub
AND is_active
AND NOT read_only;
@@ -47,7 +47,7 @@ out_invalid_officer=FALSE;
-- Check no more recent decision exists.
SELECT decision_time
INTO out_last_date
- FROM exchange.aml_history
+ FROM aml_history
WHERE h_payto=in_h_payto
ORDER BY decision_time DESC;
IF FOUND
@@ -57,7 +57,7 @@ THEN
-- Refuse to insert older decision.
RETURN;
END IF;
- UPDATE exchange.aml_status
+ UPDATE aml_status
SET threshold=in_new_threshold
,status=in_new_status
,kyc_requirement=in_requirement_row
@@ -65,7 +65,7 @@ THEN
ASSERT FOUND, 'cannot have AML decision history but no AML status';
ELSE
out_last_date = 0;
- INSERT INTO exchange.aml_status
+ INSERT INTO aml_status
(h_payto
,threshold
,status
@@ -74,11 +74,15 @@ ELSE
(in_h_payto
,in_new_threshold
,in_new_status
- ,in_requirement_row);
+ ,in_requirement_row)
+ ON CONFLICT (h_payto) DO
+ UPDATE SET
+ threshold=in_new_threshod
+ ,status=in_new_status;
END IF;
-INSERT INTO exchange.aml_history
+INSERT INTO aml_history
(h_payto
,new_threshold
,new_status
diff --git a/src/include/taler_crypto_lib.h b/src/include/taler_crypto_lib.h
index 7ea44189c..2089d77a0 100644
--- a/src/include/taler_crypto_lib.h
+++ b/src/include/taler_crypto_lib.h
@@ -50,6 +50,54 @@
#define TALER_CNC_KAPPA_MINUS_ONE_STR "2"
+/**
+ * Possible AML decision states.
+ */
+enum TALER_AmlDecisionState
+{
+
+ /**
+ * All AML requirements are currently satisfied.
+ */
+ TALER_AML_NORMAL = 0,
+
+ /**
+ * An AML investigation is pending.
+ */
+ TALER_AML_PENDING = 1,
+
+ /**
+ * An AML decision has concluded that the funds must be frozen.
+ */
+ TALER_AML_FROZEN = 2
+
+};
+
+
+/**
+ * Possible algorithms for confirmation code generation.
+ */
+enum TALER_MerchantConfirmationAlgorithm
+{
+
+ /**
+ * No purchase confirmation.
+ */
+ TALER_MCA_NONE = 0,
+
+ /**
+ * Purchase confirmation without payment
+ */
+ TALER_MCA_WITHOUT_PRICE = 1,
+
+ /**
+ * Purchase confirmation with payment
+ */
+ TALER_MCA_WITH_PRICE = 2
+
+};
+
+
/* ****************** Coin crypto primitives ************* */
GNUNET_NETWORK_STRUCT_BEGIN
@@ -562,54 +610,6 @@ struct TALER_AmlOfficerSignatureP
/**
- * Possible AML decision states.
- */
-enum TALER_AmlDecisionState
-{
-
- /**
- * All AML requirements are currently satisfied.
- */
- TALER_AML_NORMAL = 0,
-
- /**
- * An AML investigation is pending.
- */
- TALER_AML_PENDING = 1,
-
- /**
- * An AML decision has concluded that the funds must be frozen.
- */
- TALER_AML_FROZEN = 2
-
-};
-
-
-/**
- * Possible algorithms for confirmation code generation.
- */
-enum TALER_MerchantConfirmationAlgorithm
-{
-
- /**
- * No purchase confirmation.
- */
- TALER_MCA_NONE = 0,
-
- /**
- * Purchase confirmation without payment
- */
- TALER_MCA_WITHOUT_PRICE = 1,
-
- /**
- * Purchase confirmation with payment
- */
- TALER_MCA_WITH_PRICE = 2
-
-};
-
-
-/**
* Commitment value for the refresh protocol.
* See #TALER_refresh_get_commitment().
*/