gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-exchange] branch master updated: -basic insert logic of new DB AP


From: gnunet
Subject: [taler-exchange] branch master updated: -basic insert logic of new DB API
Date: Fri, 30 Dec 2022 14:41:24 +0100

This is an automated email from the git hooks/post-receive script.

grothoff pushed a commit to branch master
in repository exchange.

The following commit(s) were added to refs/heads/master by this push:
     new 94fbb1c2 -basic insert logic of new DB API
94fbb1c2 is described below

commit 94fbb1c211a8c3d8d43c76d91f369de1c0a4615f
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Fri Dec 30 14:41:16 2022 +0100

    -basic insert logic of new DB API
---
 src/exchangedb/0003-aml_history.sql       |  1 +
 src/exchangedb/pg_insert_aml_decision.c   | 31 ++++++++++++++++++++++++++++--
 src/exchangedb/pg_insert_aml_officer.c    | 27 ++++++++++++++++++++++++--
 src/exchangedb/pg_insert_kyc_attributes.c | 32 +++++++++++++++++++++++++++++--
 src/exchangedb/pg_insert_wire.c           |  7 +++----
 src/exchangedb/pg_update_aml_officer.c    | 25 ++++++++++++++++++++++--
 src/exchangedb/pg_update_kyc_attributes.c | 29 ++++++++++++++++++++++++++--
 7 files changed, 138 insertions(+), 14 deletions(-)

diff --git a/src/exchangedb/0003-aml_history.sql 
b/src/exchangedb/0003-aml_history.sql
index d3650f6c..c2ab532d 100644
--- a/src/exchangedb/0003-aml_history.sql
+++ b/src/exchangedb/0003-aml_history.sql
@@ -114,6 +114,7 @@ BEGIN
   );
 END $$;
 
+-- FIXME: also have INSERT on AML decisions to update AML status!
 
 INSERT INTO exchange_tables
     (name
diff --git a/src/exchangedb/pg_insert_aml_decision.c 
b/src/exchangedb/pg_insert_aml_decision.c
index 25ad4c56..94f30275 100644
--- a/src/exchangedb/pg_insert_aml_decision.c
+++ b/src/exchangedb/pg_insert_aml_decision.c
@@ -37,6 +37,33 @@ TEH_PG_insert_aml_decision (
   const struct TALER_AmlOfficerPublicKeyP *decider_pub,
   const struct TALER_AmlOfficerSignatureP *decider_sig)
 {
-  GNUNET_break (0); // FIXME: not implemeted!
-  return GNUNET_DB_STATUS_HARD_ERROR;
+  struct PostgresClosure *pg = cls;
+  uint32_t ns = (uint32_t) new_status;
+  struct GNUNET_PQ_QueryParam params[] = {
+    GNUNET_PQ_query_param_auto_from_type (h_payto),
+    TALER_PQ_query_param_amount (new_threshold),
+    GNUNET_PQ_query_param_uint32 (&ns),
+    GNUNET_PQ_query_param_timestamp (&decision_time),
+    GNUNET_PQ_query_param_string (justification),
+    GNUNET_PQ_query_param_auto_from_type (decider_pub),
+    GNUNET_PQ_query_param_auto_from_type (decider_sig),
+    GNUNET_PQ_query_param_end
+  };
+
+  PREPARE (pg,
+           "insert_aml_decision",
+           "INSERT INTO aml_history "
+           "(h_payto"
+           ",new_threshold_val"
+           ",new_threshold_frac"
+           ",new_status"
+           ",decision_time"
+           ",justification"
+           ",decider_pub"
+           ",decider_sig"
+           ") VALUES "
+           "($1, $2, $3, $4, $5, $6, $7, $8);");
+  return GNUNET_PQ_eval_prepared_non_select (pg->conn,
+                                             "insert_aml_decision",
+                                             params);
 }
diff --git a/src/exchangedb/pg_insert_aml_officer.c 
b/src/exchangedb/pg_insert_aml_officer.c
index 89b7ffae..fc2cadef 100644
--- a/src/exchangedb/pg_insert_aml_officer.c
+++ b/src/exchangedb/pg_insert_aml_officer.c
@@ -36,6 +36,29 @@ TEH_PG_insert_aml_officer (
   bool read_only,
   struct GNUNET_TIME_Absolute last_change)
 {
-  GNUNET_break (0); // FIXME: not implemeted!
-  return GNUNET_DB_STATUS_HARD_ERROR;
+  struct PostgresClosure *pg = cls;
+  struct GNUNET_PQ_QueryParam params[] = {
+    GNUNET_PQ_query_param_auto_from_type (decider_pub),
+    GNUNET_PQ_query_param_auto_from_type (master_sig),
+    GNUNET_PQ_query_param_string (decider_name),
+    GNUNET_PQ_query_param_bool (is_active),
+    GNUNET_PQ_query_param_bool (read_only),
+    GNUNET_PQ_query_param_absolute_time (&last_change),
+    GNUNET_PQ_query_param_end
+  };
+
+  PREPARE (pg,
+           "insert_aml_staff",
+           "INSERT INTO aml_staff "
+           "(decider_pub"
+           ",master_sig"
+           ",decider_name"
+           ",is_active"
+           ",read_only"
+           ",last_change"
+           ") VALUES "
+           "($1, $2, $3, $4, $5, $6);");
+  return GNUNET_PQ_eval_prepared_non_select (pg->conn,
+                                             "insert_aml_staff",
+                                             params);
 }
diff --git a/src/exchangedb/pg_insert_kyc_attributes.c 
b/src/exchangedb/pg_insert_kyc_attributes.c
index 5714e2aa..fd90950f 100644
--- a/src/exchangedb/pg_insert_kyc_attributes.c
+++ b/src/exchangedb/pg_insert_kyc_attributes.c
@@ -38,6 +38,34 @@ TEH_PG_insert_kyc_attributes (
   size_t enc_attributes_size,
   const void *enc_attributes)
 {
-  GNUNET_break (0); // FIXME: not implemeted!
-  return GNUNET_DB_STATUS_HARD_ERROR;
+  struct PostgresClosure *pg = cls;
+  struct GNUNET_PQ_QueryParam params[] = {
+    GNUNET_PQ_query_param_auto_from_type (h_payto),
+    GNUNET_PQ_query_param_auto_from_type (kyc_prox),
+    GNUNET_PQ_query_param_string (provider_section),
+    (NULL == birthdate)
+    ? GNUNET_PQ_query_param_null ()
+    : GNUNET_PQ_query_param_string (birthdate),
+    GNUNET_PQ_query_param_timestamp (&collection_time),
+    GNUNET_PQ_query_param_timestamp (&expiration_time),
+    GNUNET_PQ_query_param_fixed_size (enc_attributes,
+                                      enc_attributes_size),
+    GNUNET_PQ_query_param_end
+  };
+
+  PREPARE (pg,
+           "insert_kyc_attributes",
+           "INSERT INTO kyc_attributes "
+           "(h_payto"
+           ",kyc_prox"
+           ",provider"
+           ",birthdate"
+           ",collection_time"
+           ",expiration_time"
+           ",encrypted_attributes"
+           ") VALUES "
+           "($1, $2, $3, $4, $5, $6, $7);");
+  return GNUNET_PQ_eval_prepared_non_select (pg->conn,
+                                             "insert_kyc_attributes",
+                                             params);
 }
diff --git a/src/exchangedb/pg_insert_wire.c b/src/exchangedb/pg_insert_wire.c
index 646bce94..75323b6f 100644
--- a/src/exchangedb/pg_insert_wire.c
+++ b/src/exchangedb/pg_insert_wire.c
@@ -28,9 +28,9 @@
 
 enum GNUNET_DB_QueryStatus
 TEH_PG_insert_wire (void *cls,
-                      const char *payto_uri,
-                      struct GNUNET_TIME_Timestamp start_date,
-                      const struct TALER_MasterSignatureP *master_sig)
+                    const char *payto_uri,
+                    struct GNUNET_TIME_Timestamp start_date,
+                    const struct TALER_MasterSignatureP *master_sig)
 {
   struct PostgresClosure *pg = cls;
   struct GNUNET_PQ_QueryParam params[] = {
@@ -40,7 +40,6 @@ TEH_PG_insert_wire (void *cls,
     GNUNET_PQ_query_param_end
   };
 
-      /* used in #postgres_insert_wire() */
   PREPARE (pg,
            "insert_wire",
            "INSERT INTO wire_accounts "
diff --git a/src/exchangedb/pg_update_aml_officer.c 
b/src/exchangedb/pg_update_aml_officer.c
index aca58f0c..f756e6e2 100644
--- a/src/exchangedb/pg_update_aml_officer.c
+++ b/src/exchangedb/pg_update_aml_officer.c
@@ -36,6 +36,27 @@ TEH_PG_update_aml_officer (
   bool read_only,
   struct GNUNET_TIME_Absolute last_change)
 {
-  GNUNET_break (0); // FIXME: not implemeted!
-  return GNUNET_DB_STATUS_HARD_ERROR;
+  struct PostgresClosure *pg = cls;
+  struct GNUNET_PQ_QueryParam params[] = {
+    GNUNET_PQ_query_param_auto_from_type (decider_pub),
+    GNUNET_PQ_query_param_auto_from_type (master_sig),
+    GNUNET_PQ_query_param_string (decider_name),
+    GNUNET_PQ_query_param_bool (is_active),
+    GNUNET_PQ_query_param_bool (read_only),
+    GNUNET_PQ_query_param_timestamp (&last_change),
+    GNUNET_PQ_query_param_end
+  };
+
+  PREPARE (pg,
+           "update_aml_staff",
+           "UPDATE aml_staff SET "
+           " master_sig=$2"
+           ",decider_name=$3"
+           ",is_active=$4"
+           ",read_only=$5"
+           ",last_change=$6"
+           " WHERE decider_pub=$1 AND last_change < $6;");
+  return GNUNET_PQ_eval_prepared_non_select (pg->conn,
+                                             "update_aml_staff",
+                                             params);
 }
diff --git a/src/exchangedb/pg_update_kyc_attributes.c 
b/src/exchangedb/pg_update_kyc_attributes.c
index 8f0c6fd3..f77eb2bf 100644
--- a/src/exchangedb/pg_update_kyc_attributes.c
+++ b/src/exchangedb/pg_update_kyc_attributes.c
@@ -38,6 +38,31 @@ TEH_PG_update_kyc_attributes (
   size_t enc_attributes_size,
   const void *enc_attributes)
 {
-  GNUNET_break (0); // FIXME: not implemeted!
-  return GNUNET_DB_STATUS_HARD_ERROR;
+  struct PostgresClosure *pg = cls;
+  struct GNUNET_PQ_QueryParam params[] = {
+    GNUNET_PQ_query_param_auto_from_type (h_payto),
+    GNUNET_PQ_query_param_auto_from_type (kyc_prox),
+    GNUNET_PQ_query_param_string (provider_section),
+    (NULL == birthdate)
+    ? GNUNET_PQ_query_param_null ()
+    : GNUNET_PQ_query_param_string (birthdate),
+    GNUNET_PQ_query_param_timestamp (&collection_time),
+    GNUNET_PQ_query_param_timestamp (&expiration_time),
+    GNUNET_PQ_query_param_fixed_size (enc_attributes,
+                                      enc_attributes_size),
+    GNUNET_PQ_query_param_end
+  };
+
+  PREPARE (pg,
+           "update_kyc_attributes",
+           "UPDATE kyc_attributes SET "
+           " kyc_prox=$2"
+           ",birthdate=$4"
+           ",collection_time=$5"
+           ",expiration_time=$6"
+           ",encrypted_attributes=$7"
+           " WHERE h_payto=$1 AND provider_section=$3;");
+  return GNUNET_PQ_eval_prepared_non_select (pg->conn,
+                                             "update_kyc_attributes",
+                                             params);
 }

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]