gnunet-svn
[Top][All Lists]
Advanced

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

[taler-anastasis] branch master updated: -return ref to respective provi


From: gnunet
Subject: [taler-anastasis] branch master updated: -return ref to respective providers
Date: Wed, 13 Apr 2022 22:33:49 +0200

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

grothoff pushed a commit to branch master
in repository anastasis.

The following commit(s) were added to refs/heads/master by this push:
     new 2c1d49c  -return ref to respective providers
2c1d49c is described below

commit 2c1d49cddefd079798e9ba1ddcb8d08bfbab9dd9
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Wed Apr 13 22:33:46 2022 +0200

    -return ref to respective providers
---
 src/cli/anastasis-cli-discover.c      |  3 +-
 src/include/anastasis_redux.h         |  4 ++-
 src/reducer/anastasis_api_discovery.c | 61 +++++++++++++++++++++++++++++++----
 3 files changed, 59 insertions(+), 9 deletions(-)

diff --git a/src/cli/anastasis-cli-discover.c b/src/cli/anastasis-cli-discover.c
index 2731ee8..f614165 100644
--- a/src/cli/anastasis-cli-discover.c
+++ b/src/cli/anastasis-cli-discover.c
@@ -92,7 +92,8 @@ print_policy_cb (void *cls,
                  uint32_t version,
                  json_int_t attribute_mask,
                  struct GNUNET_TIME_Timestamp server_time,
-                 const char *secret_name)
+                 const char *secret_name,
+                 const json_t *providers)
 {
   if (NULL == hcpd)
   {
diff --git a/src/include/anastasis_redux.h b/src/include/anastasis_redux.h
index a62b89e..2adb74b 100644
--- a/src/include/anastasis_redux.h
+++ b/src/include/anastasis_redux.h
@@ -135,6 +135,7 @@ struct ANASTASIS_PolicyDiscovery;
  *           present in the state that was used to locate this version
  * @param server_time when did the provider receive the upload
  * @param secret_name name the user assigned to the backup
+ * @param providers json array of providers with this policy
  */
 typedef void
 (*ANASTASIS_PolicyDiscoveryCallback)(void *cls,
@@ -143,7 +144,8 @@ typedef void
                                      uint32_t version,
                                      json_int_t attribute_mask,
                                      struct GNUNET_TIME_Timestamp server_time,
-                                     const char *secret_name);
+                                     const char *secret_name,
+                                     const json_t *providers);
 
 
 /**
diff --git a/src/reducer/anastasis_api_discovery.c 
b/src/reducer/anastasis_api_discovery.c
index 76731ad..72b7ca6 100644
--- a/src/reducer/anastasis_api_discovery.c
+++ b/src/reducer/anastasis_api_discovery.c
@@ -92,7 +92,8 @@ struct ANASTASIS_PolicyDiscovery
 
   /**
    * Map for duplicate detection, maps hashes of policies we
-   * have already seen to the value "dummy".
+   * have already seen to a json_array with all providers
+   * and versions corresponding to this policy hash.
    */
   struct GNUNET_CONTAINER_MultiHashMap *dd_map;
 
@@ -130,6 +131,8 @@ meta_cb (void *cls,
 {
   struct ProviderOperation *po = cls;
   struct ANASTASIS_PolicyDiscovery *pd = po->pd;
+  json_t *pa;
+  json_t *pe;
 
   if (NULL == recdoc_id)
   {
@@ -141,16 +144,32 @@ meta_cb (void *cls,
     GNUNET_free (po);
     return;
   }
-  if (GNUNET_YES ==
-      GNUNET_CONTAINER_multihashmap_contains (pd->dd_map,
-                                              recdoc_id))
+  pe = GNUNET_JSON_PACK (
+    GNUNET_JSON_pack_uint64 ("version",
+                             version),
+    GNUNET_JSON_pack_string ("url",
+                             po->provider_url));
+
+  pa = GNUNET_CONTAINER_multihashmap_get (pd->dd_map,
+                                          recdoc_id);
+  if (NULL != pa)
+  {
+    GNUNET_break (0 ==
+                  json_array_append_new (pa,
+                                         pe));
     return;
+  }
+  pa = json_array ();
+  GNUNET_assert (NULL != pa);
+  GNUNET_break (0 ==
+                json_array_append_new (pa,
+                                       pe));
   GNUNET_assert (
     GNUNET_OK ==
     GNUNET_CONTAINER_multihashmap_put (
       pd->dd_map,
       recdoc_id,
-      "dummy",
+      pa,
       GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
   pd->cb (pd->cb_cls,
           recdoc_id,
@@ -158,7 +177,8 @@ meta_cb (void *cls,
           version,
           po->attribute_mask,
           server_time,
-          secret_name);
+          secret_name,
+          pe);
 }
 
 
@@ -309,7 +329,9 @@ ANASTASIS_policy_discovery_start (const json_t *state,
     size_t index;
     json_t *required_attribute;
 
-    json_array_foreach (required_attributes, index, required_attribute)
+    json_array_foreach (required_attributes,
+                        index,
+                        required_attribute)
     {
       const char *name;
       int optional = false;
@@ -417,6 +439,28 @@ ANASTASIS_policy_discovery_more (struct 
ANASTASIS_PolicyDiscovery *pd,
 }
 
 
+/**
+ * Free JSON Arrays from our hash map.
+ *
+ * @param cls NULL
+ * @param key ignored
+ * @param value `json_t *` to free
+ * @return #GNUNET_OK
+ */
+static enum GNUNET_GenericReturnValue
+free_dd_json (void *cls,
+              const struct GNUNET_HashCode *key,
+              void *value)
+{
+  json_t *j = value;
+
+  (void) cls;
+  (void) key;
+  json_decref (j);
+  return GNUNET_OK;
+}
+
+
 void
 ANASTASIS_policy_discovery_stop (struct ANASTASIS_PolicyDiscovery *pd)
 {
@@ -431,6 +475,9 @@ ANASTASIS_policy_discovery_stop (struct 
ANASTASIS_PolicyDiscovery *pd)
     GNUNET_free (po->provider_url);
     GNUNET_free (po);
   }
+  GNUNET_CONTAINER_multihashmap_iterate (pd->dd_map,
+                                         &free_dd_json,
+                                         NULL);
   GNUNET_CONTAINER_multihashmap_destroy (pd->dd_map);
   json_decref (pd->state);
   GNUNET_free (pd);

-- 
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]