-towards API atomization

This commit is contained in:
Christian Grothoff 2023-06-21 08:02:36 +02:00
parent 17789253e9
commit a37a8d34d5
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC
3 changed files with 29 additions and 30 deletions

View File

@ -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);

View File

@ -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; 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,

View File

@ -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,
es->leh = TALER_AUDITOR_list_exchanges (
TALER_TESTING_interpreter_get_context (is),
auditor_url,
&exchanges_cb,
es);
if (NULL == es->leh)
{
GNUNET_break (0);