-more exchange API atomization

This commit is contained in:
Christian Grothoff 2023-06-22 20:42:10 +02:00
parent d4a65faad4
commit 999dae7c5d
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC
3 changed files with 18 additions and 20 deletions

View File

@ -6081,7 +6081,8 @@ struct TALER_EXCHANGE_PurseDeleteHandle;
* Asks the exchange to delete a purse. Will only succeed if * Asks the exchange to delete a purse. Will only succeed if
* the purse was not yet merged and did not yet time out. * the purse was not yet merged and did not yet time out.
* *
* @param exchange the exchange to interact with * @param ctx CURL context
* @param url exchange base URL
* @param purse_priv private key of the purse * @param purse_priv private key of the purse
* @param cb function to call with the exchange's result * @param cb function to call with the exchange's result
* @param cb_cls closure for @a cb * @param cb_cls closure for @a cb
@ -6089,7 +6090,8 @@ struct TALER_EXCHANGE_PurseDeleteHandle;
*/ */
struct TALER_EXCHANGE_PurseDeleteHandle * struct TALER_EXCHANGE_PurseDeleteHandle *
TALER_EXCHANGE_purse_delete ( TALER_EXCHANGE_purse_delete (
struct TALER_EXCHANGE_Handle *exchange, struct GNUNET_CURL_Context *ctx,
const char *url,
const struct TALER_PurseContractPrivateKeyP *purse_priv, const struct TALER_PurseContractPrivateKeyP *purse_priv,
TALER_EXCHANGE_PurseDeleteCallback cb, TALER_EXCHANGE_PurseDeleteCallback cb,
void *cb_cls); void *cb_cls);

View File

@ -40,11 +40,6 @@
struct TALER_EXCHANGE_PurseDeleteHandle struct TALER_EXCHANGE_PurseDeleteHandle
{ {
/**
* The connection to exchange this request handle will use
*/
struct TALER_EXCHANGE_Handle *exchange;
/** /**
* The url for this request. * The url for this request.
*/ */
@ -148,26 +143,23 @@ handle_purse_delete_finished (void *cls,
struct TALER_EXCHANGE_PurseDeleteHandle * struct TALER_EXCHANGE_PurseDeleteHandle *
TALER_EXCHANGE_purse_delete ( TALER_EXCHANGE_purse_delete (
struct TALER_EXCHANGE_Handle *exchange, struct GNUNET_CURL_Context *ctx,
const char *url,
const struct TALER_PurseContractPrivateKeyP *purse_priv, const struct TALER_PurseContractPrivateKeyP *purse_priv,
TALER_EXCHANGE_PurseDeleteCallback cb, TALER_EXCHANGE_PurseDeleteCallback cb,
void *cb_cls) void *cb_cls)
{ {
struct TALER_EXCHANGE_PurseDeleteHandle *pdh; struct TALER_EXCHANGE_PurseDeleteHandle *pdh;
struct GNUNET_CURL_Context *ctx;
CURL *eh; CURL *eh;
struct TALER_PurseContractPublicKeyP purse_pub; struct TALER_PurseContractPublicKeyP purse_pub;
struct TALER_PurseContractSignatureP purse_sig; struct TALER_PurseContractSignatureP purse_sig;
char arg_str[sizeof (purse_pub) * 2 + 32]; char arg_str[sizeof (purse_pub) * 2 + 32];
pdh = GNUNET_new (struct TALER_EXCHANGE_PurseDeleteHandle); pdh = GNUNET_new (struct TALER_EXCHANGE_PurseDeleteHandle);
pdh->exchange = exchange;
pdh->cb = cb; pdh->cb = cb;
pdh->cb_cls = cb_cls; pdh->cb_cls = cb_cls;
GNUNET_CRYPTO_eddsa_key_get_public (&purse_priv->eddsa_priv, GNUNET_CRYPTO_eddsa_key_get_public (&purse_priv->eddsa_priv,
&purse_pub.eddsa_pub); &purse_pub.eddsa_pub);
GNUNET_assert (GNUNET_YES ==
TEAH_handle_is_ready (exchange));
{ {
char pub_str[sizeof (purse_pub) * 2]; char pub_str[sizeof (purse_pub) * 2];
char *end; char *end;
@ -179,11 +171,12 @@ TALER_EXCHANGE_purse_delete (
*end = '\0'; *end = '\0';
GNUNET_snprintf (arg_str, GNUNET_snprintf (arg_str,
sizeof (arg_str), sizeof (arg_str),
"/purses/%s", "purses/%s",
pub_str); pub_str);
} }
pdh->url = TEAH_path_to_url (exchange, pdh->url = TALER_url_join (url,
arg_str); arg_str,
NULL);
if (NULL == pdh->url) if (NULL == pdh->url)
{ {
GNUNET_break (0); GNUNET_break (0);
@ -223,7 +216,6 @@ TALER_EXCHANGE_purse_delete (
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"URL for purse delete: `%s'\n", "URL for purse delete: `%s'\n",
pdh->url); pdh->url);
ctx = TEAH_handle_to_context (exchange);
pdh->job = GNUNET_CURL_job_add2 (ctx, pdh->job = GNUNET_CURL_job_add2 (ctx,
eh, eh,
pdh->xhdr, pdh->xhdr,

View File

@ -97,12 +97,15 @@ purse_delete_run (void *cls,
struct PurseDeleteState *pds = cls; struct PurseDeleteState *pds = cls;
const struct TALER_PurseContractPrivateKeyP *purse_priv; const struct TALER_PurseContractPrivateKeyP *purse_priv;
const struct TALER_TESTING_Command *ref; const struct TALER_TESTING_Command *ref;
struct TALER_EXCHANGE_Handle *exchange const char *exchange_url;
= TALER_TESTING_get_exchange (is);
(void) cmd; (void) cmd;
if (NULL == exchange) exchange_url = TALER_TESTING_get_exchange_url (is);
if (NULL == exchange_url)
{
GNUNET_break (0);
return; return;
}
ref = TALER_TESTING_interpreter_lookup_command (is, ref = TALER_TESTING_interpreter_lookup_command (is,
pds->purse_cmd); pds->purse_cmd);
if (NULL == ref) if (NULL == ref)
@ -121,7 +124,8 @@ purse_delete_run (void *cls,
} }
pds->is = is; pds->is = is;
pds->pdh = TALER_EXCHANGE_purse_delete ( pds->pdh = TALER_EXCHANGE_purse_delete (
exchange, TALER_TESTING_interpreter_get_context (is),
exchange_url,
purse_priv, purse_priv,
&purse_delete_cb, &purse_delete_cb,
pds); pds);