gnunet-svn
[Top][All Lists]
Advanced

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

[gnunet] branch master updated: NAMESTORE: Massaging new bulk API


From: gnunet
Subject: [gnunet] branch master updated: NAMESTORE: Massaging new bulk API
Date: Tue, 04 Oct 2022 15:43:31 +0200

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

martin-schanzenbach pushed a commit to branch master
in repository gnunet.

The following commit(s) were added to refs/heads/master by this push:
     new 1741ddcf5 NAMESTORE: Massaging new bulk API
1741ddcf5 is described below

commit 1741ddcf5efa177181518015f2becc0a67726bd7
Author: Martin Schanzenbach <schanzen@gnunet.org>
AuthorDate: Tue Oct 4 22:43:22 2022 +0900

    NAMESTORE: Massaging new bulk API
---
 src/include/gnunet_namestore_service.h | 20 ++++++++++++++------
 src/namestore/namestore_api.c          | 26 ++++++++++++++------------
 src/namestore/plugin_rest_namestore.c  | 17 ++++++++---------
 3 files changed, 36 insertions(+), 27 deletions(-)

diff --git a/src/include/gnunet_namestore_service.h 
b/src/include/gnunet_namestore_service.h
index a42619156..6183fb8d0 100644
--- a/src/include/gnunet_namestore_service.h
+++ b/src/include/gnunet_namestore_service.h
@@ -81,6 +81,18 @@ enum GNUNET_NAMESTORE_TxControl
   GNUNET_NAMESTORE_TX_ROLLBACK = 2,
 };
 
+/**
+ * A struct for record bulk import.
+ * The fields are arrays pointing to individual GNS records and names.
+ */
+struct GNUNET_NAMESTORE_RecordInfo
+{
+  const char *a_label;
+  unsigned int a_rd_count;
+  struct GNUNET_GNSRECORD_Data *a_rd;
+};
+
+
 /**
  * Connect to the namestore service.
  *
@@ -165,9 +177,7 @@ GNUNET_NAMESTORE_records_store (struct 
GNUNET_NAMESTORE_Handle *h,
  * @param h handle to the namestore
  * @param pkey private key of the zone
  * @param rd_set_count the number of record sets
- * @param a_label an array of size @a rd_set_count of names for each record set
- * @param a_rd_count an array of size @a rd_set_count containing the number of 
records in the corresponding 'rd' array
- * @param a_rd an array of size @a rd_set_count of arrays of records with data 
to store
+ * @param record_info the records to add containing @a rd_set_count records
  * @param cont continuation to call when done
  * @param cont_cls closure for @a cont
  * @return handle to abort the request
@@ -177,9 +187,7 @@ GNUNET_NAMESTORE_records_store2 (
   struct GNUNET_NAMESTORE_Handle *h,
   const struct GNUNET_IDENTITY_PrivateKey *pkey,
   unsigned int rd_set_count,
-  const char **a_label,
-  unsigned int *a_rd_count,
-  const struct GNUNET_GNSRECORD_Data **a_rd,
+  const struct GNUNET_NAMESTORE_RecordInfo *record_info,
   GNUNET_NAMESTORE_ContinuationWithStatus cont,
   void *cont_cls);
 
diff --git a/src/namestore/namestore_api.c b/src/namestore/namestore_api.c
index fd348a057..901ad9053 100644
--- a/src/namestore/namestore_api.c
+++ b/src/namestore/namestore_api.c
@@ -1095,7 +1095,11 @@ GNUNET_NAMESTORE_records_store (
   GNUNET_NAMESTORE_ContinuationWithStatus cont,
   void *cont_cls)
 {
-  return GNUNET_NAMESTORE_records_store2 (h, pkey, 1, &label, &rd_count, &rd,
+  struct GNUNET_NAMESTORE_RecordInfo ri;
+  ri.a_label = label;
+  ri.a_rd_count = rd_count;
+  ri.a_rd = (struct GNUNET_GNSRECORD_Data *) rd;
+  return GNUNET_NAMESTORE_records_store2 (h, pkey, 1, &ri,
                                           cont, cont_cls);
 }
 
@@ -1104,9 +1108,7 @@ GNUNET_NAMESTORE_records_store2 (
   struct GNUNET_NAMESTORE_Handle *h,
   const struct GNUNET_IDENTITY_PrivateKey *pkey,
   unsigned int rd_set_count,
-  const char **a_label,
-  unsigned int *a_rd_count,
-  const struct GNUNET_GNSRECORD_Data **a_rd,
+  const struct GNUNET_NAMESTORE_RecordInfo *record_info,
   GNUNET_NAMESTORE_ContinuationWithStatus cont,
   void *cont_cls)
 {
@@ -1128,9 +1130,9 @@ GNUNET_NAMESTORE_records_store2 (
 
   for (i = 0; i < rd_set_count; i++)
   {
-    label = a_label[i];
-    rd_count = a_rd_count[i];
-    rd = a_rd[i];
+    label = record_info[i].a_label;
+    rd_count = record_info[i].a_rd_count;
+    rd = record_info[i].a_rd;
     name_len = strlen (label) + 1;
     if (name_len > MAX_NAME_LEN)
     {
@@ -1168,18 +1170,18 @@ GNUNET_NAMESTORE_records_store2 (
   rd_set = (struct RecordSet*) &msg[1];
   for (int i = 0; i < rd_set_count; i++)
   {
-    label = a_label[i];
-    rd = a_rd[i];
+    label = record_info[i].a_label;
+    rd = record_info[i].a_rd;
     name_len = strlen (label) + 1;
     rd_set->name_len = htons (name_len);
-    rd_set->rd_count = htons (a_rd_count[i]);
+    rd_set->rd_count = htons (record_info[i].a_rd_count);
     rd_set->rd_len = htons (rd_ser_len[i]);
     rd_set->reserved = ntohs (0);
     name_tmp = (char *) &rd_set[1];
     GNUNET_memcpy (name_tmp, label, name_len);
     rd_ser = &name_tmp[name_len];
-    sret = GNUNET_GNSRECORD_records_serialize (a_rd_count[i], rd, 
rd_ser_len[i],
-                                               rd_ser);
+    sret = GNUNET_GNSRECORD_records_serialize (record_info[i].a_rd_count,
+                                               rd, rd_ser_len[i], rd_ser);
     if ((0 > sret) || (sret != rd_ser_len[i]))
     {
       GNUNET_break (0);
diff --git a/src/namestore/plugin_rest_namestore.c 
b/src/namestore/plugin_rest_namestore.c
index 0eef1aaeb..d93b2e185 100644
--- a/src/namestore/plugin_rest_namestore.c
+++ b/src/namestore/plugin_rest_namestore.c
@@ -819,19 +819,19 @@ namestore_import (struct GNUNET_REST_RequestHandle 
*con_handle,
     return;
   }
   size_t rd_set_count = json_array_size (data_js);
+  struct GNUNET_NAMESTORE_RecordInfo ri[rd_set_count];
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Got record set of size %d\n", rd_set_count);
   const struct GNUNET_GNSRECORD_Data *a_rd[rd_set_count];
-  unsigned int a_rd_count[rd_set_count];
-  char *a_label[rd_set_count];
+  char *albl;
   size_t index;
   json_t *value;
   json_array_foreach (data_js, index, value) {
     {
       struct GNUNET_GNSRECORD_Data *rd;
       struct GNUNET_JSON_Specification gnsspec[] =
-      { GNUNET_GNSRECORD_JSON_spec_gnsrecord (&rd, &a_rd_count[index],
-                                              &a_label[index]),
+      { GNUNET_GNSRECORD_JSON_spec_gnsrecord (&rd, &ri[index].a_rd_count,
+                                              &albl),
         GNUNET_JSON_spec_end () };
       if (GNUNET_OK != GNUNET_JSON_parse (value, gnsspec, NULL, NULL))
       {
@@ -840,9 +840,10 @@ namestore_import (struct GNUNET_REST_RequestHandle 
*con_handle,
         json_decref (data_js);
         return;
       }
-      a_rd[index] = rd;
+      ri[index].a_rd = rd;
+      ri[index].a_label = albl;
       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                  "Parsed record set for name %s\n", a_label[index]);
+                  "Parsed record set for name %s\n", ri[index].a_label);
     }
   }
   //json_decref (data_js);
@@ -851,9 +852,7 @@ namestore_import (struct GNUNET_REST_RequestHandle 
*con_handle,
   handle->ns_qe = GNUNET_NAMESTORE_records_store2 (ns_handle,
                                                    handle->zone_pkey,
                                                    rd_set_count,
-                                                   (const char**) a_label,
-                                                   a_rd_count,
-                                                   a_rd,
+                                                   ri,
                                                    &import_finished_cb,
                                                    handle);
   if (NULL == handle->ns_qe)

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