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