gnunet-svn
[Top][All Lists]
Advanced

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

[taler-exchange] branch master updated: address DB failure error handlin


From: gnunet
Subject: [taler-exchange] branch master updated: address DB failure error handling in KYC check
Date: Fri, 27 Jan 2023 14:19:18 +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 42bd2dad address DB failure error handling in KYC check
42bd2dad is described below

commit 42bd2dadcfad336623c0650c28580e8206bf95b9
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Fri Jan 27 14:19:14 2023 +0100

    address DB failure error handling in KYC check
---
 contrib/gana                                  |  2 +-
 src/exchange/taler-exchange-httpd_kyc-check.c | 27 +++++++++++++++++++++------
 src/include/taler_kyclogic_lib.h              | 10 ++++++----
 src/kyclogic/kyclogic_api.c                   | 20 +++++++++++++++-----
 4 files changed, 43 insertions(+), 16 deletions(-)

diff --git a/contrib/gana b/contrib/gana
index 3e659ed5..7884adf9 160000
--- a/contrib/gana
+++ b/contrib/gana
@@ -1 +1 @@
-Subproject commit 3e659ed54023230dd45dbec5664f176e1763d260
+Subproject commit 7884adf99ec4d5ccf52b1a5a251b99fb6ab9c2f6
diff --git a/src/exchange/taler-exchange-httpd_kyc-check.c 
b/src/exchange/taler-exchange-httpd_kyc-check.c
index 47338ae9..1ef12bd9 100644
--- a/src/exchange/taler-exchange-httpd_kyc-check.c
+++ b/src/exchange/taler-exchange-httpd_kyc-check.c
@@ -297,6 +297,7 @@ kyc_check (void *cls,
   enum GNUNET_GenericReturnValue ret;
   struct TALER_PaytoHashP h_payto;
   char *requirements;
+  bool satisfied;
 
   qs = TEH_plugin->lookup_kyc_requirement_by_row (
     TEH_plugin->cls,
@@ -330,12 +331,26 @@ kyc_check (void *cls,
     GNUNET_free (requirements);
     return GNUNET_DB_STATUS_HARD_ERROR;
   }
-  if (TALER_KYCLOGIC_check_satisfied (
-        requirements,
-        &h_payto,
-        &kyp->kyc_details,
-        TEH_plugin->select_satisfied_kyc_processes,
-        TEH_plugin->cls))
+  qs = TALER_KYCLOGIC_check_satisfied (
+    requirements,
+    &h_payto,
+    &kyp->kyc_details,
+    TEH_plugin->select_satisfied_kyc_processes,
+    TEH_plugin->cls,
+    &satisfied);
+  if (qs < 0)
+  {
+    if (GNUNET_DB_STATUS_SOFT_ERROR == qs)
+      return qs;
+    GNUNET_break (0);
+    *mhd_ret = TALER_MHD_reply_with_error (connection,
+                                           MHD_HTTP_INTERNAL_SERVER_ERROR,
+                                           TALER_EC_GENERIC_DB_FETCH_FAILED,
+                                           "kyc_test_required");
+    GNUNET_free (requirements);
+    return GNUNET_DB_STATUS_HARD_ERROR;
+  }
+  if (satisfied)
   {
     GNUNET_log (GNUNET_ERROR_TYPE_INFO,
                 "KYC requirements `%s' already satisfied\n",
diff --git a/src/include/taler_kyclogic_lib.h b/src/include/taler_kyclogic_lib.h
index 3acc78df..e90dcb1c 100644
--- a/src/include/taler_kyclogic_lib.h
+++ b/src/include/taler_kyclogic_lib.h
@@ -214,7 +214,7 @@ typedef enum GNUNET_DB_QueryStatus
  *         amounts involved in this type of operation
  *         at the given account
  * @param ai_cls closure for @a ai
- * @param[out] set to NULL if no check is needed,
+ * @param[out] required set to NULL if no check is needed,
  *   otherwise space-separated list of required checks
  * @return transaction status
  */
@@ -238,14 +238,16 @@ TALER_KYCLOGIC_kyc_test_required (enum 
TALER_KYCLOGIC_KycTriggerEvent event,
  *             KYC information was collected
  * @param ki iterator over satisfied providers
  * @param ki_cls closure for @a ki
- * @return true if the KYC check was satisfied
+ * @param[out] satisfied set to true if the KYC check was satisfied
+ * @return transaction status (from @a ki)
  */
-bool
+enum GNUNET_DB_QueryStatus
 TALER_KYCLOGIC_check_satisfied (const char *requirements,
                                 const struct TALER_PaytoHashP *h_payto,
                                 json_t **kyc_details,
                                 TALER_KYCLOGIC_KycSatisfiedIterator ki,
-                                void *ki_cls);
+                                void *ki_cls,
+                                bool *satisfied);
 
 
 /**
diff --git a/src/kyclogic/kyclogic_api.c b/src/kyclogic/kyclogic_api.c
index fdd814ae..d7ecf51e 100644
--- a/src/kyclogic/kyclogic_api.c
+++ b/src/kyclogic/kyclogic_api.c
@@ -1166,18 +1166,22 @@ TALER_KYCLOGIC_kyc_get_details (
 }
 
 
-bool
+enum GNUNET_DB_QueryStatus
 TALER_KYCLOGIC_check_satisfied (const char *requirements,
                                 const struct TALER_PaytoHashP *h_payto,
                                 json_t **kyc_details,
                                 TALER_KYCLOGIC_KycSatisfiedIterator ki,
-                                void *ki_cls)
+                                void *ki_cls,
+                                bool *satisfied)
 {
   struct TALER_KYCLOGIC_KycCheck *needed[num_kyc_checks];
   unsigned int needed_cnt = 0;
 
   if (NULL == requirements)
-    return true;
+  {
+    *satisfied = true;
+    return GNUNET_DB_STATUS_SUCCESS_NO_RESULTS;
+  }
   {
     char *req = GNUNET_strdup (requirements);
 
@@ -1204,7 +1208,12 @@ TALER_KYCLOGIC_check_satisfied (const char *requirements,
              h_payto,
              &remove_satisfied,
              &rc);
-    GNUNET_break (qs >= 0);  // FIXME: handle DB failure more nicely?
+    if (qs < 0)
+    {
+      GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs);
+      *satisfied = false;
+      return qs;
+    }
     if (0 != needed_cnt)
     {
       json_decref (rc.kyc_details);
@@ -1215,7 +1224,8 @@ TALER_KYCLOGIC_check_satisfied (const char *requirements,
       *kyc_details = rc.kyc_details;
     }
   }
-  return (0 == needed_cnt);
+  *satisfied = (0 == needed_cnt);
+  return GNUNET_DB_STATUS_SUCCESS_ONE_RESULT;
 }
 
 

-- 
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]