gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-anastasis] 03/03: challenge array fix


From: gnunet
Subject: [taler-anastasis] 03/03: challenge array fix
Date: Wed, 17 Jun 2020 19:34:54 +0200

This is an automated email from the git hooks/post-receive script.

dennis-neufeld pushed a commit to branch master
in repository anastasis.

commit 0981886145a04d98b3e490b3f52cc48cf54c207e
Author: Dennis Neufeld <dennis.neufeld@students.bfh.ch>
AuthorDate: Wed Jun 17 17:34:24 2020 +0000

    challenge array fix
---
 src/cli/anastasis-cli-assembler.c | 33 +++++++++++++++++++++------------
 1 file changed, 21 insertions(+), 12 deletions(-)

diff --git a/src/cli/anastasis-cli-assembler.c 
b/src/cli/anastasis-cli-assembler.c
index 794c5fb..1fcf69e 100644
--- a/src/cli/anastasis-cli-assembler.c
+++ b/src/cli/anastasis-cli-assembler.c
@@ -35,11 +35,6 @@
  */
 static char *import_id;
 
-/**
- * Currency
- */
-static char *currency;
-
 /**
  * Global option '--import' to import json containing recovery document.
  */
@@ -316,10 +311,15 @@ read_keyboard_command (void *cls)
                      strlen ("policies")))
       && (characters == strlen ("policies")))
   {
+    // FIXME: Currency, maybe from config file?
+    char *currency = challenges[0].currency;
+    GNUNET_assert (NULL != currency);
+
     for (unsigned int i = 0; i < policies_length; i++)
     {
       // Calculate costs
       struct TALER_Amount cost;
+
       GNUNET_assert (GNUNET_OK == TALER_amount_get_zero (currency,
                                                          &cost));
       for (unsigned int j = 0; j < policies[i].uuids_length; j++)
@@ -487,10 +487,7 @@ config_cb (void *cls,
   }
 
   cs->cost = *question_cost;
-  if (NULL == currency)
-  {
-    currency = conf_currency;
-  }
+  cs->currency = conf_currency;
 }
 
 
@@ -521,9 +518,21 @@ challenge_cb (void *cls,
     return;
   }
   ci->cost = &cs->cost;
-  GNUNET_array_append (challenges,
-                       challenges_length,
-                       *ci);
+  ci->currency = cs->currency;
+
+  unsigned int contains = 0;
+  for (unsigned int i = 0; i < challenges_length; i++)
+  {
+    if (0 == uuid_compare (challenges[i].uuid, ci->uuid))
+    {
+      contains = 1;
+      break;
+    }
+  }
+  if (0 == contains)
+    GNUNET_array_append (challenges,
+                         challenges_length,
+                         *ci);
 }
 
 

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]