gnunet-svn
[Top][All Lists]
Advanced

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

[taler-merchant] 238/277: return active-status of reserves from backendd


From: gnunet
Subject: [taler-merchant] 238/277: return active-status of reserves from backenddb (fixes FIXMEs)
Date: Sun, 05 Jul 2020 20:52:31 +0200

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

grothoff pushed a commit to branch master
in repository merchant.

commit 0748ecde7be1fb9537382d7cadc38031fbc696ff
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Mon Jun 22 20:30:25 2020 +0200

    return active-status of reserves from backenddb (fixes FIXMEs)
---
 .../taler-merchant-httpd_private-get-reserves-ID.c |  7 +++++--
 src/backenddb/plugin_merchantdb_postgres.c         | 22 ++++++++++++++--------
 src/include/taler_merchant_service.h               |  2 ++
 src/include/taler_merchantdb_plugin.h              |  2 ++
 src/lib/merchant_api_get_reserve.c                 |  6 ++++++
 src/testing/testing_api_cmd_get_reserve.c          |  1 +
 6 files changed, 30 insertions(+), 10 deletions(-)

diff --git a/src/backend/taler-merchant-httpd_private-get-reserves-ID.c 
b/src/backend/taler-merchant-httpd_private-get-reserves-ID.c
index 7e7c14a..1945524 100644
--- a/src/backend/taler-merchant-httpd_private-get-reserves-ID.c
+++ b/src/backend/taler-merchant-httpd_private-get-reserves-ID.c
@@ -62,6 +62,7 @@ struct GetReserveContext
  * @param picked_up_amount total of tips that were picked up from this reserve
  * @param committed_amount total of tips that the merchant committed to, but 
that were not
  *           picked up yet
+ * @param active true if the reserve is still active (we have the private key)
  * @param tips_length length of the @a tips array
  * @param tips information about the tips created by this reserve
  */
@@ -73,6 +74,7 @@ handle_reserve_details (void *cls,
                         const struct TALER_Amount *exchange_initial_amount,
                         const struct TALER_Amount *picked_up_amount,
                         const struct TALER_Amount *committed_amount,
+                        bool active,
                         unsigned int tips_length,
                         const struct TALER_MERCHANTDB_TipDetails *tips)
 {
@@ -112,14 +114,15 @@ handle_reserve_details (void *cls,
   ctx->res = TALER_MHD_reply_json_pack (
     ctx->connection,
     MHD_HTTP_OK,
-    "{s:o, s:o, s:o, s:o, s:o, s:o, s:o?}",
+    "{s:o, s:o, s:o, s:o, s:o, s:o, s:o?, s:b}",
     "creation_time", GNUNET_JSON_from_time_abs (creation_time_round),
     "expiration_time", GNUNET_JSON_from_time_abs (expiration_time_round),
     "merchant_initial_amount", TALER_JSON_from_amount 
(merchant_initial_amount),
     "exchange_initial_amount", TALER_JSON_from_amount 
(exchange_initial_amount),
     "pickup_amount", TALER_JSON_from_amount (picked_up_amount),
     "committed_amount", TALER_JSON_from_amount (committed_amount),
-    "tips", tips_json);
+    "tips", tips_json,
+    "active", active);
 }
 
 
diff --git a/src/backenddb/plugin_merchantdb_postgres.c 
b/src/backenddb/plugin_merchantdb_postgres.c
index 5471994..fc1e3ac 100644
--- a/src/backenddb/plugin_merchantdb_postgres.c
+++ b/src/backenddb/plugin_merchantdb_postgres.c
@@ -4341,7 +4341,7 @@ lookup_reserves_cb (void *cls,
     struct TALER_Amount exchange_initial_balance;
     struct TALER_Amount pickup_amount;
     struct TALER_Amount committed_amount;
-    uint8_t active = 0;
+    uint8_t active;
     struct GNUNET_PQ_ResultSpec rs[] = {
       GNUNET_PQ_result_spec_auto_from_type ("reserve_pub",
                                             &reserve_pub),
@@ -4357,8 +4357,8 @@ lookup_reserves_cb (void *cls,
                                    &committed_amount),
       TALER_PQ_RESULT_SPEC_AMOUNT ("tips_picked_up",
                                    &pickup_amount),
-      /*GNUNET_PQ_result_spec_auto_from_type ("active",
-                                            &active), FIXME: 'active'*/
+      GNUNET_PQ_result_spec_auto_from_type ("active",
+                                            &active),
       GNUNET_PQ_result_spec_end
     };
 
@@ -4374,10 +4374,10 @@ lookup_reserves_cb (void *cls,
     switch (lrc->active)
     {
     case TALER_EXCHANGE_YNA_YES:
-      if (! active)
+      if (0 == active)
         continue;
     case TALER_EXCHANGE_YNA_NO:
-      if (active)
+      if (0 != active)
         continue;
     case TALER_EXCHANGE_YNA_ALL:
       break;
@@ -4682,7 +4682,7 @@ postgres_lookup_reserve (void *cls,
   struct TALER_Amount exchange_initial_balance;
   struct TALER_Amount pickup_amount;
   struct TALER_Amount committed_amount;
-  /*uint8_t active;*/
+  uint8_t active;
   struct GNUNET_PQ_ResultSpec rs[] = {
     GNUNET_PQ_result_spec_absolute_time ("creation_time",
                                          &creation_time),
@@ -4696,8 +4696,8 @@ postgres_lookup_reserve (void *cls,
                                  &pickup_amount),
     TALER_PQ_RESULT_SPEC_AMOUNT ("tips_committed",
                                  &committed_amount),
-    /*GNUNET_PQ_result_spec_auto_from_type ("active",
-                                          &active), FIXME: active! */
+    GNUNET_PQ_result_spec_auto_from_type ("active",
+                                          &active),
     GNUNET_PQ_result_spec_end
   };
   enum GNUNET_DB_QueryStatus qs;
@@ -4718,6 +4718,7 @@ postgres_lookup_reserve (void *cls,
         &exchange_initial_balance,
         &pickup_amount,
         &committed_amount,
+        (0 != active),
         0,
         NULL);
     return qs;
@@ -4739,6 +4740,7 @@ postgres_lookup_reserve (void *cls,
         &exchange_initial_balance,
         &pickup_amount,
         &committed_amount,
+        0 != active,
         ltc.tips_length,
         ltc.tips);
   }
@@ -7789,7 +7791,9 @@ libtaler_plugin_merchantdb_postgres_init (void *cls)
                             ",tips_committed_frac"
                             ",tips_picked_up_val"
                             ",tips_picked_up_frac"
+                            ",reserve_priv IS NOT NULL AS active"
                             " FROM merchant_tip_reserves"
+                            " FULL OUTER JOIN merchant_tip_reserve_keys USING 
(reserve_serial)"
                             " WHERE creation_time > $2"
                             "   AND merchant_serial ="
                             "     (SELECT merchant_serial"
@@ -7823,7 +7827,9 @@ libtaler_plugin_merchantdb_postgres_init (void *cls)
                             ",tips_committed_frac"
                             ",tips_picked_up_val"
                             ",tips_picked_up_frac"
+                            ",reserve_priv IS NOT NULL AS active"
                             " FROM merchant_tip_reserves"
+                            " FULL OUTER JOIN merchant_tip_reserve_keys USING 
(reserve_serial)"
                             " WHERE reserve_pub = $2"
                             "   AND merchant_serial ="
                             "     (SELECT merchant_serial"
diff --git a/src/include/taler_merchant_service.h 
b/src/include/taler_merchant_service.h
index 23d0bbe..b6cd681 100644
--- a/src/include/taler_merchant_service.h
+++ b/src/include/taler_merchant_service.h
@@ -2593,6 +2593,7 @@ struct TALER_MERCHANT_TipDetails
  * @param cls closure
  * @param hr HTTP response details
  * @param rs reserve summary for the reserve, NULL on error
+ * @param active is this reserve active (false if it was deleted but not 
purged)
  * @param tips_length length of the @a reserves array
  * @param tips array with details about the tips granted, NULL on error
  */
@@ -2601,6 +2602,7 @@ typedef void
   void *cls,
   const struct TALER_MERCHANT_HttpResponse *hr,
   const struct TALER_MERCHANT_ReserveSummary *rs,
+  bool active,
   unsigned int tips_length,
   const struct TALER_MERCHANT_TipDetails tips[]);
 
diff --git a/src/include/taler_merchantdb_plugin.h 
b/src/include/taler_merchantdb_plugin.h
index 18cb03e..b1dafec 100644
--- a/src/include/taler_merchantdb_plugin.h
+++ b/src/include/taler_merchantdb_plugin.h
@@ -557,6 +557,7 @@ typedef void
  * @param picked_up_amount total of tips that were picked up from this reserve
  * @param committed_amount total of tips that the merchant committed to, but 
that were not
  *           picked up yet
+ * @param active true if the reserve is still active (we have the private key)
  * @param tips_length length of the @a tips array
  * @param tips information about the tips created by this reserve
  */
@@ -569,6 +570,7 @@ typedef void
   const struct TALER_Amount *exchange_initial_amount,
   const struct TALER_Amount *picked_up_amount,
   const struct TALER_Amount *committed_amount,
+  bool active,
   unsigned int tips_length,
   const struct TALER_MERCHANTDB_TipDetails *tips);
 
diff --git a/src/lib/merchant_api_get_reserve.c 
b/src/lib/merchant_api_get_reserve.c
index f92f37f..3ff14d4 100644
--- a/src/lib/merchant_api_get_reserve.c
+++ b/src/lib/merchant_api_get_reserve.c
@@ -83,6 +83,7 @@ handle_reserve_get_finished (void *cls,
     .http_status = (unsigned int) response_code,
     .reply = json
   };
+  bool active;
 
   rgh->job = NULL;
   switch (response_code)
@@ -99,6 +100,8 @@ handle_reserve_get_finished (void *cls,
                                         &rs.creation_time),
         GNUNET_JSON_spec_absolute_time ("expiration_time",
                                         &rs.expiration_time),
+        GNUNET_JSON_spec_bool ("active",
+                               &active),
         TALER_JSON_spec_amount ("merchant_initial_amount",
                                 &rs.merchant_initial_amount),
         TALER_JSON_spec_amount ("exchange_initial_amount",
@@ -129,6 +132,7 @@ handle_reserve_get_finished (void *cls,
         rgh->cb (rgh->cb_cls,
                  &hr,
                  &rs,
+                 false,
                  0,
                  NULL);
         TALER_MERCHANT_reserve_get_cancel (rgh);
@@ -186,6 +190,7 @@ handle_reserve_get_finished (void *cls,
         rgh->cb (rgh->cb_cls,
                  &hr,
                  &rs,
+                 active,
                  tds_length,
                  tds);
         GNUNET_free (tds);
@@ -215,6 +220,7 @@ handle_reserve_get_finished (void *cls,
   rgh->cb (rgh->cb_cls,
            &hr,
            NULL,
+           false,
            0,
            NULL);
   TALER_MERCHANT_reserve_get_cancel (rgh);
diff --git a/src/testing/testing_api_cmd_get_reserve.c 
b/src/testing/testing_api_cmd_get_reserve.c
index 8a26a9a..8c626f8 100644
--- a/src/testing/testing_api_cmd_get_reserve.c
+++ b/src/testing/testing_api_cmd_get_reserve.c
@@ -72,6 +72,7 @@ static void
 get_reserve_cb (void *cls,
                 const struct TALER_MERCHANT_HttpResponse *hr,
                 const struct TALER_MERCHANT_ReserveSummary *rs,
+                bool active,
                 unsigned int tips_length,
                 const struct TALER_MERCHANT_TipDetails tips[])
 {

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