summaryrefslogtreecommitdiff
path: root/src/lib/exchange_api_handle.c
diff options
context:
space:
mode:
authorMarcello Stanisci <stanisci.m@gmail.com>2019-01-16 19:44:44 +0100
committerMarcello Stanisci <stanisci.m@gmail.com>2019-01-16 19:44:44 +0100
commit448a57d81e2a72d8117603ee60f60e5586c7d05d (patch)
treeeb21973b67387378248d8698766ea3016ae1438c /src/lib/exchange_api_handle.c
parentece3a9bfdb6419d344abeb6c78c167b80d81fb6b (diff)
downloadexchange-448a57d81e2a72d8117603ee60f60e5586c7d05d.tar.gz
exchange-448a57d81e2a72d8117603ee60f60e5586c7d05d.tar.bz2
exchange-448a57d81e2a72d8117603ee60f60e5586c7d05d.zip
Extend tests.
Give a way to force redownload (= no cherry picking) all /keys.
Diffstat (limited to 'src/lib/exchange_api_handle.c')
-rw-r--r--src/lib/exchange_api_handle.c30
1 files changed, 29 insertions, 1 deletions
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
@@ -1022,19 +1022,33 @@ 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;
@@ -1219,6 +1233,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.
*
* @param h the exchange handle to query
@@ -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);
}