From a37a8d34d54cd91fba321a225ae626e8594c6a48 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Wed, 21 Jun 2023 08:02:36 +0200 Subject: -towards API atomization --- src/include/taler_auditor_service.h | 8 ++++--- src/lib/auditor_api_exchanges.c | 28 +++++++++---------------- src/testing/testing_api_cmd_auditor_exchanges.c | 23 ++++++++++++-------- 3 files changed, 29 insertions(+), 30 deletions(-) (limited to 'src') 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 @@ -44,11 +44,6 @@ struct TALER_AUDITOR_ListExchangesHandle { - /** - * The connection to auditor this request handle will use - */ - struct TALER_AUDITOR_Handle *auditor; - /** * The url for this request. */ @@ -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; iauditor = 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); -- cgit v1.2.3