gnunet-svn
[Top][All Lists]
Advanced

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

[taler-exchange] branch master updated: -fix some FIXMEs


From: gnunet
Subject: [taler-exchange] branch master updated: -fix some FIXMEs
Date: Wed, 01 Jan 2025 16:59:01 +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 830d6e3e1 -fix some FIXMEs
830d6e3e1 is described below

commit 830d6e3e1ea20e57c2ef971f9c2a9e8e1738c1a0
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Wed Jan 1 16:58:55 2025 +0100

    -fix some FIXMEs
---
 src/bank-lib/taler-exchange-wire-gateway-client.c |   2 +-
 src/benchmark/taler-bank-benchmark.c              |   4 +-
 src/exchange/taler-exchange-aggregator.c          |  55 +++-------
 src/exchangedb/pg_find_aggregation_transient.c    | 123 ++++------------------
 src/exchangedb/pg_find_aggregation_transient.h    |  14 ++-
 src/include/taler_exchangedb_plugin.h             |  32 ++----
 src/kyclogic/kyclogic_api.c                       |   2 +-
 7 files changed, 57 insertions(+), 175 deletions(-)

diff --git a/src/bank-lib/taler-exchange-wire-gateway-client.c 
b/src/bank-lib/taler-exchange-wire-gateway-client.c
index a28962c73..f16f4fb0c 100644
--- a/src/bank-lib/taler-exchange-wire-gateway-client.c
+++ b/src/bank-lib/taler-exchange-wire-gateway-client.c
@@ -216,7 +216,7 @@ credit_history_cb (void *cls,
                  GNUNET_TIME_timestamp2s (cd->execution_date));
         break;
       case TALER_BANK_CT_WAD:
-        GNUNET_break (0); // FIXME
+        GNUNET_break (0); // FIXME-#7271 (support wad payments)
         break;
       }
     }
diff --git a/src/benchmark/taler-bank-benchmark.c 
b/src/benchmark/taler-bank-benchmark.c
index e337cbe53..d07cc5ae4 100644
--- a/src/benchmark/taler-bank-benchmark.c
+++ b/src/benchmark/taler-bank-benchmark.c
@@ -487,9 +487,9 @@ main (int argc,
     return EXIT_INVALIDARGUMENT;
   }
   if (NULL == exchange_bank_section)
-    exchange_bank_section = "exchange-account-1";
+    exchange_bank_section = (char *) "exchange-account-1";
   if (NULL == loglev)
-    loglev = "INFO";
+    loglev = (char *) "INFO";
   GNUNET_log_setup ("taler-bank-benchmark",
                     loglev,
                     logfile);
diff --git a/src/exchange/taler-exchange-aggregator.c 
b/src/exchange/taler-exchange-aggregator.c
index 3e8263942..25ed3a6da 100644
--- a/src/exchange/taler-exchange-aggregator.c
+++ b/src/exchange/taler-exchange-aggregator.c
@@ -1,6 +1,6 @@
 /*
   This file is part of TALER
-  Copyright (C) 2016-2024 Taler Systems SA
+  Copyright (C) 2016-2025 Taler Systems SA
 
   TALER is free software; you can redistribute it and/or modify it under the
   terms of the GNU Affero General Public License as published by the Free 
Software
@@ -1268,40 +1268,6 @@ run_shard (void *cls)
 }
 
 
-/**
- * Function called on transient aggregations matching
- * a particular hash of a payto URI.
- *
- * @param cls
- * @param payto_uri corresponding payto URI
- * @param wtid wire transfer identifier of transient aggregation
- * @param merchant_pub public key of the merchant
- * @param total amount aggregated so far
- * @return true to continue to iterate
- */
-static bool
-handle_transient_cb (
-  void *cls,
-  const struct TALER_FullPayto payto_uri,
-  const struct TALER_WireTransferIdentifierRawP *wtid,
-  const struct TALER_MerchantPublicKeyP *merchant_pub,
-  const struct TALER_Amount *total)
-{
-  struct AggregationUnit *au = cls;
-
-  au->payto_uri.full_payto
-    = GNUNET_strdup (payto_uri.full_payto);
-  TALER_full_payto_hash (payto_uri,
-                         &au->h_full_payto);
-  au->wtid = *wtid;
-  au->merchant_pub = *merchant_pub;
-  au->trans = *total;
-  au->have_transient = true;
-  do_aggregate (au);
-  return false;
-}
-
-
 static void
 drain_kyc_alerts (void *cls)
 {
@@ -1374,10 +1340,14 @@ drain_kyc_alerts (void *cls)
     }
 
     /* FIXME: should be replaced with a query that has a LIMIT 1... */
-    qs = db_plugin->find_aggregation_transient (db_plugin->cls,
-                                                &au->h_normalized_payto,
-                                                &handle_transient_cb,
-                                                au);
+    qs = db_plugin->find_aggregation_transient (
+      db_plugin->cls,
+      &au->h_normalized_payto,
+      &au->payto_uri,
+      &au->wtid,
+      &au->merchant_pub,
+      &au->trans);
+
     switch (qs)
     {
     case GNUNET_DB_STATUS_HARD_ERROR:
@@ -1399,8 +1369,11 @@ drain_kyc_alerts (void *cls)
       return;
     case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS:
       continue; /* while (1) */
-    default:
-      /* handle_transient_cb has various continuations... */
+    case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT:
+      TALER_full_payto_hash (au->payto_uri,
+                             &au->h_full_payto);
+      au->have_transient = true;
+      do_aggregate (au);
       return;
     }
     GNUNET_assert (0);
diff --git a/src/exchangedb/pg_find_aggregation_transient.c 
b/src/exchangedb/pg_find_aggregation_transient.c
index 813b3a81a..79e621b38 100644
--- a/src/exchangedb/pg_find_aggregation_transient.c
+++ b/src/exchangedb/pg_find_aggregation_transient.c
@@ -1,6 +1,6 @@
 /*
    This file is part of TALER
-   Copyright (C) 2022, 2024 Taler Systems SA
+   Copyright (C) 2022, 2024, 2025 Taler Systems SA
 
    TALER is free software; you can redistribute it and/or modify it under the
    terms of the GNU General Public License as published by the Free Software
@@ -26,107 +26,30 @@
 #include "pg_helper.h"
 
 
-/**
- * Closure for #get_refunds_cb().
- */
-struct FindAggregationTransientContext
-{
-  /**
-   * Function to call on each result.
-   */
-  TALER_EXCHANGEDB_TransientAggregationCallback cb;
-
-  /**
-   * Closure for @a cb.
-   */
-  void *cb_cls;
-
-  /**
-   * Plugin context.
-   */
-  struct PostgresClosure *pg;
-
-  /**
-   * Set to #GNUNET_SYSERR on error.
-   */
-  enum GNUNET_GenericReturnValue status;
-};
-
-
-/**
- * Function to be called with the results of a SELECT statement
- * that has returned @a num_results results.
- *
- * @param cls closure of type `struct SelectRefundContext *`
- * @param result the postgres result
- * @param num_results the number of results in @a result
- */
-static void
-get_transients_cb (void *cls,
-                   PGresult *result,
-                   unsigned int num_results)
-{
-  struct FindAggregationTransientContext *srctx = cls;
-  struct PostgresClosure *pg = srctx->pg;
-
-  for (unsigned int i = 0; i<num_results; i++)
-  {
-    struct TALER_Amount amount;
-    struct TALER_FullPayto payto_uri;
-    struct TALER_WireTransferIdentifierRawP wtid;
-    struct TALER_MerchantPublicKeyP merchant_pub;
-    struct GNUNET_PQ_ResultSpec rs[] = {
-      GNUNET_PQ_result_spec_auto_from_type ("merchant_pub",
-                                            &merchant_pub),
-      GNUNET_PQ_result_spec_auto_from_type ("wtid_raw",
-                                            &wtid),
-      GNUNET_PQ_result_spec_string ("payto_uri",
-                                    &payto_uri.full_payto),
-      TALER_PQ_RESULT_SPEC_AMOUNT ("amount",
-                                   &amount),
-      GNUNET_PQ_result_spec_end
-    };
-    bool cont;
-
-    if (GNUNET_OK !=
-        GNUNET_PQ_extract_result (result,
-                                  rs,
-                                  i))
-    {
-      GNUNET_break (0);
-      srctx->status = GNUNET_SYSERR;
-      return;
-    }
-    cont = srctx->cb (srctx->cb_cls,
-                      payto_uri,
-                      &wtid,
-                      &merchant_pub,
-                      &amount);
-    GNUNET_free (payto_uri.full_payto);
-    if (! cont)
-      break;
-  }
-}
-
-
 enum GNUNET_DB_QueryStatus
 TEH_PG_find_aggregation_transient (
   void *cls,
   const struct TALER_NormalizedPaytoHashP *h_payto,
-  TALER_EXCHANGEDB_TransientAggregationCallback cb,
-  void *cb_cls)
+  struct TALER_FullPayto *payto_uri,
+  struct TALER_WireTransferIdentifierRawP *wtid,
+  struct TALER_MerchantPublicKeyP *merchant_pub,
+  struct TALER_Amount *total)
 {
   struct PostgresClosure *pg = cls;
-  enum GNUNET_DB_QueryStatus qs;
   struct GNUNET_PQ_QueryParam params[] = {
     GNUNET_PQ_query_param_auto_from_type (h_payto),
     GNUNET_PQ_query_param_end
   };
-  struct FindAggregationTransientContext srctx = {
-    .cb = cb,
-    .cb_cls = cb_cls,
-    .pg = pg,
-    .status = GNUNET_OK
+  struct GNUNET_PQ_ResultSpec rs[] = {
+    GNUNET_PQ_result_spec_auto_from_type ("merchant_pub",
+                                          merchant_pub),
+    GNUNET_PQ_result_spec_auto_from_type ("wtid_raw",
+                                          wtid),
+    GNUNET_PQ_result_spec_string ("payto_uri",
+                                  &payto_uri->full_payto),
+    TALER_PQ_RESULT_SPEC_AMOUNT ("amount",
+                                 total),
+    GNUNET_PQ_result_spec_end
   };
 
   PREPARE (pg,
@@ -139,13 +62,11 @@ TEH_PG_find_aggregation_transient (
            " FROM wire_targets wt"
            " JOIN aggregation_transient atr"
            "   USING (wire_target_h_payto)"
-           " WHERE wt.h_normalized_payto=$1;");
-  qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn,
-                                             "find_transient_aggregations",
-                                             params,
-                                             &get_transients_cb,
-                                             &srctx);
-  if (GNUNET_SYSERR == srctx.status)
-    return GNUNET_DB_STATUS_HARD_ERROR;
-  return qs;
+           " WHERE wt.h_normalized_payto=$1"
+           " LIMIT 1;"); /* Note: there should really be only 1 match */
+  return GNUNET_PQ_eval_prepared_singleton_select (
+    pg->conn,
+    "find_transient_aggregations",
+    params,
+    rs);
 }
diff --git a/src/exchangedb/pg_find_aggregation_transient.h 
b/src/exchangedb/pg_find_aggregation_transient.h
index 2475dec3c..3943dd4e3 100644
--- a/src/exchangedb/pg_find_aggregation_transient.h
+++ b/src/exchangedb/pg_find_aggregation_transient.h
@@ -1,6 +1,6 @@
 /*
    This file is part of TALER
-   Copyright (C) 2022 Taler Systems SA
+   Copyright (C) 2022, 2025 Taler Systems SA
 
    TALER is free software; you can redistribute it and/or modify it under the
    terms of the GNU General Public License as published by the Free Software
@@ -29,15 +29,19 @@
  *
  * @param cls the @e cls of this struct with the plugin-specific state
  * @param h_payto destination of the wire transfer
- * @param cb function to call on each matching entry
- * @param cb_cls closure for @a cb
+ * @param[out] payto_uri corresponding payto URI, to be freed by caller
+ * @param[out] wtid wire transfer identifier of transient aggregation
+ * @param[out] merchant_pub public key of the merchant
+ * @param[out] total amount aggregated so far
  * @return transaction status
  */
 enum GNUNET_DB_QueryStatus
 TEH_PG_find_aggregation_transient (
   void *cls,
   const struct TALER_NormalizedPaytoHashP *h_payto,
-  TALER_EXCHANGEDB_TransientAggregationCallback cb,
-  void *cb_cls);
+  struct TALER_FullPayto *payto_uri,
+  struct TALER_WireTransferIdentifierRawP *wtid,
+  struct TALER_MerchantPublicKeyP *merchant_pub,
+  struct TALER_Amount *total);
 
 #endif
diff --git a/src/include/taler_exchangedb_plugin.h 
b/src/include/taler_exchangedb_plugin.h
index 242a154e6..84d246616 100644
--- a/src/include/taler_exchangedb_plugin.h
+++ b/src/include/taler_exchangedb_plugin.h
@@ -3329,26 +3329,6 @@ typedef enum GNUNET_GenericReturnValue
   const struct TALER_Amount *amount);
 
 
-/**
- * Function called on transient aggregations matching
- * a particular hash of a payto URI.
- *
- * @param cls
- * @param payto_uri corresponding payto URI
- * @param wtid wire transfer identifier of transient aggregation
- * @param merchant_pub public key of the merchant
- * @param total amount aggregated so far
- * @return true to continue iterating
- */
-typedef bool
-(*TALER_EXCHANGEDB_TransientAggregationCallback)(
-  void *cls,
-  const struct TALER_FullPayto payto_uri,
-  const struct TALER_WireTransferIdentifierRawP *wtid,
-  const struct TALER_MerchantPublicKeyP *merchant_pub,
-  const struct TALER_Amount *total);
-
-
 /**
  * Callback with data about a prepared wire transfer.
  *
@@ -4787,16 +4767,20 @@ struct TALER_EXCHANGEDB_Plugin
    *
    * @param cls the @e cls of this struct with the plugin-specific state
    * @param h_payto destination of the wire transfer
-   * @param cb function to call on each matching entry
-   * @param cb_cls closure for @a cb
+   * @param[out] payto_uri corresponding payto URI, to be freed by caller
+   * @param[out] wtid wire transfer identifier of transient aggregation
+   * @param[out] merchant_pub public key of the merchant
+   * @param[out] total amount aggregated so far
    * @return transaction status
    */
   enum GNUNET_DB_QueryStatus
     (*find_aggregation_transient)(
     void *cls,
     const struct TALER_NormalizedPaytoHashP *h_payto,
-    TALER_EXCHANGEDB_TransientAggregationCallback cb,
-    void *cb_cls);
+    struct TALER_FullPayto *payto_uri,
+    struct TALER_WireTransferIdentifierRawP *wtid,
+    struct TALER_MerchantPublicKeyP *merchant_pub,
+    struct TALER_Amount *total);
 
 
   /**
diff --git a/src/kyclogic/kyclogic_api.c b/src/kyclogic/kyclogic_api.c
index 31b69bd14..9e50a277e 100644
--- a/src/kyclogic/kyclogic_api.c
+++ b/src/kyclogic/kyclogic_api.c
@@ -1215,7 +1215,7 @@ append_voluntary_measure (
                        ms->check_name))
     return; /* very strange configuration */
 #if 0
-  /* FIXME: support vATTEST-9048 (this API in kyclogic!) */
+  /* FIXME: support vATTEST-#9048 (this API in kyclogic!) */
   // NOTE: need to convert ms to "KycRequirementInformation"
   // *and* in particular generate "id" values that
   // are then understood to refer to the voluntary measures

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