gnunet-svn
[Top][All Lists]
Advanced

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

[taler-donau] branch master updated: fix taler amount in db


From: gnunet
Subject: [taler-donau] branch master updated: fix taler amount in db
Date: Tue, 26 Mar 2024 20:54:24 +0100

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

johannes-casaburi pushed a commit to branch master
in repository donau.

The following commit(s) were added to refs/heads/master by this push:
     new 26a90ba  fix taler amount in db
26a90ba is described below

commit 26a90ba8f9f9fad96d8b2c34e8013ee0a0549e7a
Author: Casaburi Johannes <johannes.casaburi@students.bfh.ch>
AuthorDate: Tue Mar 26 20:53:54 2024 +0100

    fix taler amount in db
---
 src/donau/donau-httpd_get-charities.c   |  5 ++--
 src/donau/donau-httpd_get-history.c     |  4 ++-
 src/donau/donau-httpd_keys.c            |  3 +-
 src/donaudb/pg_get_charities.c          | 51 +++++++++++++++++++--------------
 src/donaudb/pg_get_history.c            | 42 ++++++++++++++++-----------
 src/donaudb/pg_iterate_donation_units.c | 42 ++++++++++++++++-----------
 src/include/donaudb_plugin.h            | 28 +++++++++---------
 7 files changed, 101 insertions(+), 74 deletions(-)

diff --git a/src/donau/donau-httpd_get-charities.c 
b/src/donau/donau-httpd_get-charities.c
index 038411f..1084c76 100644
--- a/src/donau/donau-httpd_get-charities.c
+++ b/src/donau/donau-httpd_get-charities.c
@@ -41,10 +41,10 @@
  *
  * @param cls closure
  */
-static void
+static enum GNUNET_GenericReturnValue
 charities_cb (
   void *cls,
-  struct DONAU_CharityPublicKeyP charity_pub,
+  const struct DONAU_CharityPublicKeyP charity_pub,
   const char *charity_name,
   const char *charity_url,
   struct TALER_Amount max_per_year,
@@ -70,6 +70,7 @@ charities_cb (
                                 &receipts_to_date),
         GNUNET_JSON_pack_int64 ("current_year",
                                 current_year))));
+  return GNUNET_OK;
 }
 
 
diff --git a/src/donau/donau-httpd_get-history.c 
b/src/donau/donau-httpd_get-history.c
index b911ca8..4ac2d77 100644
--- a/src/donau/donau-httpd_get-history.c
+++ b/src/donau/donau-httpd_get-history.c
@@ -41,7 +41,7 @@
  *
  * @param cls closure
  */
-static void
+enum GNUNET_GenericReturnValue
 history_cb (
   void *cls,
   unsigned long long charity_id,
@@ -61,6 +61,8 @@ history_cb (
                                 &final_amount),
         GNUNET_JSON_pack_int64 ("donation_year",
                                 donation_year))));
+
+  return GNUNET_OK;
 }
 
 
diff --git a/src/donau/donau-httpd_keys.c b/src/donau/donau-httpd_keys.c
index aaa0b8a..9527d01 100644
--- a/src/donau/donau-httpd_keys.c
+++ b/src/donau/donau-httpd_keys.c
@@ -1379,7 +1379,7 @@ setup_key_helpers (struct HelperState *hs)
  * @param donation_unit_pub public key of the donation_unit
  * @param h_donation_unit_pub hash of @a donation_unit_pub
  */
-static void
+static enum GNUNET_GenericReturnValue
 donation_unit_info_cb (
   void *cls,
   const struct DONAU_DonationUnitHashP *h_donation_unit_pub,
@@ -1434,6 +1434,7 @@ donation_unit_info_cb (
                                        dk,
                                        
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)
     );
+  return GNUNET_OK;
 }
 
 
diff --git a/src/donaudb/pg_get_charities.c b/src/donaudb/pg_get_charities.c
index f5c24dc..30c3404 100644
--- a/src/donaudb/pg_get_charities.c
+++ b/src/donaudb/pg_get_charities.c
@@ -42,9 +42,14 @@ struct GetCharitiesContext
   void *cb_cls;
 
   /**
-   * Flag set to #GNUNET_OK as long as everything is fine.
+   * Plugin context.
    */
-  enum GNUNET_GenericReturnValue status;
+  struct PostgresClosure *pg;
+
+  /**
+   * Number of results processed.
+   */
+  enum GNUNET_DB_QueryStatus qs;
 
 };
 
@@ -62,6 +67,7 @@ get_charities_cb (void *cls,
                   unsigned int num_results)
 {
   struct GetCharitiesContext *ctx = cls;
+  struct PostgresClosure *pg = ctx->pg;
 
   for (unsigned int i = 0; i < num_results; i++)
   {
@@ -79,11 +85,9 @@ get_charities_cb (void *cls,
                                     &charity_name),
       GNUNET_PQ_result_spec_string ("charity_url",
                                     &charity_url),
-      TALER_PQ_result_spec_amount ("max_per_year",
-                                   "EUR",  // TODO: Error if using 
TALER_PQ_RESULT_SPEC_AMOUNT
+      TALER_PQ_RESULT_SPEC_AMOUNT ("max_per_year",
                                    &max_per_year),
-      TALER_PQ_result_spec_amount ("receipts_to_date",
-                                   "EUR", // TODO: Error if using 
TALER_PQ_RESULT_SPEC_AMOUNT
+      TALER_PQ_RESULT_SPEC_AMOUNT ("receipts_to_date",
                                    &receipts_to_date),
       GNUNET_PQ_result_spec_uint64 ("current_year",
                                     &current_year),
@@ -96,17 +100,20 @@ get_charities_cb (void *cls,
                                   i))
     {
       GNUNET_break (0);
-      ctx->status = GNUNET_SYSERR;
+      ctx->qs = GNUNET_DB_STATUS_HARD_ERROR;
       return;
     }
-    ctx->cb (ctx->cb_cls,
-             charity_pub,
-             charity_name,
-             charity_url,
-             max_per_year,
-             receipts_to_date,
-             current_year);
-    GNUNET_PQ_cleanup_result (rs);
+
+    ctx->qs = i + 1;
+    if (GNUNET_OK !=
+        ctx->cb (ctx->cb_cls,
+                 charity_pub,
+                 charity_name,
+                 charity_url,
+                 max_per_year,
+                 receipts_to_date,
+                 current_year))
+      break;
   }
 }
 
@@ -117,13 +124,13 @@ DH_PG_get_charities (void *cls,
                      void *cb_cls)
 {
   struct PostgresClosure *pg = cls;
+  struct GNUNET_PQ_QueryParam params[] = {
+    GNUNET_PQ_query_param_end
+  };
   struct GetCharitiesContext ctx = {
     .cb = cb,
     .cb_cls = cb_cls,
-    .status = GNUNET_OK
-  };
-  struct GNUNET_PQ_QueryParam params[] = {
-    GNUNET_PQ_query_param_end
+    .pg = pg
   };
   enum GNUNET_DB_QueryStatus qs;
 
@@ -142,7 +149,7 @@ DH_PG_get_charities (void *cls,
                                              params,
                                              &get_charities_cb,
                                              &ctx);
-  if (GNUNET_OK != ctx.status)
-    return GNUNET_DB_STATUS_HARD_ERROR;
-  return qs;
+  if (qs <= 0)
+    return qs;
+  return ctx.qs;
 }
diff --git a/src/donaudb/pg_get_history.c b/src/donaudb/pg_get_history.c
index e7f28ac..88ef36e 100644
--- a/src/donaudb/pg_get_history.c
+++ b/src/donaudb/pg_get_history.c
@@ -42,9 +42,14 @@ struct GetHistoryContext
   void *cb_cls;
 
   /**
-   * Flag set to #GNUNET_OK as long as everything is fine.
+   * Plugin context.
    */
-  enum GNUNET_GenericReturnValue status;
+  struct PostgresClosure *pg;
+
+  /**
+   * Number of results processed.
+   */
+  enum GNUNET_DB_QueryStatus qs;
 
 };
 
@@ -62,6 +67,7 @@ get_history_cb (void *cls,
                 unsigned int num_results)
 {
   struct GetHistoryContext *ctx = cls;
+  struct PostgresClosure *pg = ctx->pg;
 
   for (unsigned int i = 0; i < num_results; i++)
   {
@@ -72,8 +78,7 @@ get_history_cb (void *cls,
     struct GNUNET_PQ_ResultSpec rs[] = {
       GNUNET_PQ_result_spec_uint64 ("charity_id",
                                     &charity_id),
-      TALER_PQ_result_spec_amount ("final_amount",
-                                   "EUR", // TODO: Error if using 
TALER_PQ_RESULT_SPEC_AMOUNT
+      TALER_PQ_RESULT_SPEC_AMOUNT ("final_amount",
                                    &final_amount),
       GNUNET_PQ_result_spec_uint64 ("donation_year",
                                     &donation_year),
@@ -86,14 +91,17 @@ get_history_cb (void *cls,
                                   i))
     {
       GNUNET_break (0);
-      ctx->status = GNUNET_SYSERR;
+      ctx->qs = GNUNET_DB_STATUS_HARD_ERROR;
       return;
     }
-    ctx->cb (ctx->cb_cls,
-             charity_id,
-             final_amount,
-             donation_year);
-    GNUNET_PQ_cleanup_result (rs);
+
+    ctx->qs = i + 1;
+    if (GNUNET_OK !=
+        ctx->cb (ctx->cb_cls,
+                 charity_id,
+                 final_amount,
+                 donation_year))
+      break;
   }
 }
 
@@ -104,13 +112,13 @@ DH_PG_get_history (void *cls,
                    void *cb_cls)
 {
   struct PostgresClosure *pg = cls;
+  struct GNUNET_PQ_QueryParam params[] = {
+    GNUNET_PQ_query_param_end
+  };
   struct GetHistoryContext ctx = {
     .cb = cb,
     .cb_cls = cb_cls,
-    .status = GNUNET_OK
-  };
-  struct GNUNET_PQ_QueryParam params[] = {
-    GNUNET_PQ_query_param_end
+    .pg = pg
   };
   enum GNUNET_DB_QueryStatus qs;
 
@@ -126,7 +134,7 @@ DH_PG_get_history (void *cls,
                                              params,
                                              &get_history_cb,
                                              &ctx);
-  if (GNUNET_OK != ctx.status)
-    return GNUNET_DB_STATUS_HARD_ERROR;
-  return qs;
+  if (qs <= 0)
+    return qs;
+  return ctx.qs;
 }
diff --git a/src/donaudb/pg_iterate_donation_units.c 
b/src/donaudb/pg_iterate_donation_units.c
index 77f5246..f227c5e 100644
--- a/src/donaudb/pg_iterate_donation_units.c
+++ b/src/donaudb/pg_iterate_donation_units.c
@@ -41,10 +41,15 @@ struct IterateDonationUnitsContext
    */
   void *cb_cls;
 
+  /**
+   * Plugin context.
+   */
+  struct PostgresClosure *pg;
+
   /**
    * Flag set to #GNUNET_OK as long as everything is fine.
    */
-  enum GNUNET_GenericReturnValue status;
+  enum GNUNET_DB_QueryStatus qs;
 
 };
 
@@ -61,6 +66,7 @@ iterate_donation_units_cb (void *cls,
                            unsigned int num_results)
 {
   struct IterateDonationUnitsContext *ctx = cls;
+  struct PostgresClosure *pg = ctx->pg;
 
   for (unsigned int i = 0; i < num_results; i++)
   {
@@ -76,8 +82,7 @@ iterate_donation_units_cb (void *cls,
                                               &donation_unit_pub),
       GNUNET_PQ_result_spec_uint64 ("validity_year",
                                     &validity_year),
-      TALER_PQ_result_spec_amount ("value",
-                                   "EUR", // TODO: Error if using 
TALER_PQ_RESULT_SPEC_AMOUNT
+      TALER_PQ_RESULT_SPEC_AMOUNT ("value",
                                    &value),
       GNUNET_PQ_result_spec_end
     };
@@ -88,15 +93,18 @@ iterate_donation_units_cb (void *cls,
                                   i))
     {
       GNUNET_break (0);
-      ctx->status = GNUNET_SYSERR;
+      ctx->qs = GNUNET_DB_STATUS_HARD_ERROR;
       return;
     }
-    ctx->cb (ctx->cb_cls,
-             &h_donation_unit_pub,
-             &donation_unit_pub,
-             validity_year,
-             &value);
-    GNUNET_PQ_cleanup_result (rs);
+
+    ctx->qs = i + 1;
+    if (GNUNET_OK !=
+        ctx->cb (ctx->cb_cls,
+                 &h_donation_unit_pub,
+                 &donation_unit_pub,
+                 validity_year,
+                 &value))
+      break;
   }
 }
 
@@ -107,13 +115,13 @@ DH_PG_iterate_donation_units (void *cls,
                               void *cb_cls)
 {
   struct PostgresClosure *pg = cls;
+  struct GNUNET_PQ_QueryParam params[] = {
+    GNUNET_PQ_query_param_end
+  };
   struct IterateDonationUnitsContext ctx = {
     .cb = cb,
     .cb_cls = cb_cls,
-    .status = GNUNET_OK
-  };
-  struct GNUNET_PQ_QueryParam params[] = {
-    GNUNET_PQ_query_param_end
+    .pg = pg
   };
   enum GNUNET_DB_QueryStatus qs;
 
@@ -130,7 +138,7 @@ DH_PG_iterate_donation_units (void *cls,
                                              params,
                                              &iterate_donation_units_cb,
                                              &ctx);
-  if (GNUNET_OK != ctx.status)
-    return GNUNET_DB_STATUS_HARD_ERROR;
-  return qs;
+  if (qs <= 0)
+    return qs;
+  return ctx.qs;
 }
diff --git a/src/include/donaudb_plugin.h b/src/include/donaudb_plugin.h
index c9028e2..3324637 100644
--- a/src/include/donaudb_plugin.h
+++ b/src/include/donaudb_plugin.h
@@ -109,9 +109,9 @@ struct DONAUDB_IssuedReceiptsMetaData
    */
   unsigned int num_sig;
 
-    /**
-   * Charity signature
-   */
+  /**
+ * Charity signature
+ */
   struct DONAU_BlindedDonationUnitSignature **blinded_sig;
 
 };
@@ -155,7 +155,7 @@ typedef void
  *
  * @param cls closure
  */
-typedef void
+typedef enum GNUNET_GenericReturnValue
 (*DONAUDB_IterateDonationUnitsCallback)(
   void *cls,
   const struct DONAU_DonationUnitHashP *h_donation_unit_pub,
@@ -168,7 +168,7 @@ typedef void
  *
  * @param cls closure
  */
-typedef void
+typedef enum GNUNET_GenericReturnValue
 (*DONAUDB_GetCharitiesCallback)(
   void *cls,
   const struct DONAU_CharityPublicKeyP charity_pub,
@@ -183,7 +183,7 @@ typedef void
  *
  * @param cls closure
  */
-typedef void
+typedef enum GNUNET_GenericReturnValue
 (*DONAUDB_GetHistoryCallback)(
   void *cls,
   unsigned long long charity_id,
@@ -533,14 +533,14 @@ struct DONAUDB_Plugin
     const struct DONAU_DonauSignatureP *donau_sig,
     const uint64_t donation_year);
 
-    /**
-    * Lookup issued receipts from the charity.
-    *
-    * @param cls closure
-    * @param bkp_hash the hash over the budi-key-pairs
-    * @param meta meta data about an issued request
-    * @return transaction status code
-    */
+  /**
+  * Lookup issued receipts from the charity.
+  *
+  * @param cls closure
+  * @param bkp_hash the hash over the budi-key-pairs
+  * @param meta meta data about an issued request
+  * @return transaction status code
+  */
   enum GNUNET_DB_QueryStatus
     (*lookup_issued_receipts) (
     void *cls,

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