gnunet-svn
[Top][All Lists]
Advanced

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

[taler-exchange] 01/02: fix auditordb test and nested transaction use by


From: gnunet
Subject: [taler-exchange] 01/02: fix auditordb test and nested transaction use by auditors
Date: Wed, 21 Aug 2024 17:45:12 +0200

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

grothoff pushed a commit to branch master
in repository exchange.

commit dc6d8b08ec4a58f5d0cf88517559afc7d7305d68
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Wed Aug 21 17:39:11 2024 +0200

    fix auditordb test and nested transaction use by auditors
---
 contrib/wallet-core                            |  2 +-
 doc/prebuilt                                   |  2 +-
 src/auditor/report-lib.c                       |  3 +-
 src/auditor/taler-helper-auditor-aggregation.c | 54 +++++++++++++-------------
 src/auditor/taler-helper-auditor-coins.c       |  2 +
 src/auditordb/pg_get_balance.c                 | 17 ++++----
 src/auditordb/test_auditordb.c                 | 13 +++++--
 src/exchange/taler-exchange-httpd_coins_get.c  |  1 +
 src/exchangedb/pg_commit.c                     |  1 -
 src/exchangedb/pg_get_coin_transactions.c      | 36 +++++++++++------
 src/exchangedb/pg_get_coin_transactions.h      |  2 +
 src/exchangedb/test_exchangedb.c               |  2 +
 src/include/taler_exchangedb_plugin.h          |  2 +
 13 files changed, 81 insertions(+), 56 deletions(-)

diff --git a/contrib/wallet-core b/contrib/wallet-core
index 4c59144f6..5934e007f 160000
--- a/contrib/wallet-core
+++ b/contrib/wallet-core
@@ -1 +1 @@
-Subproject commit 4c59144f6e2a9b5748de42fa108a3a164cacc4ee
+Subproject commit 5934e007f637bd9834a811e67c0a030d7a59f2c0
diff --git a/doc/prebuilt b/doc/prebuilt
index ab2e09b5a..c1a885ac1 160000
--- a/doc/prebuilt
+++ b/doc/prebuilt
@@ -1 +1 @@
-Subproject commit ab2e09b5a3711ab04f1f77f79158cc006cab3195
+Subproject commit c1a885ac1f9d9b2fdef19a976bed01dab4f7d852
diff --git a/src/auditor/report-lib.c b/src/auditor/report-lib.c
index 6dd20d677..ad7b3d6f3 100644
--- a/src/auditor/report-lib.c
+++ b/src/auditor/report-lib.c
@@ -282,8 +282,7 @@ transact (TALER_ARL_Analysis analysis,
   else
   {
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                "Processing failed (or no changes), rolling back 
transaction\n")
-    ;
+                "Processing failed; rolling back transaction\n");
     TALER_ARL_adb->rollback (TALER_ARL_adb->cls);
     TALER_ARL_edb->rollback (TALER_ARL_edb->cls);
   }
diff --git a/src/auditor/taler-helper-auditor-aggregation.c 
b/src/auditor/taler-helper-auditor-aggregation.c
index 0011e3607..5b890a168 100644
--- a/src/auditor/taler-helper-auditor-aggregation.c
+++ b/src/auditor/taler-helper-auditor-aggregation.c
@@ -798,7 +798,9 @@ wire_transfer_information_cb (
   {
     struct TALER_Amount balance;
     struct TALER_DenominationHashP h_denom_pub;
+
     qs = TALER_ARL_edb->get_coin_transactions (TALER_ARL_edb->cls,
+                                               false,
                                                coin_pub,
                                                0,
                                                0,
@@ -1363,34 +1365,34 @@ analyze_aggregations (void *cls)
     GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == ac.qs);
     return ac.qs;
   }
-  if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qsx)
-  {
-    qs = TALER_ARL_adb->insert_balance (
-      TALER_ARL_adb->cls,
-      TALER_ARL_SET_AB (aggregation_total_wire_fee_revenue),
-      TALER_ARL_SET_AB (aggregation_total_arithmetic_delta_plus),
-      TALER_ARL_SET_AB (aggregation_total_arithmetic_delta_minus),
-      TALER_ARL_SET_AB (aggregation_total_bad_sig_loss),
-      TALER_ARL_SET_AB (aggregation_total_wire_out_delta_plus),
-      TALER_ARL_SET_AB (aggregation_total_wire_out_delta_minus),
-      TALER_ARL_SET_AB (aggregation_total_coin_delta_plus),
-      NULL);
-  }
-  else
+  qs = TALER_ARL_adb->insert_balance (
+    TALER_ARL_adb->cls,
+    TALER_ARL_SET_AB (aggregation_total_wire_fee_revenue),
+    TALER_ARL_SET_AB (aggregation_total_arithmetic_delta_plus),
+    TALER_ARL_SET_AB (aggregation_total_arithmetic_delta_minus),
+    TALER_ARL_SET_AB (aggregation_total_bad_sig_loss),
+    TALER_ARL_SET_AB (aggregation_total_wire_out_delta_plus),
+    TALER_ARL_SET_AB (aggregation_total_wire_out_delta_minus),
+    TALER_ARL_SET_AB (aggregation_total_coin_delta_plus),
+    NULL);
+  if (0 > qs)
   {
-    GNUNET_assert (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qsx);
-    qs = TALER_ARL_adb->update_balance (
-      TALER_ARL_adb->cls,
-      TALER_ARL_SET_AB (aggregation_total_wire_fee_revenue),
-      TALER_ARL_SET_AB (aggregation_total_arithmetic_delta_plus),
-      TALER_ARL_SET_AB (aggregation_total_arithmetic_delta_minus),
-      TALER_ARL_SET_AB (aggregation_total_bad_sig_loss),
-      TALER_ARL_SET_AB (aggregation_total_wire_out_delta_plus),
-      TALER_ARL_SET_AB (aggregation_total_wire_out_delta_minus),
-      TALER_ARL_SET_AB (aggregation_total_coin_delta_plus),
-      NULL);
+    GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+                "Failed to update auditor DB, not recording progress\n");
+    GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs);
+    return qs;
   }
-  if (0 >= qs)
+  qs = TALER_ARL_adb->update_balance (
+    TALER_ARL_adb->cls,
+    TALER_ARL_SET_AB (aggregation_total_wire_fee_revenue),
+    TALER_ARL_SET_AB (aggregation_total_arithmetic_delta_plus),
+    TALER_ARL_SET_AB (aggregation_total_arithmetic_delta_minus),
+    TALER_ARL_SET_AB (aggregation_total_bad_sig_loss),
+    TALER_ARL_SET_AB (aggregation_total_wire_out_delta_plus),
+    TALER_ARL_SET_AB (aggregation_total_wire_out_delta_minus),
+    TALER_ARL_SET_AB (aggregation_total_coin_delta_plus),
+    NULL);
+  if (0 > qs)
   {
     GNUNET_log (GNUNET_ERROR_TYPE_INFO,
                 "Failed to update auditor DB, not recording progress\n");
diff --git a/src/auditor/taler-helper-auditor-coins.c 
b/src/auditor/taler-helper-auditor-coins.c
index f21d9fca4..b3bc4cbe6 100644
--- a/src/auditor/taler-helper-auditor-coins.c
+++ b/src/auditor/taler-helper-auditor-coins.c
@@ -453,7 +453,9 @@ check_coin_history (const struct TALER_CoinSpendPublicKeyP 
*coin_pub,
   {
     struct TALER_Amount balance;
     struct TALER_DenominationHashP h_denom_pub;
+
     qs = TALER_ARL_edb->get_coin_transactions (TALER_ARL_edb->cls,
+                                               false,
                                                coin_pub,
                                                0,
                                                0,
diff --git a/src/auditordb/pg_get_balance.c b/src/auditordb/pg_get_balance.c
index 2bacbb507..7a0b7c38c 100644
--- a/src/auditordb/pg_get_balance.c
+++ b/src/auditordb/pg_get_balance.c
@@ -80,13 +80,12 @@ balance_cb (void *cls,
   GNUNET_assert (num_results <= ctx->len);
   for (unsigned int i = 0; i < num_results; i++)
   {
-    bool is_missing = false;
     struct GNUNET_PQ_ResultSpec rs[] = {
       GNUNET_PQ_result_spec_allow_null (
         TALER_PQ_result_spec_amount ("balance",
                                      pg->currency,
                                      ctx->dst[i]),
-        &is_missing),
+        NULL),
       GNUNET_PQ_result_spec_end
     };
 
@@ -99,11 +98,6 @@ balance_cb (void *cls,
       ctx->failure = true;
       return;
     }
-    if (is_missing)
-    {
-      TALER_amount_set_zero (pg->currency,
-                             ctx->dst[i]);
-    }
     ctx->off++;
   }
 }
@@ -124,9 +118,13 @@ TAH_PG_get_balance (void *cls,
   while (NULL != va_arg (ap,
                          const char *))
   {
+    struct TALER_Amount *dst;
+
     cnt++;
-    (void) va_arg (ap,
-                   struct TALER_Amount *);
+    dst = va_arg (ap,
+                  struct TALER_Amount *);
+    TALER_amount_set_zero (pg->currency,
+                           dst);
   }
   va_end (ap);
   {
@@ -148,7 +146,6 @@ TAH_PG_get_balance (void *cls,
 
     keys[0] = balance_key;
     dsts[0] = balance_value;
-
     va_start (ap,
               balance_value);
     while (off < cnt)
diff --git a/src/auditordb/test_auditordb.c b/src/auditordb/test_auditordb.c
index b72e95ab1..ab08a9bb7 100644
--- a/src/auditordb/test_auditordb.c
+++ b/src/auditordb/test_auditordb.c
@@ -106,6 +106,7 @@ static struct TALER_Amount reserve_profits;
 static enum GNUNET_GenericReturnValue
 select_historic_denom_revenue_result (
   void *cls,
+  uint64_t rowid,
   const struct TALER_DenominationHashP *denom_pub_hash2,
   struct GNUNET_TIME_Timestamp revenue_timestamp2,
   const struct TALER_Amount *revenue_balance2,
@@ -144,6 +145,7 @@ select_historic_denom_revenue_result (
 static enum GNUNET_GenericReturnValue
 select_historic_reserve_revenue_result (
   void *cls,
+  uint64_t rowid,
   struct GNUNET_TIME_Timestamp start_time2,
   struct GNUNET_TIME_Timestamp end_time2,
   const struct TALER_Amount *reserve_profits2)
@@ -414,6 +416,8 @@ run (void *cls)
   FAILIF (0 >=
           plugin->select_historic_denom_revenue (
             plugin->cls,
+            0,
+            1024,
             &select_historic_denom_revenue_result,
             NULL));
   GNUNET_log (GNUNET_ERROR_TYPE_INFO,
@@ -434,9 +438,12 @@ run (void *cls)
   GNUNET_log (GNUNET_ERROR_TYPE_INFO,
               "Test: select_historic_reserve_revenue\n");
   FAILIF (0 >=
-          plugin->select_historic_reserve_revenue (plugin->cls,
-                                                   
select_historic_reserve_revenue_result,
-                                                   NULL));
+          plugin->select_historic_reserve_revenue (
+            plugin->cls,
+            0,
+            1024,
+            &select_historic_reserve_revenue_result,
+            NULL));
 
   FAILIF (0 >
           plugin->commit (plugin->cls));
diff --git a/src/exchange/taler-exchange-httpd_coins_get.c 
b/src/exchange/taler-exchange-httpd_coins_get.c
index 8644395e5..7d61fd5a4 100644
--- a/src/exchange/taler-exchange-httpd_coins_get.c
+++ b/src/exchange/taler-exchange-httpd_coins_get.c
@@ -609,6 +609,7 @@ TEH_handler_coins_get (struct TEH_RequestContext *rc,
     enum GNUNET_DB_QueryStatus qs;
 
     qs = TEH_plugin->get_coin_transactions (TEH_plugin->cls,
+                                            true,
                                             coin_pub,
                                             start_off,
                                             etag_in,
diff --git a/src/exchangedb/pg_commit.c b/src/exchangedb/pg_commit.c
index 8c4f87c90..66adfd79b 100644
--- a/src/exchangedb/pg_commit.c
+++ b/src/exchangedb/pg_commit.c
@@ -45,7 +45,6 @@ TEH_PG_commit (void *cls)
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Committing transaction `%s'\n",
               pg->transaction_name);
-  /* used in #postgres_commit */
   PREPARE (pg,
            "do_commit",
            "COMMIT");
diff --git a/src/exchangedb/pg_get_coin_transactions.c 
b/src/exchangedb/pg_get_coin_transactions.c
index b2db935a5..56fb55db3 100644
--- a/src/exchangedb/pg_get_coin_transactions.c
+++ b/src/exchangedb/pg_get_coin_transactions.c
@@ -807,6 +807,7 @@ handle_history_entry (void *cls,
 enum GNUNET_DB_QueryStatus
 TEH_PG_get_coin_transactions (
   void *cls,
+  bool begin_transaction,
   const struct TALER_CoinSpendPublicKeyP *coin_pub,
   uint64_t start_off,
   uint64_t etag_in,
@@ -1010,7 +1011,7 @@ TEH_PG_get_coin_transactions (
            "   ON (denoms.denominations_serial = coins.denominations_serial)"
            " WHERE rcp.recoup_uuid=$2"
            "   AND coins.coin_pub=$1;");
-  /* Used in #postgres_get_coin_transactions() to obtain recoup transactions
+  /* Used to obtain recoup transactions
      for a refreshed coin */
   PREPARE (pg,
            "recoup_by_refreshed_coin",
@@ -1062,12 +1063,15 @@ TEH_PG_get_coin_transactions (
       GNUNET_PQ_result_spec_end
     };
 
-    if (GNUNET_OK !=
-        TEH_PG_start_read_committed (pg,
-                                     "get-coin-transactions"))
+    if (begin_transaction)
     {
-      GNUNET_break (0);
-      return GNUNET_DB_STATUS_HARD_ERROR;
+      if (GNUNET_OK !=
+          TEH_PG_start_read_committed (pg,
+                                       "get-coin-transactions"))
+      {
+        GNUNET_break (0);
+        return GNUNET_DB_STATUS_HARD_ERROR;
+      }
     }
     /* First only check the last item, to see if
        we even need to iterate */
@@ -1079,13 +1083,16 @@ TEH_PG_get_coin_transactions (
     switch (qs)
     {
     case GNUNET_DB_STATUS_HARD_ERROR:
-      TEH_PG_rollback (pg);
+      if (begin_transaction)
+        TEH_PG_rollback (pg);
       return qs;
     case GNUNET_DB_STATUS_SOFT_ERROR:
-      TEH_PG_rollback (pg);
+      if (begin_transaction)
+        TEH_PG_rollback (pg);
       continue;
     case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS:
-      TEH_PG_rollback (pg);
+      if (begin_transaction)
+        TEH_PG_rollback (pg);
       return qs;
     case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT:
       *etag_out = end;
@@ -1107,21 +1114,26 @@ TEH_PG_get_coin_transactions (
     switch (qs)
     {
     case GNUNET_DB_STATUS_HARD_ERROR:
-      TEH_PG_rollback (pg);
+      if (begin_transaction)
+        TEH_PG_rollback (pg);
       return qs;
     case GNUNET_DB_STATUS_SOFT_ERROR:
-      TEH_PG_rollback (pg);
+      if (begin_transaction)
+        TEH_PG_rollback (pg);
       continue;
     default:
       break;
     }
     if (chc.failed)
     {
-      TEH_PG_rollback (pg);
+      if (begin_transaction)
+        TEH_PG_rollback (pg);
       TEH_COMMON_free_coin_transaction_list (pg,
                                              chc.head);
       return GNUNET_DB_STATUS_SOFT_ERROR;
     }
+    if (! begin_transaction)
+      return GNUNET_DB_STATUS_SUCCESS_ONE_RESULT;
     qs = TEH_PG_commit (pg);
     switch (qs)
     {
diff --git a/src/exchangedb/pg_get_coin_transactions.h 
b/src/exchangedb/pg_get_coin_transactions.h
index 46e32e094..c844a51f2 100644
--- a/src/exchangedb/pg_get_coin_transactions.h
+++ b/src/exchangedb/pg_get_coin_transactions.h
@@ -34,6 +34,7 @@
  * to the last row ID of the given @a coin_pub in the coin history table.
  *
  * @param cls the @e cls of this struct with the plugin-specific state
+ * @param begin_transaction true to run this in its own transaction(s)
  * @param coin_pub coin to investigate
  * @param start_off starting offset from which on to return entries
  * @param etag_in up to this offset the client already has a response, do not
@@ -49,6 +50,7 @@
 enum GNUNET_DB_QueryStatus
 TEH_PG_get_coin_transactions (
   void *cls,
+  bool begin_transaction,
   const struct TALER_CoinSpendPublicKeyP *coin_pub,
   uint64_t start_off,
   uint64_t etag_in,
diff --git a/src/exchangedb/test_exchangedb.c b/src/exchangedb/test_exchangedb.c
index cb78d0544..4868e1501 100644
--- a/src/exchangedb/test_exchangedb.c
+++ b/src/exchangedb/test_exchangedb.c
@@ -1739,6 +1739,7 @@ run (void *cls)
       struct TALER_DenominationHashP h_denom_pub;
 
       qs = plugin->get_coin_transactions (plugin->cls,
+                                          true,
                                           &refresh.coin.coin_pub,
                                           0,
                                           0,
@@ -2004,6 +2005,7 @@ run (void *cls)
     struct TALER_DenominationHashP h_denom_pub;
 
     qs = plugin->get_coin_transactions (plugin->cls,
+                                        true,
                                         &refund.coin.coin_pub,
                                         0,
                                         0,
diff --git a/src/include/taler_exchangedb_plugin.h 
b/src/include/taler_exchangedb_plugin.h
index 2037fde95..e5c03cd72 100644
--- a/src/include/taler_exchangedb_plugin.h
+++ b/src/include/taler_exchangedb_plugin.h
@@ -4854,6 +4854,7 @@ struct TALER_EXCHANGEDB_Plugin
    * to the last row ID of the given @a coin_pub in the coin history table.
    *
    * @param cls the @e cls of this struct with the plugin-specific state
+   * @param begin_transaction true to run this in its own transaction(s)
    * @param coin_pub coin to investigate
    * @param start_off starting offset from which on to return entries
    * @param etag_in up to this offset the client already has a response, do not
@@ -4869,6 +4870,7 @@ struct TALER_EXCHANGEDB_Plugin
   enum GNUNET_DB_QueryStatus
     (*get_coin_transactions)(
     void *cls,
+    bool begin_transaction,
     const struct TALER_CoinSpendPublicKeyP *coin_pub,
     uint64_t start_off,
     uint64_t etag_in,

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