gnunet-svn
[Top][All Lists]
Advanced

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

[taler-exchange] 49/130: -more work on FTBFS issues


From: gnunet
Subject: [taler-exchange] 49/130: -more work on FTBFS issues
Date: Wed, 17 Nov 2021 12:24:57 +0100

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

grothoff pushed a commit to branch master
in repository exchange.

commit d83a65320af412bdc31c82397bb79a10a771166b
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Sat Oct 30 19:57:54 2021 +0200

    -more work on FTBFS issues
---
 src/exchange/taler-exchange-aggregator.c    | 81 ++++++++++-------------------
 src/exchangedb/plugin_exchangedb_postgres.c | 39 ++++++++------
 src/include/taler_exchangedb_plugin.h       | 11 ++--
 3 files changed, 58 insertions(+), 73 deletions(-)

diff --git a/src/exchange/taler-exchange-aggregator.c 
b/src/exchange/taler-exchange-aggregator.c
index 97d85c81..69c8dc5b 100644
--- a/src/exchange/taler-exchange-aggregator.c
+++ b/src/exchange/taler-exchange-aggregator.c
@@ -57,11 +57,6 @@ struct AggregationUnit
    */
   struct TALER_Amount wire_fee;
 
-  /**
-   * Hash of @e wire.
-   */
-  struct TALER_MerchantWireHash h_wire;
-
   /**
    * Wire transfer identifier we use.
    */
@@ -81,7 +76,12 @@ struct AggregationUnit
   /**
    * Wire details of the merchant.
    */
-  json_t *wire;
+  char *payto_uri;
+
+  /**
+   * Selected wire target for the aggregation.
+   */
+  uint64_t wire_target;
 
   /**
    * Exchange wire account to be used for the preparation and
@@ -216,8 +216,7 @@ static void
 cleanup_au (struct AggregationUnit *au)
 {
   GNUNET_assert (NULL != au);
-  if (NULL != au->wire)
-    json_decref (au->wire);
+  GNUNET_free (au->payto_uri);
   memset (au,
           0,
           sizeof (*au));
@@ -353,7 +352,8 @@ refund_by_coin_cb (void *cls,
  * @param amount_with_fee amount that was deposited including fee
  * @param deposit_fee amount the exchange gets to keep as transaction fees
  * @param h_contract_terms hash of the proposal data known to merchant and 
customer
- * @param wire target account for the wire transfer
+ * @param wire_target target account for the wire transfer
+ * @param payto_uri URI of the target account
  * @return transaction status code,  #GNUNET_DB_STATUS_SUCCESS_ONE_RESULT to 
continue to iterate
  */
 static enum GNUNET_DB_QueryStatus
@@ -364,7 +364,8 @@ deposit_cb (void *cls,
             const struct TALER_Amount *amount_with_fee,
             const struct TALER_Amount *deposit_fee,
             const struct TALER_PrivateContractHash *h_contract_terms,
-            const json_t *wire)
+            uint64_t wire_target,
+            const char *payto_uri)
 {
   struct AggregationUnit *au = cls;
   enum GNUNET_DB_QueryStatus qs;
@@ -416,21 +417,9 @@ deposit_cb (void *cls,
     }
   }
 
-  GNUNET_assert (NULL == au->wire);
-  if (NULL == (au->wire = json_incref ((json_t *) wire)))
-  {
-    GNUNET_break (0);
-    return GNUNET_DB_STATUS_HARD_ERROR;
-  }
-  if (GNUNET_OK !=
-      TALER_JSON_merchant_wire_signature_hash (wire,
-                                               &au->h_wire))
-  {
-    GNUNET_break (0);
-    json_decref (au->wire);
-    au->wire = NULL;
-    return GNUNET_DB_STATUS_HARD_ERROR;
-  }
+  GNUNET_assert (NULL == au->payto_uri);
+  au->payto_uri = GNUNET_strdup (payto_uri);
+  au->wire_target = wire_target;
   GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_NONCE,
                               &au->wtid,
                               sizeof (au->wtid));
@@ -439,20 +428,13 @@ deposit_cb (void *cls,
               TALER_B2S (&au->wtid),
               TALER_amount2s (amount_with_fee),
               (unsigned long long) row_id);
+  au->wa = TALER_EXCHANGEDB_find_account_by_payto_uri (payto_uri);
+  if (NULL == au->wa)
   {
-    char *url;
-
-    url = TALER_JSON_wire_to_payto (au->wire);
-    au->wa = TALER_EXCHANGEDB_find_account_by_payto_uri (url);
-    if (NULL == au->wa)
-    {
-      GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                  "No exchange account configured for `%s', please fix your 
setup to continue!\n",
-                  url);
-      GNUNET_free (url);
-      return GNUNET_DB_STATUS_HARD_ERROR;
-    }
-    GNUNET_free (url);
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                "No exchange account configured for `%s', please fix your 
setup to continue!\n",
+                payto_uri);
+    return GNUNET_DB_STATUS_HARD_ERROR;
   }
 
   /* make sure we have current fees */
@@ -789,7 +771,7 @@ run_aggregation (void *cls)
               "Found ready deposit for %s, aggregating\n",
               TALER_B2S (&au_active.merchant_pub));
   qs = db_plugin->iterate_matching_deposits (db_plugin->cls,
-                                             &au_active.h_wire,
+                                             au_active.wire_target,
                                              &au_active.merchant_pub,
                                              &aggregate_cb,
                                              &au_active,
@@ -908,19 +890,12 @@ run_aggregation (void *cls)
     void *buf;
     size_t buf_size;
 
-    {
-      char *url;
-
-      url = TALER_JSON_wire_to_payto (au_active.wire);
-      TALER_BANK_prepare_transfer (url,
-                                   &au_active.final_amount,
-                                   exchange_base_url,
-                                   &au_active.wtid,
-                                   &buf,
-                                   &buf_size);
-      GNUNET_free (url);
-    }
-
+    TALER_BANK_prepare_transfer (au_active.payto_uri,
+                                 &au_active.final_amount,
+                                 exchange_base_url,
+                                 &au_active.wtid,
+                                 &buf,
+                                 &buf_size);
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                 "Storing %u bytes of wire prepare data\n",
                 (unsigned int) buf_size);
@@ -937,7 +912,7 @@ run_aggregation (void *cls)
     qs = db_plugin->store_wire_transfer_out (db_plugin->cls,
                                              au_active.execution_time,
                                              &au_active.wtid,
-                                             au_active.wire,
+                                             au_active.wire_target,
                                              au_active.wa->section_name,
                                              &au_active.final_amount);
   cleanup_au (&au_active);
diff --git a/src/exchangedb/plugin_exchangedb_postgres.c 
b/src/exchangedb/plugin_exchangedb_postgres.c
index f15f9233..34ad5750 100644
--- a/src/exchangedb/plugin_exchangedb_postgres.c
+++ b/src/exchangedb/plugin_exchangedb_postgres.c
@@ -1023,12 +1023,17 @@ prepare_statements (struct PostgresClosure *pg)
                             ",denom.fee_deposit_val"
                             ",denom.fee_deposit_frac"
                             ",h_contract_terms"
-                            ",wire"
+                            ",payto_uri"
+                            ",wire_target_serial_id"
                             ",merchant_pub"
                             ",kc.coin_pub"
                             " FROM deposits"
-                            "    JOIN known_coins kc USING (known_coin_id)"
-                            "    JOIN denominations denom USING 
(denominations_serial)"
+                            "  JOIN wire_targets "
+                            "    USING (wire_target_serial_id)"
+                            "  JOIN known_coins kc"
+                            "    USING (known_coin_id)"
+                            "  JOIN denominations denom"
+                            "    USING (denominations_serial)"
                             " WHERE "
                             "       shard >= $2"
                             "   AND shard <= $3"
@@ -1056,7 +1061,7 @@ prepare_statements (struct PostgresClosure *pg)
                             "    JOIN denominations denom USING 
(denominations_serial)"
                             " WHERE"
                             "     merchant_pub=$1 AND"
-                            "     h_wire=$2 AND"
+                            "     wire_target_serial_id=$2 AND"
                             "     done=FALSE"
                             " ORDER BY wire_deadline ASC"
                             " LIMIT "
@@ -1225,7 +1230,7 @@ prepare_statements (struct PostgresClosure *pg)
                             "INSERT INTO wire_out "
                             "(execution_date"
                             ",wtid_raw"
-                            ",wire_target"
+                            ",wire_target_serial_id"
                             ",exchange_account_section"
                             ",amount_val"
                             ",amount_frac"
@@ -5109,10 +5114,13 @@ postgres_get_ready_deposit (void *cls,
   struct TALER_MerchantPublicKeyP merchant_pub;
   struct TALER_CoinSpendPublicKeyP coin_pub;
   uint64_t serial_id;
-  json_t *wire;
+  uint64_t wire_target;
+  char *payto_uri;
   struct GNUNET_PQ_ResultSpec rs[] = {
     GNUNET_PQ_result_spec_uint64 ("deposit_serial_id",
                                   &serial_id),
+    GNUNET_PQ_result_spec_uint64 ("wire_target_serial_id",
+                                  &wire_target),
     TALER_PQ_RESULT_SPEC_AMOUNT ("amount_with_fee",
                                  &amount_with_fee),
     TALER_PQ_RESULT_SPEC_AMOUNT ("fee_deposit",
@@ -5123,8 +5131,8 @@ postgres_get_ready_deposit (void *cls,
                                           &merchant_pub),
     GNUNET_PQ_result_spec_auto_from_type ("coin_pub",
                                           &coin_pub),
-    TALER_PQ_result_spec_json ("wire",
-                               &wire),
+    GNUNET_PQ_result_spec_string ("payto_uri",
+                                  &payto_uri),
     GNUNET_PQ_result_spec_end
   };
   enum GNUNET_DB_QueryStatus qs;
@@ -5151,7 +5159,8 @@ postgres_get_ready_deposit (void *cls,
                    &amount_with_fee,
                    &deposit_fee,
                    &h_contract_terms,
-                   wire);
+                   wire_target,
+                   payto_uri);
   GNUNET_PQ_cleanup_result (rs);
   return qs;
 }
@@ -5271,7 +5280,7 @@ match_deposit_cb (void *cls,
  * destination.  Those deposits must not already be "done".
  *
  * @param cls the @e cls of this struct with the plugin-specific state
- * @param h_wire destination of the wire transfer
+ * @param wire_target destination of the wire transfer
  * @param merchant_pub public key of the merchant
  * @param deposit_cb function to call for each deposit
  * @param deposit_cb_cls closure for @a deposit_cb
@@ -5282,7 +5291,7 @@ match_deposit_cb (void *cls,
 static enum GNUNET_DB_QueryStatus
 postgres_iterate_matching_deposits (
   void *cls,
-  const struct TALER_MerchantWireHash *h_wire,
+  uint64_t wire_target,
   const struct TALER_MerchantPublicKeyP *merchant_pub,
   TALER_EXCHANGEDB_MatchingDepositIterator deposit_cb,
   void *deposit_cb_cls,
@@ -5291,7 +5300,7 @@ postgres_iterate_matching_deposits (
   struct PostgresClosure *pg = cls;
   struct GNUNET_PQ_QueryParam params[] = {
     GNUNET_PQ_query_param_auto_from_type (merchant_pub),
-    GNUNET_PQ_query_param_auto_from_type (h_wire),
+    GNUNET_PQ_query_param_uint64 (&wire_target),
     GNUNET_PQ_query_param_end
   };
   struct MatchingDepositContext mdc = {
@@ -7733,7 +7742,7 @@ postgres_start_deferred_wire_out (void *cls)
  * @param cls closure
  * @param date time of the wire transfer
  * @param wtid subject of the wire transfer
- * @param wire_account details about the receiver account of the wire transfer
+ * @param wire_target identifies the receiver account of the wire transfer
  * @param exchange_account_section configuration section of the exchange 
specifying the
  *        exchange's bank account being used
  * @param amount amount that was transmitted
@@ -7744,7 +7753,7 @@ postgres_store_wire_transfer_out (
   void *cls,
   struct GNUNET_TIME_Absolute date,
   const struct TALER_WireTransferIdentifierRawP *wtid,
-  const json_t *wire_account,
+  uint64_t wire_target,
   const char *exchange_account_section,
   const struct TALER_Amount *amount)
 {
@@ -7752,7 +7761,7 @@ postgres_store_wire_transfer_out (
   struct GNUNET_PQ_QueryParam params[] = {
     TALER_PQ_query_param_absolute_time (&date),
     GNUNET_PQ_query_param_auto_from_type (wtid),
-    TALER_PQ_query_param_json (wire_account),
+    GNUNET_PQ_query_param_uint64 (&wire_target),
     GNUNET_PQ_query_param_string (exchange_account_section),
     TALER_PQ_query_param_amount (amount),
     GNUNET_PQ_query_param_end
diff --git a/src/include/taler_exchangedb_plugin.h 
b/src/include/taler_exchangedb_plugin.h
index 73a18ca6..4bc87330 100644
--- a/src/include/taler_exchangedb_plugin.h
+++ b/src/include/taler_exchangedb_plugin.h
@@ -1478,8 +1478,8 @@ typedef enum GNUNET_DB_QueryStatus
  * @param amount_with_fee amount that was deposited including fee
  * @param deposit_fee amount the exchange gets to keep as transaction fees
  * @param h_contract_terms hash of the proposal data known to merchant and 
customer
- * @param receiver_wire_account wire details for the merchant, includes
- *        'url' in payto://-format;
+ * @param wire_target unique ID of the receiver account
+ * @param payto_uri how to pay the merchant, URI in payto://-format;
  * @return transaction status code, #GNUNET_DB_STATUS_SUCCESS_ONE_RESULT to 
continue to iterate
  */
 typedef enum GNUNET_DB_QueryStatus
@@ -1491,7 +1491,8 @@ typedef enum GNUNET_DB_QueryStatus
   const struct TALER_Amount *amount_with_fee,
   const struct TALER_Amount *deposit_fee,
   const struct TALER_PrivateContractHash *h_contract_terms,
-  const json_t *receiver_wire_account);
+  uint64_t wire_target,
+  const char *payto_uri);
 
 
 /**
@@ -2796,7 +2797,7 @@ struct TALER_EXCHANGEDB_Plugin
   enum GNUNET_DB_QueryStatus
   (*iterate_matching_deposits)(
     void *cls,
-    const struct TALER_MerchantWireHash *h_wire,
+    uint64_t wire_target,
     const struct TALER_MerchantPublicKeyP *merchant_pub,
     TALER_EXCHANGEDB_MatchingDepositIterator deposit_cb,
     void *deposit_cb_cls,
@@ -3178,7 +3179,7 @@ struct TALER_EXCHANGEDB_Plugin
     void *cls,
     struct GNUNET_TIME_Absolute date,
     const struct TALER_WireTransferIdentifierRawP *wtid,
-    const json_t *wire_account,
+    uint64_t wire_target,
     const char *exchange_account_section,
     const struct TALER_Amount *amount);
 

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