gnunet-svn
[Top][All Lists]
Advanced

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

[taler-exchange] branch master updated: -more exchange API atomization


From: gnunet
Subject: [taler-exchange] branch master updated: -more exchange API atomization
Date: Thu, 22 Jun 2023 20:37:18 +0200

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 d4a65faa -more exchange API atomization
d4a65faa is described below

commit d4a65faad4144e54633bf627ed7cf7bb64283924
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Thu Jun 22 20:37:15 2023 +0200

    -more exchange API atomization
---
 src/include/taler_exchange_service.h               | 12 +++++++----
 src/lib/exchange_api_contracts_get.c               | 24 +++++++---------------
 src/lib/exchange_api_reserves_get.c                |  3 ++-
 src/lib/exchange_api_reserves_get_attestable.c     | 24 ++++++----------------
 src/testing/testing_api_cmd_contract_get.c         | 14 ++++++++-----
 .../testing_api_cmd_reserve_get_attestable.c       | 21 +++++++++++--------
 6 files changed, 45 insertions(+), 53 deletions(-)

diff --git a/src/include/taler_exchange_service.h 
b/src/include/taler_exchange_service.h
index 80299cdf..9460fdbd 100644
--- a/src/include/taler_exchange_service.h
+++ b/src/include/taler_exchange_service.h
@@ -5785,7 +5785,8 @@ struct TALER_EXCHANGE_ContractsGetHandle;
 /**
  * Request information about a contract from the exchange.
  *
- * @param exchange exchange handle
+ * @param ctx CURL context
+ * @param url exchange base URL
  * @param contract_priv private key of the contract
  * @param cb function to call with the exchange's result
  * @param cb_cls closure for @a cb
@@ -5793,7 +5794,8 @@ struct TALER_EXCHANGE_ContractsGetHandle;
  */
 struct TALER_EXCHANGE_ContractsGetHandle *
 TALER_EXCHANGE_contract_get (
-  struct TALER_EXCHANGE_Handle *exchange,
+  struct GNUNET_CURL_Context *ctx,
+  const char *url,
   const struct TALER_ContractDiffiePrivateP *contract_priv,
   TALER_EXCHANGE_ContractGetCallback cb,
   void *cb_cls);
@@ -6637,7 +6639,8 @@ typedef void
 /**
  * Submit a request to get the list of attestable attributes for a reserve.
  *
- * @param exchange the exchange handle; the exchange must be ready to operate
+ * @param ctx CURL context
+ * @param url exchange base URL
  * @param reserve_pub public key of the reserve to get available attributes for
  * @param cb the callback to call when a reply for this request is available
  * @param cb_cls closure for the above callback
@@ -6646,7 +6649,8 @@ typedef void
  */
 struct TALER_EXCHANGE_ReservesGetAttestHandle *
 TALER_EXCHANGE_reserves_get_attestable (
-  struct TALER_EXCHANGE_Handle *exchange,
+  struct GNUNET_CURL_Context *ctx,
+  const char *url,
   const struct TALER_ReservePublicKeyP *reserve_pub,
   TALER_EXCHANGE_ReservesGetAttestCallback cb,
   void *cb_cls);
diff --git a/src/lib/exchange_api_contracts_get.c 
b/src/lib/exchange_api_contracts_get.c
index 8fd4ba1e..aece7733 100644
--- a/src/lib/exchange_api_contracts_get.c
+++ b/src/lib/exchange_api_contracts_get.c
@@ -38,11 +38,6 @@
 struct TALER_EXCHANGE_ContractsGetHandle
 {
 
-  /**
-   * The connection to exchange this request handle will use
-   */
-  struct TALER_EXCHANGE_Handle *exchange;
-
   /**
    * The url for this request.
    */
@@ -194,7 +189,8 @@ handle_contract_get_finished (void *cls,
 
 struct TALER_EXCHANGE_ContractsGetHandle *
 TALER_EXCHANGE_contract_get (
-  struct TALER_EXCHANGE_Handle *exchange,
+  struct GNUNET_CURL_Context *ctx,
+  const char *url,
   const struct TALER_ContractDiffiePrivateP *contract_priv,
   TALER_EXCHANGE_ContractGetCallback cb,
   void *cb_cls)
@@ -203,14 +199,7 @@ TALER_EXCHANGE_contract_get (
   CURL *eh;
   char arg_str[sizeof (cgh->cpub) * 2 + 48];
 
-  if (GNUNET_YES !=
-      TEAH_handle_is_ready (exchange))
-  {
-    GNUNET_break (0);
-    return NULL;
-  }
   cgh = GNUNET_new (struct TALER_EXCHANGE_ContractsGetHandle);
-  cgh->exchange = exchange;
   cgh->cb = cb;
   cgh->cb_cls = cb_cls;
   GNUNET_CRYPTO_ecdhe_key_get_public (&contract_priv->ecdhe_priv,
@@ -226,12 +215,13 @@ TALER_EXCHANGE_contract_get (
     *end = '\0';
     GNUNET_snprintf (arg_str,
                      sizeof (arg_str),
-                     "/contracts/%s",
+                     "contracts/%s",
                      cpub_str);
   }
 
-  cgh->url = TEAH_path_to_url (exchange,
-                               arg_str);
+  cgh->url = TALER_url_join (url,
+                             arg_str,
+                             NULL);
   if (NULL == cgh->url)
   {
     GNUNET_free (cgh);
@@ -247,7 +237,7 @@ TALER_EXCHANGE_contract_get (
     GNUNET_free (cgh);
     return NULL;
   }
-  cgh->job = GNUNET_CURL_job_add (TEAH_handle_to_context (exchange),
+  cgh->job = GNUNET_CURL_job_add (ctx,
                                   eh,
                                   &handle_contract_get_finished,
                                   cgh);
diff --git a/src/lib/exchange_api_reserves_get.c 
b/src/lib/exchange_api_reserves_get.c
index 73354023..7b59ba9a 100644
--- a/src/lib/exchange_api_reserves_get.c
+++ b/src/lib/exchange_api_reserves_get.c
@@ -226,7 +226,8 @@ TALER_EXCHANGE_reserves_get (
   rgh->cb_cls = cb_cls;
   rgh->reserve_pub = *reserve_pub;
   rgh->url = TALER_url_join (url,
-                             arg_str);
+                             arg_str,
+                             NULL);
   if (NULL == rgh->url)
   {
     GNUNET_free (rgh);
diff --git a/src/lib/exchange_api_reserves_get_attestable.c 
b/src/lib/exchange_api_reserves_get_attestable.c
index b272d478..f58e0592 100644
--- a/src/lib/exchange_api_reserves_get_attestable.c
+++ b/src/lib/exchange_api_reserves_get_attestable.c
@@ -38,11 +38,6 @@
 struct TALER_EXCHANGE_ReservesGetAttestHandle
 {
 
-  /**
-   * The connection to exchange this request handle will use
-   */
-  struct TALER_EXCHANGE_Handle *exchange;
-
   /**
    * The url for this request.
    */
@@ -211,22 +206,16 @@ handle_reserves_get_attestable_finished (void *cls,
 
 struct TALER_EXCHANGE_ReservesGetAttestHandle *
 TALER_EXCHANGE_reserves_get_attestable (
-  struct TALER_EXCHANGE_Handle *exchange,
+  struct GNUNET_CURL_Context *ctx,
+  const char *url,
   const struct TALER_ReservePublicKeyP *reserve_pub,
   TALER_EXCHANGE_ReservesGetAttestCallback cb,
   void *cb_cls)
 {
   struct TALER_EXCHANGE_ReservesGetAttestHandle *rgah;
-  struct GNUNET_CURL_Context *ctx;
   CURL *eh;
   char arg_str[sizeof (struct TALER_ReservePublicKeyP) * 2 + 32];
 
-  if (GNUNET_YES !=
-      TEAH_handle_is_ready (exchange))
-  {
-    GNUNET_break (0);
-    return NULL;
-  }
   {
     char pub_str[sizeof (struct TALER_ReservePublicKeyP) * 2];
     char *end;
@@ -239,16 +228,16 @@ TALER_EXCHANGE_reserves_get_attestable (
     *end = '\0';
     GNUNET_snprintf (arg_str,
                      sizeof (arg_str),
-                     "/reserves-attest/%s",
+                     "reserves-attest/%s",
                      pub_str);
   }
   rgah = GNUNET_new (struct TALER_EXCHANGE_ReservesGetAttestHandle);
-  rgah->exchange = exchange;
   rgah->cb = cb;
   rgah->cb_cls = cb_cls;
   rgah->reserve_pub = *reserve_pub;
-  rgah->url = TEAH_path_to_url (exchange,
-                                arg_str);
+  rgah->url = TALER_url_join (url,
+                              arg_str,
+                              NULL);
   if (NULL == rgah->url)
   {
     GNUNET_free (rgah);
@@ -262,7 +251,6 @@ TALER_EXCHANGE_reserves_get_attestable (
     GNUNET_free (rgah);
     return NULL;
   }
-  ctx = TEAH_handle_to_context (exchange);
   rgah->job = GNUNET_CURL_job_add (ctx,
                                    eh,
                                    &handle_reserves_get_attestable_finished,
diff --git a/src/testing/testing_api_cmd_contract_get.c 
b/src/testing/testing_api_cmd_contract_get.c
index adde3ed2..902ec4a4 100644
--- a/src/testing/testing_api_cmd_contract_get.c
+++ b/src/testing/testing_api_cmd_contract_get.c
@@ -190,13 +190,16 @@ get_run (void *cls,
   struct ContractGetState *ds = cls;
   const struct TALER_ContractDiffiePrivateP *contract_priv;
   const struct TALER_TESTING_Command *ref;
-  struct TALER_EXCHANGE_Handle *exchange
-    = TALER_TESTING_get_exchange (is);
+  const char *exchange_url;
 
   (void) cmd;
-  if (NULL == exchange)
-    return;
   ds->is = is;
+  exchange_url = TALER_TESTING_get_exchange_url (is);
+  if (NULL == exchange_url)
+  {
+    GNUNET_break (0);
+    return;
+  }
   ref = TALER_TESTING_interpreter_lookup_command (ds->is,
                                                   ds->contract_ref);
   GNUNET_assert (NULL != ref);
@@ -210,7 +213,8 @@ get_run (void *cls,
   }
   ds->contract_priv = *contract_priv;
   ds->dh = TALER_EXCHANGE_contract_get (
-    exchange,
+    TALER_TESTING_interpreter_get_context (is),
+    exchange_url,
     contract_priv,
     &get_cb,
     ds);
diff --git a/src/testing/testing_api_cmd_reserve_get_attestable.c 
b/src/testing/testing_api_cmd_reserve_get_attestable.c
index 75783e04..ed1eb135 100644
--- a/src/testing/testing_api_cmd_reserve_get_attestable.c
+++ b/src/testing/testing_api_cmd_reserve_get_attestable.c
@@ -125,12 +125,15 @@ get_attestable_run (void *cls,
   const struct TALER_TESTING_Command *ref_reserve;
   const struct TALER_ReservePrivateKeyP *reserve_priv;
   const struct TALER_ReservePublicKeyP *reserve_pub;
-  struct TALER_EXCHANGE_Handle *exchange
-    = TALER_TESTING_get_exchange (is);
+  const char *exchange_url;
 
-  if (NULL == exchange)
-    return;
   ss->is = is;
+  exchange_url = TALER_TESTING_get_exchange_url (is);
+  if (NULL == exchange_url)
+  {
+    GNUNET_break (0);
+    return;
+  }
   ref_reserve
     = TALER_TESTING_interpreter_lookup_command (is,
                                                 ss->reserve_reference);
@@ -162,10 +165,12 @@ get_attestable_run (void *cls,
     }
     ss->reserve_pub = *reserve_pub;
   }
-  ss->rgah = TALER_EXCHANGE_reserves_get_attestable (exchange,
-                                                     &ss->reserve_pub,
-                                                     
&reserve_get_attestable_cb,
-                                                     ss);
+  ss->rgah = TALER_EXCHANGE_reserves_get_attestable (
+    TALER_TESTING_interpreter_get_context (is),
+    exchange_url,
+    &ss->reserve_pub,
+    &reserve_get_attestable_cb,
+    ss);
 }
 
 

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