Fix cherry picking.

Fix how the last denom issue date was set after
a redownloading of /keys.

Additionally, some styling fix also came along.
This commit is contained in:
Marcello Stanisci 2019-01-09 15:54:34 +01:00
parent ec58188446
commit f311ffb3ba
No known key found for this signature in database
GPG Key ID: 8D526861953F4C0F

View File

@ -502,14 +502,15 @@ parse_json_auditor (struct TALER_EXCHANGE_AuditorInformation *auditor,
/**
* Decode the JSON in @a resp_obj from the /keys response and store the data
* in the @a key_data.
* Decode the JSON in @a resp_obj from the /keys response
* 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[out] key_data where to store the results we decoded
* @param[out] where to store version compatibility data
* @return #GNUNET_OK on success, #GNUNET_SYSERR on error (malformed JSON)
* @return #GNUNET_OK on success, #GNUNET_SYSERR on error
* (malformed JSON)
*/
static int
decode_keys_json (const json_t *resp_obj,
@ -517,7 +518,6 @@ decode_keys_json (const json_t *resp_obj,
struct TALER_EXCHANGE_Keys *key_data,
enum TALER_EXCHANGE_VersionCompatibility *vc)
{
struct GNUNET_TIME_Absolute last_denom_issue_date;
struct TALER_ExchangeSignatureP sig;
struct GNUNET_HashContext *hash_context;
struct TALER_ExchangePublicKeyP pub;
@ -535,7 +535,8 @@ decode_keys_json (const json_t *resp_obj,
&key_data->master_pub),
GNUNET_JSON_spec_absolute_time ("list_issue_date",
&key_data->list_issue_date),
GNUNET_JSON_spec_relative_time ("reserve_closing_delay",
GNUNET_JSON_spec_relative_time
("reserve_closing_delay",
&key_data->reserve_closing_delay),
GNUNET_JSON_spec_end()
};
@ -624,7 +625,6 @@ decode_keys_json (const json_t *resp_obj,
/* parse the denomination keys, merging with the
possibly EXISTING array as required (/keys cherry picking) */
last_denom_issue_date.abs_value_us = 0LLU;
{
json_t *denom_keys_array;
json_t *denom_key_obj;
@ -669,13 +669,13 @@ decode_keys_json (const json_t *resp_obj,
key_data->denom_keys[key_data->num_denom_keys++] = dk;
/* Update "last_denom_issue_date" */
last_denom_issue_date
= GNUNET_TIME_absolute_max (last_denom_issue_date,
TALER_LOG_DEBUG ("Crawling DK 'valid_from': %s\n",
GNUNET_STRINGS_absolute_time_to_string (dk.valid_from));
key_data->last_denom_issue_date
= GNUNET_TIME_absolute_max (key_data->last_denom_issue_date,
dk.valid_from);
};
}
key_data->last_denom_issue_date = last_denom_issue_date;
/* parse the auditor information */
{
json_t *auditors_array;
@ -874,9 +874,11 @@ keys_completed_cb (void *cls,
/* We keep the denomination keys and auditor signatures from the
previous iteration (/keys cherry picking) */
kd.num_denom_keys = kd_old.num_denom_keys;
kd.last_denom_issue_date = kd_old.last_denom_issue_date;
GNUNET_array_grow (kd.denom_keys,
kd.denom_keys_size,
kd.num_denom_keys);
/* First make a shallow copy, we then need another pass for the RSA key... */
memcpy (kd.denom_keys,
kd_old.denom_keys,
@ -943,6 +945,10 @@ keys_completed_cb (void *cls,
break;
}
exchange->key_data = kd;
TALER_LOG_DEBUG ("Last DK issue date update to: %s\n",
GNUNET_STRINGS_absolute_time_to_string
(exchange->key_data.last_denom_issue_date));
if (MHD_HTTP_OK != response_code)
{
@ -1211,9 +1217,10 @@ deserialize_data (struct TALER_EXCHANGE_Handle *exchange,
* disk (to be used with #TALER_EXCHANGE_OPTION_DATA to more
* efficiently recover the state).
*
* @param exchange which exchange's key and wire data should be serialized
* @return NULL on error (i.e. no current data available); otherwise
* json object owned by the caller
* @param exchange which exchange's key and wire data should be
* serialized
* @return NULL on error (i.e. no current data available);
* otherwise JSON object owned by the caller
*/
json_t *
TALER_EXCHANGE_serialize_data (struct TALER_EXCHANGE_Handle *exchange)
@ -1461,6 +1468,8 @@ request_keys (void *cls)
{
char *arg;
TALER_LOG_DEBUG ("Last DK issue date (before GETting /keys): %s\n",
GNUNET_STRINGS_absolute_time_to_string (exchange->key_data.last_denom_issue_date));
GNUNET_asprintf (&arg,
"/keys?last_issue_date=%llu",
(unsigned long long) exchange->key_data.last_denom_issue_date.abs_value_us / 1000000LLU);