From ff8349e6e7b7a898f3a9b0f69c44fa4a2a6a3fb1 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Tue, 4 Jul 2023 15:37:34 +0200 Subject: more exchange API refactoring --- src/lib/exchange_api_handle.h | 174 +++--------------------------------------- 1 file changed, 9 insertions(+), 165 deletions(-) (limited to 'src/lib/exchange_api_handle.h') diff --git a/src/lib/exchange_api_handle.h b/src/lib/exchange_api_handle.h index 6b96e21eb..7c01b9a9f 100644 --- a/src/lib/exchange_api_handle.h +++ b/src/lib/exchange_api_handle.h @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2014, 2015 Taler Systems SA + Copyright (C) 2014, 2015, 2023 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -28,124 +28,6 @@ #include "taler_util.h" #include "taler_curl_lib.h" -/** - * Entry in DLL of auditors used by an exchange. - */ -struct TEAH_AuditorListEntry; - - -/** - * Stages of initialization for the `struct TALER_EXCHANGE_Handle` - */ -enum ExchangeHandleState -{ - /** - * Just allocated. - */ - MHS_INIT = 0, - - /** - * Obtained the exchange's certification data and keys. - */ - MHS_CERT = 1, - - /** - * Failed to initialize (fatal). - */ - MHS_FAILED = 2 -}; - - -/** - * Handle to the exchange - */ -struct TALER_EXCHANGE_Handle -{ - /** - * The context of this handle - */ - struct GNUNET_CURL_Context *ctx; - - /** - * The URL of the exchange (i.e. "http://exchange.taler.net/") - */ - char *url; - - /** - * Function to call with the exchange's certification data, - * NULL if this has already been done. - */ - TALER_EXCHANGE_CertificationCallback cert_cb; - - /** - * Closure to pass to @e cert_cb. - */ - void *cert_cb_cls; - - /** - * Data for the request to get the /keys of a exchange, - * NULL once we are past stage #MHS_INIT. - */ - struct KeysRequest *kr; - - /** - * Task for retrying /keys request. - */ - struct GNUNET_SCHEDULER_Task *retry_task; - - /** - * Raw key data of the exchange, only valid if - * @e handshake_complete is past stage #MHS_CERT. - */ - json_t *key_data_raw; - - /** - * Head of DLL of auditors of this exchange. - */ - struct TEAH_AuditorListEntry *auditors_head; - - /** - * Tail of DLL of auditors of this exchange. - */ - struct TEAH_AuditorListEntry *auditors_tail; - - /** - * Key data of the exchange, only valid if - * @e handshake_complete is past stage #MHS_CERT. - */ - struct TALER_EXCHANGE_Keys key_data; - - /** - * Retry /keys frequency. - */ - struct GNUNET_TIME_Relative retry_delay; - - /** - * When does @e key_data expire? - */ - struct GNUNET_TIME_Timestamp key_data_expiration; - - /** - * Number of subsequent failed requests to /keys. - * - * Used to compute the CURL timeout for the request. - */ - unsigned int keys_error_count; - - /** - * Number of subsequent failed requests to /wire. - * - * Used to compute the CURL timeout for the request. - */ - unsigned int wire_error_count; - - /** - * Stage of the exchange's initialization routines. - */ - enum ExchangeHandleState state; - -}; - /** * Function called for each auditor to give us a chance to possibly @@ -156,9 +38,10 @@ struct TALER_EXCHANGE_Handle * @param auditor_pub public key of the auditor */ typedef void -(*TEAH_AuditorCallback)(void *cls, - const char *auditor_url, - const struct TALER_AuditorPublicKeyP *auditor_pub); +(*TEAH_AuditorCallback)( + void *cls, + const char *auditor_url, + const struct TALER_AuditorPublicKeyP *auditor_pub); /** @@ -171,50 +54,11 @@ typedef void * @param ac_cls closure for @a ac */ void -TEAH_get_auditors_for_dc (struct TALER_EXCHANGE_Keys *keys, - TEAH_AuditorCallback ac, - void *ac_cls); - +TEAH_get_auditors_for_dc ( + struct TALER_EXCHANGE_Keys *keys, + TEAH_AuditorCallback ac, + void *ac_cls); -/** - * Get the context of a exchange. - * - * @param h the exchange handle to query - * @return ctx context to execute jobs in - */ -struct GNUNET_CURL_Context * -TEAH_handle_to_context (struct TALER_EXCHANGE_Handle *h); - - -/** - * Check if the handle is ready to process requests. - * - * @param h the exchange handle to query - * @return #GNUNET_YES if we are ready, #GNUNET_NO if not - */ -enum GNUNET_GenericReturnValue -TEAH_handle_is_ready (struct TALER_EXCHANGE_Handle *h); - -/** - * Check if the handle is ready to process requests. - * - * @param h the exchange handle to query - * @return #GNUNET_YES if we are ready, #GNUNET_NO if not - */ -enum GNUNET_GenericReturnValue -TEAH_handle_is_ready (struct TALER_EXCHANGE_Handle *h); - - -/** - * Obtain the URL to use for an API request. - * - * @param h the exchange handle to query - * @param path Taler API path (i.e. "/reserve/withdraw") - * @return the full URL to use with cURL - */ -char * -TEAH_path_to_url (struct TALER_EXCHANGE_Handle *h, - const char *path); /* end of exchange_api_handle.h */ #endif -- cgit v1.2.3