summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2021-04-14 17:39:13 +0200
committerChristian Grothoff <christian@grothoff.org>2021-04-14 17:39:13 +0200
commit453d122c30b33c4481bb1624db722596ecf1453e (patch)
tree1f56b865d54b5a683c9818655d3f7b9f2a38b31e /src/lib
parent084a5f6685b603691571f5b6c9b8ad141657602a (diff)
downloadexchange-453d122c30b33c4481bb1624db722596ecf1453e.tar.gz
exchange-453d122c30b33c4481bb1624db722596ecf1453e.tar.bz2
exchange-453d122c30b33c4481bb1624db722596ecf1453e.zip
do not repeatedly append the same auditor signature
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/exchange_api_handle.c35
1 files changed, 24 insertions, 11 deletions
diff --git a/src/lib/exchange_api_handle.c b/src/lib/exchange_api_handle.c
index fbb33eb2..3adef7b4 100644
--- a/src/lib/exchange_api_handle.c
+++ b/src/lib/exchange_api_handle.c
@@ -803,7 +803,7 @@ decode_keys_json (const json_t *resp_obj,
json_array_foreach (denom_keys_array, index, denom_key_obj) {
struct TALER_EXCHANGE_DenomPublicKey dk;
- int found = GNUNET_NO;
+ bool found = false;
memset (&dk,
0,
@@ -822,11 +822,11 @@ decode_keys_json (const json_t *resp_obj,
if (0 == denoms_cmp (&dk,
&key_data->denom_keys[j]))
{
- found = GNUNET_YES;
+ found = true;
break;
}
}
- if (GNUNET_YES == found)
+ if (found)
{
/* 0:0:0 did not support /keys cherry picking */
TALER_LOG_DEBUG ("Skipping denomination key: already know it\n");
@@ -862,7 +862,7 @@ decode_keys_json (const json_t *resp_obj,
/* Merge with the existing auditor information we have (/keys cherry picking) */
json_array_foreach (auditors_array, index, auditor_info) {
struct TALER_EXCHANGE_AuditorInformation ai;
- int found = GNUNET_NO;
+ bool found = false;
memset (&ai,
0,
@@ -879,22 +879,35 @@ decode_keys_json (const json_t *resp_obj,
if (0 == GNUNET_memcmp (&ai.auditor_pub,
&aix->auditor_pub))
{
- found = GNUNET_YES;
+ found = true;
/* Merge denomination key signatures of downloaded /keys into existing
auditor information 'aix'. */
TALER_LOG_DEBUG (
"Merging %u new audited keys with %u known audited keys\n",
aix->num_denom_keys,
ai.num_denom_keys);
-
- GNUNET_array_concatenate (aix->denom_keys,
- aix->num_denom_keys,
- ai.denom_keys,
- ai.num_denom_keys);
+ for (unsigned int i = 0; i<ai.num_denom_keys; i++)
+ {
+ bool kfound = false;
+
+ for (unsigned int k = 0; k<aix->num_denom_keys; k++)
+ {
+ if (aix->denom_keys[k].denom_key_offset ==
+ ai.denom_keys[i].denom_key_offset)
+ {
+ kfound = true;
+ break;
+ }
+ }
+ if (! kfound)
+ GNUNET_array_append (aix->denom_keys,
+ aix->num_denom_keys,
+ ai.denom_keys[i]);
+ }
break;
}
}
- if (GNUNET_YES == found)
+ if (found)
{
GNUNET_array_grow (ai.denom_keys,
ai.num_denom_keys,