summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2023-06-21 08:02:36 +0200
committerChristian Grothoff <christian@grothoff.org>2023-06-21 08:02:36 +0200
commita37a8d34d54cd91fba321a225ae626e8594c6a48 (patch)
tree4403bc4b76adb2974d15e1b33d6a6dfe7e443823 /src
parent17789253e9194c66bb9ddb081425a35212ac7bf3 (diff)
downloadexchange-a37a8d34d54cd91fba321a225ae626e8594c6a48.tar.gz
exchange-a37a8d34d54cd91fba321a225ae626e8594c6a48.tar.bz2
exchange-a37a8d34d54cd91fba321a225ae626e8594c6a48.zip
-towards API atomization
Diffstat (limited to 'src')
-rw-r--r--src/include/taler_auditor_service.h8
-rw-r--r--src/lib/auditor_api_exchanges.c28
-rw-r--r--src/testing/testing_api_cmd_auditor_exchanges.c23
3 files changed, 29 insertions, 30 deletions
diff --git a/src/include/taler_auditor_service.h b/src/include/taler_auditor_service.h
index 9d721550b..5ee41c3b1 100644
--- a/src/include/taler_auditor_service.h
+++ b/src/include/taler_auditor_service.h
@@ -211,7 +211,7 @@ struct TALER_AUDITOR_Handle;
* interactions with the auditor will be checked to be signed
* (where appropriate) by the respective master key.
*
- * @param ctx the context
+ * @param ctx the context for CURL requests
* @param url HTTP base URL for the auditor
* @param version_cb function to call with the auditor's version information
* @param version_cb_cls closure for @a version_cb
@@ -412,14 +412,16 @@ typedef void
* auditor's response. If the auditor's reply is not
* well-formed, we return an HTTP status code of zero to @a cb.
*
- * @param auditor the auditor handle; the auditor must be ready to operate
+ * @param ctx the context for CURL requests
+ * @param url HTTP base URL for the auditor
* @param cb the callback to call when a reply for this request is available
* @param cb_cls closure for the above callback
* @return a handle for this request; NULL if the inputs are invalid (i.e.
* signatures fail to verify). In this case, the callback is not called.
*/
struct TALER_AUDITOR_ListExchangesHandle *
-TALER_AUDITOR_list_exchanges (struct TALER_AUDITOR_Handle *auditor,
+TALER_AUDITOR_list_exchanges (struct GNUNET_CURL_Context *ctx,
+ const char *url,
TALER_AUDITOR_ListExchangesResultCallback cb,
void *cb_cls);
diff --git a/src/lib/auditor_api_exchanges.c b/src/lib/auditor_api_exchanges.c
index 9f35c7077..8acf59467 100644
--- a/src/lib/auditor_api_exchanges.c
+++ b/src/lib/auditor_api_exchanges.c
@@ -45,11 +45,6 @@ struct TALER_AUDITOR_ListExchangesHandle
{
/**
- * The connection to auditor this request handle will use
- */
- struct TALER_AUDITOR_Handle *auditor;
-
- /**
* The url for this request.
*/
char *url;
@@ -122,14 +117,15 @@ handle_exchanges_finished (void *cls,
}
{
struct TALER_AUDITOR_ExchangeInfo ei[GNUNET_NZL (ja_len)];
- bool ok;
+ bool ok = true;
- ok = true;
for (unsigned int i = 0; i<ja_len; i++)
{
struct GNUNET_JSON_Specification spec[] = {
- GNUNET_JSON_spec_fixed_auto ("master_pub", &ei[i].master_pub),
- GNUNET_JSON_spec_string ("exchange_url", &ei[i].exchange_url),
+ GNUNET_JSON_spec_fixed_auto ("master_pub",
+ &ei[i].master_pub),
+ GNUNET_JSON_spec_string ("exchange_url",
+ &ei[i].exchange_url),
GNUNET_JSON_spec_end ()
};
@@ -192,23 +188,20 @@ handle_exchanges_finished (void *cls,
struct TALER_AUDITOR_ListExchangesHandle *
-TALER_AUDITOR_list_exchanges (struct TALER_AUDITOR_Handle *auditor,
+TALER_AUDITOR_list_exchanges (struct GNUNET_CURL_Context *ctx,
+ const char *url,
TALER_AUDITOR_ListExchangesResultCallback cb,
void *cb_cls)
{
struct TALER_AUDITOR_ListExchangesHandle *leh;
- struct GNUNET_CURL_Context *ctx;
CURL *eh;
- GNUNET_assert (GNUNET_YES ==
- TALER_AUDITOR_handle_is_ready_ (auditor));
-
leh = GNUNET_new (struct TALER_AUDITOR_ListExchangesHandle);
- leh->auditor = auditor;
leh->cb = cb;
leh->cb_cls = cb_cls;
- leh->url = TALER_AUDITOR_path_to_url_ (auditor,
- "/exchanges");
+ leh->url = TALER_url_join (url,
+ "exchanges",
+ NULL);
if (NULL == leh->url)
{
GNUNET_free (leh);
@@ -225,7 +218,6 @@ TALER_AUDITOR_list_exchanges (struct TALER_AUDITOR_Handle *auditor,
GNUNET_free (leh);
return NULL;
}
- ctx = TALER_AUDITOR_handle_to_context_ (auditor);
leh->job = GNUNET_CURL_job_add (ctx,
eh,
&handle_exchanges_finished,
diff --git a/src/testing/testing_api_cmd_auditor_exchanges.c b/src/testing/testing_api_cmd_auditor_exchanges.c
index ea9ace3e4..aa9a1bfb7 100644
--- a/src/testing/testing_api_cmd_auditor_exchanges.c
+++ b/src/testing/testing_api_cmd_auditor_exchanges.c
@@ -208,7 +208,7 @@ exchanges_run (void *cls,
{
struct ExchangesState *es = cls;
const struct TALER_TESTING_Command *auditor_cmd;
- struct TALER_AUDITOR_Handle *auditor;
+ const char *auditor_url;
(void) cmd;
auditor_cmd = TALER_TESTING_interpreter_get_command (is,
@@ -219,15 +219,20 @@ exchanges_run (void *cls,
TALER_TESTING_interpreter_fail (is);
return;
}
- GNUNET_assert (GNUNET_OK ==
- TALER_TESTING_get_trait_auditor (auditor_cmd,
- &auditor));
-
+ if (GNUNET_OK !=
+ TALER_TESTING_get_trait_auditor_url (auditor_cmd,
+ &auditor_url))
+ {
+ GNUNET_break (0);
+ TALER_TESTING_interpreter_fail (is);
+ return;
+ }
es->is = is;
- es->leh = TALER_AUDITOR_list_exchanges (auditor,
- &exchanges_cb,
- es);
-
+ es->leh = TALER_AUDITOR_list_exchanges (
+ TALER_TESTING_interpreter_get_context (is),
+ auditor_url,
+ &exchanges_cb,
+ es);
if (NULL == es->leh)
{
GNUNET_break (0);