aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/include/taler_exchange_service.h42
-rw-r--r--src/lib/exchange_api_handle.c28
-rw-r--r--src/testing/testing_api_cmd_check_keys.c5
3 files changed, 52 insertions, 23 deletions
diff --git a/src/include/taler_exchange_service.h b/src/include/taler_exchange_service.h
index 4d8adcc81..441a93c7e 100644
--- a/src/include/taler_exchange_service.h
+++ b/src/include/taler_exchange_service.h
@@ -504,19 +504,49 @@ TALER_EXCHANGE_set_last_denom (struct TALER_EXCHANGE_Handle *exchange,
/**
+ * Flags for #TALER_EXCHANGE_check_keys_current().
+ */
+enum TALER_EXCHANGE_CheckKeysFlags
+{
+ /**
+ * No special options.
+ */
+ TALER_EXCHANGE_CKF_NONE,
+
+ /**
+ * Force downloading /keys now, even if /keys is still valid
+ * (that is, the period advertised by the exchange for re-downloads
+ * has not yet expired).
+ */
+ TALER_EXCHANGE_CKF_FORCE_DOWNLOAD = 1,
+
+ /**
+ * Pull all keys again, resetting the client state to the original state.
+ * Using this flag disables the incremental download, and also prevents using
+ * the context until the re-download has completed.
+ */
+ TALER_EXCHANGE_CKF_PULL_ALL_KEYS = 2,
+
+ /**
+ * Force downloading all keys now.
+ */
+ TALER_EXCHANGE_CKF_FORCE_ALL_NOW = TALER_EXCHANGE_CKF_FORCE_DOWNLOAD
+ | TALER_EXCHANGE_CKF_PULL_ALL_KEYS
+
+};
+
+
+/**
* Check if our current response for /keys is valid, and if
* not, trigger /keys 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 #MHS_INIT,
- * and all denoms will be redownloaded.
- * @return until when the response is current, 0 if we are re-downloading
+ * @param flags options controlling when to download what
+ * @return until when the existing response is current, 0 if we are re-downloading now
*/
struct GNUNET_TIME_Absolute
TALER_EXCHANGE_check_keys_current (struct TALER_EXCHANGE_Handle *exchange,
- int force_download,
- int pull_all_keys);
+ enum TALER_EXCHANGE_CheckKeysFlags flags);
/**
diff --git a/src/lib/exchange_api_handle.c b/src/lib/exchange_api_handle.c
index 374312a1b..f2d202559 100644
--- a/src/lib/exchange_api_handle.c
+++ b/src/lib/exchange_api_handle.c
@@ -801,7 +801,7 @@ denoms_cmp (struct TALER_EXCHANGE_DenomPublicKey *denom1,
* and store the data in the @a key_data.
*
* @param[in] resp_obj JSON object to parse
- * @param check_sig #GNUNET_YES if we should check the signature
+ * @param check_sig true if we should check the signature
* @param[out] key_data where to store the results we decoded
* @param[out] vc where to store version compatibility data
* @return #GNUNET_OK on success, #GNUNET_SYSERR on error
@@ -809,7 +809,7 @@ denoms_cmp (struct TALER_EXCHANGE_DenomPublicKey *denom1,
*/
static int
decode_keys_json (const json_t *resp_obj,
- int check_sig,
+ bool check_sig,
struct TALER_EXCHANGE_Keys *key_data,
enum TALER_EXCHANGE_VersionCompatibility *vc)
{
@@ -1195,27 +1195,27 @@ TALER_EXCHANGE_set_last_denom (struct TALER_EXCHANGE_Handle *exchange,
* 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 #MHS_INIT,
- * and all denoms will be redownloaded.
+ * @param flags options controlling when to download what
* @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 pull_all_keys)
+ enum TALER_EXCHANGE_CheckKeysFlags flags)
{
+ bool force_download = 0 != (flags & TALER_EXCHANGE_CKF_FORCE_DOWNLOAD);
+ bool pull_all_keys = 0 != (flags & TALER_EXCHANGE_CKF_PULL_ALL_KEYS);
+
if (NULL != exchange->kr)
return GNUNET_TIME_UNIT_ZERO_ABS;
- if (GNUNET_YES == pull_all_keys)
+ if (pull_all_keys)
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Forcing re-download of all exchange keys\n");
GNUNET_break (GNUNET_YES == force_download);
exchange->state = MHS_INIT;
}
- if ( (GNUNET_NO == force_download) &&
+ if ( (! force_download) &&
(0 < GNUNET_TIME_absolute_get_remaining (
exchange->key_data_expiration).rel_value_us) )
return exchange->key_data_expiration;
@@ -1320,7 +1320,7 @@ keys_completed_cb (void *cls,
/* Old auditors got just copied into new ones. */
if (GNUNET_OK !=
decode_keys_json (j,
- GNUNET_YES,
+ true,
&kd,
&vc))
{
@@ -1605,7 +1605,7 @@ deserialize_data (struct TALER_EXCHANGE_Handle *exchange,
sizeof (struct TALER_EXCHANGE_Keys));
if (GNUNET_OK !=
decode_keys_json (keys,
- GNUNET_NO,
+ false,
&key_data,
&vc))
{
@@ -2211,8 +2211,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);
+ TALER_EXCHANGE_CKF_NONE);
return &exchange->key_data;
}
@@ -2228,8 +2227,7 @@ json_t *
TALER_EXCHANGE_get_keys_raw (struct TALER_EXCHANGE_Handle *exchange)
{
(void) TALER_EXCHANGE_check_keys_current (exchange,
- GNUNET_NO,
- GNUNET_NO);
+ TALER_EXCHANGE_CKF_NONE);
return json_deep_copy (exchange->key_data_raw);
}
diff --git a/src/testing/testing_api_cmd_check_keys.c b/src/testing/testing_api_cmd_check_keys.c
index a0dca8cf9..20dbfb85b 100644
--- a/src/testing/testing_api_cmd_check_keys.c
+++ b/src/testing/testing_api_cmd_check_keys.c
@@ -128,8 +128,9 @@ check_keys_run (void *cls,
GNUNET_break
(0 == TALER_EXCHANGE_check_keys_current
(is->exchange,
- GNUNET_YES,
- cks->pull_all_keys).abs_value_us);
+ cks->pull_all_keys
+ ? TALER_EXCHANGE_CKF_FORCE_ALL_NOW
+ : TALER_EXCHANGE_CKF_FORCE_DOWNLOAD).abs_value_us);
return;
}