gnunet-svn
[Top][All Lists]
Advanced

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

[taler-merchant] 01/02: simplify logic: only look in orders table if con


From: gnunet
Subject: [taler-merchant] 01/02: simplify logic: only look in orders table if contracts table failed
Date: Thu, 04 Jan 2024 01:03:46 +0100

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

grothoff pushed a commit to branch master
in repository merchant.

commit 881381503f7f51b294c2740e9fcf7f28ef43f973
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Wed Jan 3 23:41:35 2024 +0100

    simplify logic: only look in orders table if contracts table failed
---
 .../taler-merchant-httpd_private-get-orders-ID.c   | 68 +++++++++-------------
 1 file changed, 29 insertions(+), 39 deletions(-)

diff --git a/src/backend/taler-merchant-httpd_private-get-orders-ID.c 
b/src/backend/taler-merchant-httpd_private-get-orders-ID.c
index cd26d378..602a970f 100644
--- a/src/backend/taler-merchant-httpd_private-get-orders-ID.c
+++ b/src/backend/taler-merchant-httpd_private-get-orders-ID.c
@@ -763,16 +763,15 @@ phase_fetch_contract (struct GetOrderRequestContext *gorc)
                                            "contract terms"));
     return;
   }
-  if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs)
+  if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qs)
   {
-    gorc->order_only = true;
+    gorc->phase++;
+    return;
   }
-  /* FIXME: what is the point of doing the lookup_order
-     below if order_only is false (qs == 1 above)?
-     Seems we could just return here, or not? */
+  /* No contract, only order, fetch from orders table */
+  gorc->order_only = true;
   {
     struct TALER_MerchantPostDataHashP unused;
-    json_t *ct = NULL;
 
     /* We need the order for two cases:  Either when the contract doesn't 
exist yet,
      * or when the order is claimed but unpaid, and we need the claim token. */
@@ -781,39 +780,30 @@ phase_fetch_contract (struct GetOrderRequestContext *gorc)
                                hc->infix,
                                &gorc->claim_token,
                                &unused,
-                               &ct);
-    if (0 > qs)
-    {
-      /* single, read-only SQL statements should never cause
-         serialization problems */
-      GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR != qs);
-      /* Always report on hard error as well to enable diagnostics */
-      GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR == qs);
-      phase_end (gorc,
-                 TALER_MHD_reply_with_error (gorc->sc.con,
-                                             MHD_HTTP_INTERNAL_SERVER_ERROR,
-                                             TALER_EC_GENERIC_DB_FETCH_FAILED,
-                                             "order"));
-      return;
-    }
-    if (gorc->order_only &&
-        (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs) )
-    {
-      phase_end (gorc,
-                 TALER_MHD_reply_with_error (gorc->sc.con,
-                                             MHD_HTTP_NOT_FOUND,
-                                             
TALER_EC_MERCHANT_GENERIC_ORDER_UNKNOWN,
-                                             hc->infix));
-      return;
-    }
-    if (gorc->order_only)
-    {
-      gorc->contract_terms = ct;
-    }
-    else if (NULL != ct)
-    {
-      json_decref (ct);
-    }
+                               &gorc->contract_terms);
+  }
+  if (0 > qs)
+  {
+    /* single, read-only SQL statements should never cause
+       serialization problems */
+    GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR != qs);
+    /* Always report on hard error as well to enable diagnostics */
+    GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR == qs);
+    phase_end (gorc,
+               TALER_MHD_reply_with_error (gorc->sc.con,
+                                           MHD_HTTP_INTERNAL_SERVER_ERROR,
+                                           TALER_EC_GENERIC_DB_FETCH_FAILED,
+                                           "order"));
+    return;
+  }
+  if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs)
+  {
+    phase_end (gorc,
+               TALER_MHD_reply_with_error (gorc->sc.con,
+                                           MHD_HTTP_NOT_FOUND,
+                                           
TALER_EC_MERCHANT_GENERIC_ORDER_UNKNOWN,
+                                           hc->infix));
+    return;
   }
   gorc->phase++;
 }

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