From 448a57d81e2a72d8117603ee60f60e5586c7d05d Mon Sep 17 00:00:00 2001 From: Marcello Stanisci Date: Wed, 16 Jan 2019 19:44:44 +0100 Subject: Extend tests. Give a way to force redownload (= no cherry picking) all /keys. --- src/lib/exchange_api_handle.c | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) (limited to 'src/lib/exchange_api_handle.c') diff --git a/src/lib/exchange_api_handle.c b/src/lib/exchange_api_handle.c index 8eedfd60a..bace2b47b 100644 --- a/src/lib/exchange_api_handle.c +++ b/src/lib/exchange_api_handle.c @@ -1021,20 +1021,34 @@ static void request_keys (void *cls); +/** + * Put the handle back to the init state. Might + * be useful to force-download all /keys. + * + * @param h exchange handle. + */ +void +TEAH_handle_reset (struct TALER_EXCHANGE_Handle *h); + /** * Check if our current response for /keys is valid, and if * not trigger download. * * @param exchange exchange to check keys for * @param force_download #GNUNET_YES to force download even if /keys is still valid + * @param pull_all_keys if GNUNET_YES, then the exchange state is reset to 'init', + * and all denoms will be redownloaded. * @return until when the response is current, 0 if we are re-downloading */ struct GNUNET_TIME_Absolute TALER_EXCHANGE_check_keys_current (struct TALER_EXCHANGE_Handle *exchange, - int force_download) + int force_download, + int pull_all_keys) { if (NULL != exchange->kr) return GNUNET_TIME_UNIT_ZERO_ABS; + if (GNUNET_YES == pull_all_keys) + TEAH_handle_reset (exchange); if ( (GNUNET_NO == force_download) && (0 < GNUNET_TIME_absolute_get_remaining (exchange->key_data_expiration).rel_value_us) ) return exchange->key_data_expiration; @@ -1218,6 +1232,18 @@ TEAH_handle_to_context (struct TALER_EXCHANGE_Handle *h) } +/** + * Put the handle back to the init state. Might + * be useful to force-download all /keys. + * + * @param h exchange handle. + */ +void +TEAH_handle_reset (struct TALER_EXCHANGE_Handle *h) +{ + h->state = MHS_INIT; +} + /** * Check if the handle is ready to process requests. * @@ -1903,6 +1929,7 @@ const struct TALER_EXCHANGE_Keys * TALER_EXCHANGE_get_keys (struct TALER_EXCHANGE_Handle *exchange) { (void) TALER_EXCHANGE_check_keys_current (exchange, + GNUNET_NO, GNUNET_NO); return &exchange->key_data; } @@ -1919,6 +1946,7 @@ json_t * TALER_EXCHANGE_get_keys_raw (struct TALER_EXCHANGE_Handle *exchange) { (void) TALER_EXCHANGE_check_keys_current (exchange, + GNUNET_NO, GNUNET_NO); return json_deep_copy (exchange->key_data_raw); } -- cgit v1.2.3