gnunet-svn
[Top][All Lists]
Advanced

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

[gnunet] branch master updated: -refactor zonemaster


From: gnunet
Subject: [gnunet] branch master updated: -refactor zonemaster
Date: Sat, 05 Feb 2022 21:37:46 +0100

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 3ab4b92da -refactor zonemaster
3ab4b92da is described below

commit 3ab4b92da2ff2aeb135c2ddf2a51eeec93e33468
Author: Martin Schanzenbach <schanzen@gnunet.org>
AuthorDate: Sat Feb 5 21:37:40 2022 +0100

    -refactor zonemaster
---
 src/zonemaster/Makefile.am                         |   6 +-
 src/zonemaster/gnunet-service-zonemaster-monitor.c | 153 +++---------------
 src/zonemaster/gnunet-service-zonemaster.c         | 172 +++++----------------
 src/zonemaster/zonemaster_misc.c                   | 132 ++++++++++++++++
 src/zonemaster/zonemaster_misc.h                   |  62 ++++++++
 5 files changed, 259 insertions(+), 266 deletions(-)

diff --git a/src/zonemaster/Makefile.am b/src/zonemaster/Makefile.am
index f2d569c75..d561d75fe 100644
--- a/src/zonemaster/Makefile.am
+++ b/src/zonemaster/Makefile.am
@@ -20,7 +20,8 @@ libexec_PROGRAMS = \
  gnunet-service-zonemaster-monitor
 
 gnunet_service_zonemaster_SOURCES = \
- gnunet-service-zonemaster.c
+ gnunet-service-zonemaster.c \
+ zonemaster_misc.c zonemaster_misc.h
 gnunet_service_zonemaster_LDADD = \
   $(top_builddir)/src/dht/libgnunetdht.la \
   $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \
@@ -32,7 +33,8 @@ gnunet_service_zonemaster_LDADD = \
 
 
 gnunet_service_zonemaster_monitor_SOURCES = \
- gnunet-service-zonemaster-monitor.c
+ gnunet-service-zonemaster-monitor.c \
+ zonemaster_misc.c zonemaster_misc.h
 gnunet_service_zonemaster_monitor_LDADD = \
   $(top_builddir)/src/dht/libgnunetdht.la \
   $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \
diff --git a/src/zonemaster/gnunet-service-zonemaster-monitor.c 
b/src/zonemaster/gnunet-service-zonemaster-monitor.c
index b51d1cb97..dcacec60f 100644
--- a/src/zonemaster/gnunet-service-zonemaster-monitor.c
+++ b/src/zonemaster/gnunet-service-zonemaster-monitor.c
@@ -28,7 +28,7 @@
 #include "gnunet_dht_service.h"
 #include "gnunet_namestore_service.h"
 #include "gnunet_statistics_service.h"
-
+#include "zonemaster_misc.h"
 
 #define LOG_STRERROR_FILE(kind, syscall, \
                           filename) GNUNET_log_from_strerror_file (kind, 
"util", \
@@ -239,68 +239,6 @@ dht_put_monitor_continuation (void *cls)
 }
 
 
-/**
- * Convert namestore records from the internal format to that
- * suitable for publication (removes private records, converts
- * to absolute expiration time).
- *
- * @param rd input records
- * @param rd_count size of the @a rd and @a rd_public arrays
- * @param rd_public where to write the converted records
- * @return number of records written to @a rd_public
- */
-static unsigned int
-convert_records_for_export (const struct GNUNET_GNSRECORD_Data *rd,
-                            unsigned int rd_count,
-                            struct GNUNET_GNSRECORD_Data *rd_public,
-                            struct GNUNET_TIME_Absolute *expiry)
-{
-  const struct GNUNET_GNSRECORD_TombstoneRecord *tombstone;
-  struct GNUNET_TIME_Absolute expiry_tombstone;
-  struct GNUNET_TIME_Absolute now;
-  unsigned int rd_public_count;
-
-  rd_public_count = 0;
-  tombstone = NULL;
-  now = GNUNET_TIME_absolute_get ();
-  for (unsigned int i = 0; i < rd_count; i++)
-  {
-    if (GNUNET_GNSRECORD_TYPE_TOMBSTONE == rd[i].record_type)
-    {
-      tombstone = rd[i].data;
-      continue;
-    }
-    if (0 != (rd[i].flags & GNUNET_GNSRECORD_RF_PRIVATE))
-      continue;
-    if ((0 == (rd[i].flags & GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION)) &&
-        (rd[i].expiration_time < now.abs_value_us))
-      continue;   /* record already expired, skip it */
-    rd_public[rd_public_count] = rd[i];
-    /* Make sure critical record types are published as such */
-    if (GNUNET_YES == GNUNET_GNSRECORD_is_critical (rd[i].record_type))
-      rd_public[rd_public_count].flags |= GNUNET_GNSRECORD_RF_CRITICAL;
-    rd_public_count++;
-  }
-
-  *expiry = GNUNET_GNSRECORD_record_get_expiration_time (rd_public_count,
-                                                         rd_public);
-
-  /* We need to check if the tombstone has an expiration in the fututre
-   * which would mean there was a block published under this label
-   * previously that is still valid. In this case we MUST NOT publish this
-   * block
-   */
-  if (NULL != tombstone)
-  {
-    expiry_tombstone = GNUNET_TIME_absolute_ntoh (tombstone->time_of_death);
-    if (GNUNET_TIME_absolute_cmp (*expiry,<=,expiry_tombstone))
-      return 0;
-  }
-
-  return rd_public_count;
-}
-
-
 /**
  * Store GNS records in the DHT.
  *
@@ -386,62 +324,6 @@ ts_store_cont (void *cls, int32_t success, const char 
*emsg)
 }
 
 
-/**
- * Update tombstone records.
- *
- * @param key key of the zone
- * @param label label to store under
- * @param rd_public public record data
- * @param rd_public_count number of records in @a rd_public
- * @param expire the expiration time for the tombstone
- * @param ta handle for the put operation
- * @return Namestore queue entry, NULL on error
- */
-static struct GNUNET_NAMESTORE_QueueEntry *
-touch_tombstone (const struct GNUNET_IDENTITY_PrivateKey *key,
-                 const char *label,
-                 const struct GNUNET_GNSRECORD_Data *rd_original,
-                 unsigned int rd_count_original,
-                 const struct GNUNET_TIME_Absolute expire,
-                 struct TombstoneActivity *ta)
-{
-  struct GNUNET_TIME_AbsoluteNBO exp_nbo;
-  struct GNUNET_GNSRECORD_Data rd[rd_count_original + 1];
-  int tombstone_exists = GNUNET_NO;
-  unsigned int rd_count;
-
-  exp_nbo = GNUNET_TIME_absolute_hton (expire);
-  for (rd_count = 0; rd_count < rd_count_original; rd_count++)
-  {
-    memcpy (&rd[rd_count], &rd_original[rd_count],
-            sizeof (struct GNUNET_GNSRECORD_Data));
-    if (GNUNET_GNSRECORD_TYPE_TOMBSTONE == rd[rd_count].record_type)
-    {
-      rd[rd_count].data = &exp_nbo;
-      tombstone_exists = GNUNET_YES;
-    }
-  }
-  if (GNUNET_NO == tombstone_exists)
-  {
-    rd[rd_count].data = &exp_nbo;
-    rd[rd_count].data_size = sizeof (exp_nbo);
-    rd[rd_count].record_type = GNUNET_GNSRECORD_TYPE_TOMBSTONE;
-    rd[rd_count].flags = GNUNET_GNSRECORD_RF_PRIVATE;
-    rd[rd_count].expiration_time = GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us;
-    rd_count++;
-  }
-  return GNUNET_NAMESTORE_records_store_ (namestore_handle,
-                                                key,
-                                                label,
-                                                rd_count,
-                                                rd,
-                                                GNUNET_YES,
-                                                &ts_store_cont,
-                                                ta);
-}
-
-
-
 /**
  * Process a record that was stored in the namestore
  * (invoked by the monitor).
@@ -460,7 +342,9 @@ handle_monitor_event (void *cls,
                       const struct GNUNET_GNSRECORD_Data *rd)
 {
   struct GNUNET_GNSRECORD_Data rd_public[rd_count];
+  struct GNUNET_GNSRECORD_Data rd_fresh[rd_count + 1];
   unsigned int rd_public_count;
+  unsigned int rd_fresh_count;
   struct DhtPutActivity *ma;
   struct TombstoneActivity *ta;
   struct GNUNET_TIME_Absolute expire;
@@ -476,10 +360,10 @@ handle_monitor_event (void *cls,
               label);
   /* filter out records that are not public, and convert to
      absolute expiration time. */
-  rd_public_count = convert_records_for_export (rd,
-                                                rd_count,
-                                                rd_public,
-                                                &expire);
+  rd_public_count = ZMSTR_convert_records_for_export (rd,
+                                                      rd_count,
+                                                      rd_public,
+                                                      &expire);
   if (0 == rd_public_count)
   {
     GNUNET_NAMESTORE_zone_monitor_next (zmon,
@@ -495,12 +379,23 @@ handle_monitor_event (void *cls,
                             expire,
                             ma);
   ta = GNUNET_new (struct TombstoneActivity);
-  ta->ns_qe = touch_tombstone (zone,
-                               label,
-                               rd,
-                               rd_count,
-                               expire,
-                               ta);
+  ZMSTR_touch_tombstone (zone,
+                         label,
+                         rd,
+                         rd_count,
+                         rd_fresh,
+                         &rd_fresh_count,
+                         expire);
+  ta->ns_qe =  GNUNET_NAMESTORE_records_store_ (namestore_handle,
+                                                zone,
+                                                label,
+                                                rd_fresh_count,
+                                                rd_fresh,
+                                                GNUNET_YES,
+                                                &ts_store_cont,
+                                                ta);
+
+
   GNUNET_CONTAINER_DLL_insert_tail (ta_head,
                                     ta_tail,
                                     ta);
diff --git a/src/zonemaster/gnunet-service-zonemaster.c 
b/src/zonemaster/gnunet-service-zonemaster.c
index 3a8ac4be1..9f0de8a54 100644
--- a/src/zonemaster/gnunet-service-zonemaster.c
+++ b/src/zonemaster/gnunet-service-zonemaster.c
@@ -29,7 +29,7 @@
 #include "gnunet_dht_service.h"
 #include "gnunet_namestore_service.h"
 #include "gnunet_statistics_service.h"
-
+#include "zonemaster_misc.h"
 
 #define LOG_STRERROR_FILE(kind, syscall, \
                           filename) GNUNET_log_from_strerror_file (kind, 
"util", \
@@ -569,75 +569,6 @@ dht_put_continuation (void *cls)
 }
 
 
-/**
- * Convert namestore records from the internal format to that
- * suitable for publication (removes private records, converts
- * to absolute expiration time).
- *
- * @param rd input records
- * @param rd_count size of the @a rd and @a rd_public arrays
- * @param rd_public where to write the converted records
- * @param expire the expiration of the block
- * @return number of records written to @a rd_public
- */
-static unsigned int
-convert_records_for_export (const struct GNUNET_GNSRECORD_Data *rd,
-                            unsigned int rd_count,
-                            struct GNUNET_GNSRECORD_Data *rd_public,
-                            struct GNUNET_TIME_Absolute *expiry)
-{
-  const struct GNUNET_GNSRECORD_TombstoneRecord *tombstone;
-  struct GNUNET_TIME_Absolute expiry_tombstone;
-  struct GNUNET_TIME_Absolute now;
-  unsigned int rd_public_count;
-
-  rd_public_count = 0;
-  tombstone = NULL;
-  now = GNUNET_TIME_absolute_get ();
-  for (unsigned int i = 0; i < rd_count; i++)
-  {
-    if (GNUNET_GNSRECORD_TYPE_TOMBSTONE == rd[i].record_type)
-    {
-      tombstone = rd[i].data;
-      continue;
-    }
-    if (0 != (rd[i].flags & GNUNET_GNSRECORD_RF_PRIVATE))
-      continue;
-    if ((0 == (rd[i].flags & GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION)) &&
-        (rd[i].expiration_time < now.abs_value_us))
-      continue;   /* record already expired, skip it */
-    if (0 != (rd[i].flags & GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION))
-    {
-      /* GNUNET_GNSRECORD_block_create will convert to absolute time;
-         we just need to adjust our iteration frequency */
-      min_relative_record_time.rel_value_us =
-        GNUNET_MIN (rd[i].expiration_time,
-                    min_relative_record_time.rel_value_us);
-    }
-    rd_public[rd_public_count] = rd[i];
-    /* Make sure critical record types are published as such */
-    if (GNUNET_YES == GNUNET_GNSRECORD_is_critical (rd[i].record_type))
-      rd_public[rd_public_count].flags |= GNUNET_GNSRECORD_RF_CRITICAL;
-    rd_public_count++;
-  }
-
-  *expiry = GNUNET_GNSRECORD_record_get_expiration_time (rd_public_count,
-                                                         rd_public);
-
-  /* We need to check if the tombstone has an expiration in the fututre
-   * which would mean there was a block published under this label
-   * previously that is still valid. In this case we MUST NOT publish this
-   * block
-   */
-  if (NULL != tombstone)
-  {
-    expiry_tombstone = GNUNET_TIME_absolute_ntoh (tombstone->time_of_death);
-    if (GNUNET_TIME_absolute_cmp (*expiry,<=,expiry_tombstone))
-      return 0;
-  }
-  return rd_public_count;
-}
-
 
 /**
  * Store GNS records in the DHT.
@@ -796,60 +727,6 @@ ts_store_cont (void *cls, int32_t success, const char 
*emsg)
 
 }
 
-/**
- * Update tombstone records.
- *
- * @param key key of the zone
- * @param label label to store under
- * @param rd_public public record data
- * @param rd_public_count number of records in @a rd_public
- * @param expire the expiration time for the tombstone
- * @param ta handle for the put operation
- * @return Namestore queue entry, NULL on error
- */
-static struct GNUNET_NAMESTORE_QueueEntry *
-touch_tombstone (const struct GNUNET_IDENTITY_PrivateKey *key,
-                 const char *label,
-                 const struct GNUNET_GNSRECORD_Data *rd_original,
-                 unsigned int rd_count_original,
-                 const struct GNUNET_TIME_Absolute expire,
-                 struct TombstoneActivity *ta)
-{
-  struct GNUNET_TIME_AbsoluteNBO exp_nbo;
-  struct GNUNET_GNSRECORD_Data rd[rd_count_original + 1];
-  int tombstone_exists = GNUNET_NO;
-  unsigned int rd_count;
-
-  exp_nbo = GNUNET_TIME_absolute_hton (expire);
-  for (rd_count = 0; rd_count < rd_count_original; rd_count++)
-  {
-    memcpy (&rd[rd_count], &rd_original[rd_count],
-            sizeof (struct GNUNET_GNSRECORD_Data));
-    if (GNUNET_GNSRECORD_TYPE_TOMBSTONE == rd[rd_count].record_type)
-    {
-      rd[rd_count].data = &exp_nbo;
-      tombstone_exists = GNUNET_YES;
-    }
-  }
-  if (GNUNET_NO == tombstone_exists)
-  {
-    rd[rd_count].data = &exp_nbo;
-    rd[rd_count].data_size = sizeof (exp_nbo);
-    rd[rd_count].record_type = GNUNET_GNSRECORD_TYPE_TOMBSTONE;
-    rd[rd_count].flags = GNUNET_GNSRECORD_RF_PRIVATE;
-    rd[rd_count].expiration_time = GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us;
-    rd_count++;
-  }
-  return GNUNET_NAMESTORE_records_store_ (namestore_handle,
-                                                key,
-                                                label,
-                                                rd_count,
-                                                rd,
-                                                GNUNET_YES,
-                                                &ts_store_cont,
-                                                ta);
-}
-
 
 /**
  * Function used to put all records successively into the DHT.
@@ -868,17 +745,19 @@ put_gns_record (void *cls,
                 const struct GNUNET_GNSRECORD_Data *rd)
 {
   struct GNUNET_GNSRECORD_Data rd_public[rd_count];
+  struct GNUNET_GNSRECORD_Data rd_fresh[rd_count + 1];
   unsigned int rd_public_count;
+  unsigned int rd_fresh_count = 0;
   struct DhtPutActivity *ma;
   struct TombstoneActivity *ta;
   struct GNUNET_TIME_Absolute expire;
 
   (void) cls;
   ns_iteration_left--;
-  rd_public_count = convert_records_for_export (rd,
-                                                rd_count,
-                                                rd_public,
-                                                &expire);
+  rd_public_count = ZMSTR_convert_records_for_export (rd,
+                                                      rd_count,
+                                                      rd_public,
+                                                      &expire);
   if (0 == rd_public_count)
   {
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -886,6 +765,19 @@ put_gns_record (void *cls,
     check_zone_namestore_next ();
     return;
   }
+  for (unsigned int i = 0; i < rd_public_count; i++)
+  {
+    if (0 != (rd_public[i].flags & GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION))
+    {
+      /* GNUNET_GNSRECORD_block_create will convert to absolute time;
+         we just need to adjust our iteration frequency */
+      min_relative_record_time.rel_value_us =
+        GNUNET_MIN (rd_public[i].expiration_time,
+                    min_relative_record_time.rel_value_us);
+    }
+  }
+
+
   /* We got a set of records to publish */
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Starting DHT PUT\n");
@@ -899,12 +791,23 @@ put_gns_record (void *cls,
                             expire,
                             ma);
   ta = GNUNET_new (struct TombstoneActivity);
-  ta->ns_qe = touch_tombstone (key,
-                               label,
-                               rd,
-                               rd_count,
-                               expire,
-                               ta);
+  ZMSTR_touch_tombstone (key,
+                         label,
+                         rd,
+                         rd_count,
+                         rd_fresh,
+                         &rd_fresh_count,
+                         expire);
+  ta->ns_qe =  GNUNET_NAMESTORE_records_store_ (namestore_handle,
+                                                key,
+                                                label,
+                                                rd_fresh_count,
+                                                rd_fresh,
+                                                GNUNET_YES,
+                                                &ts_store_cont,
+                                                ta);
+
+
   GNUNET_CONTAINER_DLL_insert_tail (ta_head,
                                     ta_tail,
                                     ta);
@@ -940,7 +843,6 @@ put_gns_record (void *cls,
   }
 }
 
-
 /**
  * Periodically iterate over all zones and store everything in DHT
  *
diff --git a/src/zonemaster/zonemaster_misc.c b/src/zonemaster/zonemaster_misc.c
new file mode 100644
index 000000000..f067e9c62
--- /dev/null
+++ b/src/zonemaster/zonemaster_misc.c
@@ -0,0 +1,132 @@
+/*
+     This file is part of GNUnet.
+     Copyright (C) 2021 GNUnet e.V.
+
+     GNUnet is free software: you can redistribute it and/or modify it
+     under the terms of the GNU Affero General Public License as published
+     by the Free Software Foundation, either version 3 of the License,
+     or (at your option) any later version.
+
+     GNUnet is distributed in the hope that it will be useful, but
+     WITHOUT ANY WARRANTY; without even the implied warranty of
+     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+     Affero General Public License for more details.
+
+     You should have received a copy of the GNU Affero General Public License
+     along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+     SPDX-License-Identifier: AGPL3.0-or-later
+ */
+
+
+#include "zonemaster_misc.h"
+
+/**
+ * Convert namestore records from the internal format to that
+ * suitable for publication (removes private records, converts
+ * to absolute expiration time).
+ *
+ * @param rd input records
+ * @param rd_count size of the @a rd and @a rd_public arrays
+ * @param rd_public where to write the converted records
+ * @param expire the expiration of the block
+ * @return number of records written to @a rd_public
+ */
+unsigned int
+ZMSTR_convert_records_for_export (const struct GNUNET_GNSRECORD_Data *rd,
+                            unsigned int rd_count,
+                            struct GNUNET_GNSRECORD_Data *rd_public,
+                            struct GNUNET_TIME_Absolute *expiry)
+{
+  const struct GNUNET_GNSRECORD_TombstoneRecord *tombstone;
+  struct GNUNET_TIME_Absolute expiry_tombstone;
+  struct GNUNET_TIME_Absolute now;
+  unsigned int rd_public_count;
+
+  rd_public_count = 0;
+  tombstone = NULL;
+  now = GNUNET_TIME_absolute_get ();
+  for (unsigned int i = 0; i < rd_count; i++)
+  {
+    if (GNUNET_GNSRECORD_TYPE_TOMBSTONE == rd[i].record_type)
+    {
+      tombstone = rd[i].data;
+      continue;
+    }
+    if (0 != (rd[i].flags & GNUNET_GNSRECORD_RF_PRIVATE))
+      continue;
+    if ((0 == (rd[i].flags & GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION)) &&
+        (rd[i].expiration_time < now.abs_value_us))
+      continue;   /* record already expired, skip it */
+      rd_public[rd_public_count] = rd[i];
+    /* Make sure critical record types are published as such */
+    if (GNUNET_YES == GNUNET_GNSRECORD_is_critical (rd[i].record_type))
+      rd_public[rd_public_count].flags |= GNUNET_GNSRECORD_RF_CRITICAL;
+    rd_public_count++;
+  }
+
+  *expiry = GNUNET_GNSRECORD_record_get_expiration_time (rd_public_count,
+                                                         rd_public);
+
+  /* We need to check if the tombstone has an expiration in the fututre
+   * which would mean there was a block published under this label
+   * previously that is still valid. In this case we MUST NOT publish this
+   * block
+   */
+  if (NULL != tombstone)
+  {
+    expiry_tombstone = GNUNET_TIME_absolute_ntoh (tombstone->time_of_death);
+    if (GNUNET_TIME_absolute_cmp (*expiry,<=,expiry_tombstone))
+      return 0;
+  }
+  return rd_public_count;
+}
+
+
+/**
+ * Update tombstone records.
+ *
+ * @param key key of the zone
+ * @param label label to store under
+ * @param rd_public public record data
+ * @param rd_public_count number of records in @a rd_public
+ * @param rd the buffer for the result. Must be rd_public_count +1
+ * @param rd_count the actual number of records written to rd
+ * @param expire the expiration time for the tombstone
+ * @return Namestore queue entry, NULL on error
+ */
+void
+ZMSTR_touch_tombstone (const struct GNUNET_IDENTITY_PrivateKey *key,
+                 const char *label,
+                 const struct GNUNET_GNSRECORD_Data *rd_original,
+                 unsigned int rd_count_original,
+                 struct GNUNET_GNSRECORD_Data *rd,
+                 unsigned int *rd_count,
+                 const struct GNUNET_TIME_Absolute expire)
+{
+  struct GNUNET_TIME_AbsoluteNBO exp_nbo;
+  int tombstone_exists = GNUNET_NO;
+  unsigned int i;
+
+  exp_nbo = GNUNET_TIME_absolute_hton (expire);
+  for (i = 0; i < rd_count_original; i++)
+  {
+    memcpy (&rd[i], &rd_original[i],
+            sizeof (struct GNUNET_GNSRECORD_Data));
+    if (GNUNET_GNSRECORD_TYPE_TOMBSTONE == rd[i].record_type)
+    {
+      rd[i].data = &exp_nbo;
+      tombstone_exists = GNUNET_YES;
+    }
+  }
+  if (GNUNET_NO == tombstone_exists)
+  {
+    rd[i].data = &exp_nbo;
+    rd[i].data_size = sizeof (exp_nbo);
+    rd[i].record_type = GNUNET_GNSRECORD_TYPE_TOMBSTONE;
+    rd[i].flags = GNUNET_GNSRECORD_RF_PRIVATE;
+    rd[i].expiration_time = GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us;
+    i++;
+  }
+  *rd_count = i;
+}
diff --git a/src/zonemaster/zonemaster_misc.h b/src/zonemaster/zonemaster_misc.h
new file mode 100644
index 000000000..27ef3aab7
--- /dev/null
+++ b/src/zonemaster/zonemaster_misc.h
@@ -0,0 +1,62 @@
+/*
+     This file is part of GNUnet.
+     Copyright (C) 2021 GNUnet e.V.
+
+     GNUnet is free software: you can redistribute it and/or modify it
+     under the terms of the GNU Affero General Public License as published
+     by the Free Software Foundation, either version 3 of the License,
+     or (at your option) any later version.
+
+     GNUnet is distributed in the hope that it will be useful, but
+     WITHOUT ANY WARRANTY; without even the implied warranty of
+     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+     Affero General Public License for more details.
+
+     You should have received a copy of the GNU Affero General Public License
+     along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+     SPDX-License-Identifier: AGPL3.0-or-later
+ */
+
+#include "platform.h"
+#include "gnunet_util_lib.h"
+#include "gnunet_namestore_service.h"
+
+
+/**
+ * Convert namestore records from the internal format to that
+ * suitable for publication (removes private records, converts
+ * to absolute expiration time).
+ *
+ * @param rd input records
+ * @param rd_count size of the @a rd and @a rd_public arrays
+ * @param rd_public where to write the converted records
+ * @param expire the expiration of the block
+ * @return number of records written to @a rd_public
+ */
+unsigned int
+ZMSTR_convert_records_for_export (const struct GNUNET_GNSRECORD_Data *rd,
+                            unsigned int rd_count,
+                            struct GNUNET_GNSRECORD_Data *rd_public,
+                            struct GNUNET_TIME_Absolute *expiry);
+
+/**
+ * Update tombstone records.
+ *
+ * @param key key of the zone
+ * @param label label to store under
+ * @param rd_public public record data
+ * @param rd_public_count number of records in @a rd_public
+ * @param rd the buffer for the result. Must be rd_public_count +1
+ * @param rd_count the actual number of records written to rd
+ * @param expire the expiration time for the tombstone
+ * @return Namestore queue entry, NULL on error
+ */
+void
+ZMSTR_touch_tombstone (const struct GNUNET_IDENTITY_PrivateKey *key,
+                 const char *label,
+                 const struct GNUNET_GNSRECORD_Data *rd_original,
+                 unsigned int rd_count_original,
+                 struct GNUNET_GNSRECORD_Data *rd,
+                 unsigned int *rd_count,
+                 const struct GNUNET_TIME_Absolute expire);

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