better api for parsing a denomination group
This commit is contained in:
parent
a6544069f9
commit
5633ad5a26
@ -2190,6 +2190,8 @@ finish_keys_response (struct TEH_KeyStateHandle *ksh)
|
||||
.age_mask = dk->meta.age_mask,
|
||||
};
|
||||
|
||||
memset (&meta.hash, 0, sizeof(meta.hash));
|
||||
|
||||
/* Search the group/JSON-blob for the key */
|
||||
GNUNET_CRYPTO_hash (&meta, sizeof(meta), &key);
|
||||
|
||||
|
@ -375,9 +375,6 @@ struct TALER_DenominationGroup
|
||||
struct TALER_DenomFeeSet fees;
|
||||
struct TALER_AgeMask age_mask;
|
||||
|
||||
// currency must be set prior to calling TALER_JSON_spec_denomination_group
|
||||
const char *currency;
|
||||
|
||||
// hash is/should be the XOR of all SHA-512 hashes of the public keys in this
|
||||
// group
|
||||
struct GNUNET_HashCode hash;
|
||||
@ -385,14 +382,15 @@ struct TALER_DenominationGroup
|
||||
|
||||
/**
|
||||
* Generate a parser for a group of denominations.
|
||||
* NOTE: group.currency MUST have been set prior to calling this function.
|
||||
*
|
||||
* @param field name of the field, maybe NULL
|
||||
* @param[in] field name of the field, maybe NULL
|
||||
* @param[in] currency name of the currency
|
||||
* @param[out] group denomination group information
|
||||
* @return corresponding field spec
|
||||
*/
|
||||
struct GNUNET_JSON_Specification
|
||||
TALER_JSON_spec_denomination_group (const char *field,
|
||||
const char *currency,
|
||||
struct TALER_DenominationGroup *group);
|
||||
|
||||
/**
|
||||
|
@ -250,16 +250,17 @@ parse_denomination_group (void *cls,
|
||||
{
|
||||
struct TALER_DenominationGroup *group = spec->ptr;
|
||||
const char *cipher;
|
||||
const char *currency = cls;
|
||||
bool age_mask_missing = false;
|
||||
bool has_age_restricted_suffix = false;
|
||||
struct GNUNET_JSON_Specification gspec[] = {
|
||||
GNUNET_JSON_spec_string ("cipher",
|
||||
&cipher),
|
||||
TALER_JSON_spec_amount ("value",
|
||||
group->currency,
|
||||
currency,
|
||||
&group->value),
|
||||
TALER_JSON_SPEC_DENOM_FEES ("fee",
|
||||
group->currency,
|
||||
currency,
|
||||
&group->fees),
|
||||
GNUNET_JSON_spec_mark_optional (
|
||||
GNUNET_JSON_spec_uint32 ("age_mask",
|
||||
@ -307,9 +308,11 @@ parse_denomination_group (void *cls,
|
||||
|
||||
struct GNUNET_JSON_Specification
|
||||
TALER_JSON_spec_denomination_group (const char *name,
|
||||
const char *currency,
|
||||
struct TALER_DenominationGroup *group)
|
||||
{
|
||||
struct GNUNET_JSON_Specification ret = {
|
||||
.cls = (void *) currency,
|
||||
.parser = &parse_denomination_group,
|
||||
.cleaner = NULL,
|
||||
.field = name,
|
||||
@ -318,7 +321,6 @@ TALER_JSON_spec_denomination_group (const char *name,
|
||||
.size_ptr = NULL,
|
||||
};
|
||||
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -952,9 +952,9 @@ decode_keys_json (const json_t *resp_obj,
|
||||
|
||||
// First, parse { cipher, fees, value, age_mask, hash } of the current
|
||||
// group.
|
||||
struct TALER_DenominationGroup group = { .currency = currency };
|
||||
struct TALER_DenominationGroup group = {0};
|
||||
struct GNUNET_JSON_Specification group_spec[] = {
|
||||
TALER_JSON_spec_denomination_group (NULL, &group),
|
||||
TALER_JSON_spec_denomination_group (NULL, currency, &group),
|
||||
GNUNET_JSON_spec_end ()
|
||||
};
|
||||
EXITIF (GNUNET_SYSERR ==
|
||||
|
Loading…
Reference in New Issue
Block a user