[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnunet] branch master updated: -simlify and correct tombstone logic
From: |
gnunet |
Subject: |
[gnunet] branch master updated: -simlify and correct tombstone logic |
Date: |
Sun, 06 Feb 2022 14:30:07 +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 215032563 -simlify and correct tombstone logic
215032563 is described below
commit 215032563755ba48d4e871b82c9c6697611726f8
Author: Martin Schanzenbach <schanzen@gnunet.org>
AuthorDate: Sun Feb 6 14:30:00 2022 +0100
-simlify and correct tombstone logic
---
src/gns/plugin_gnsrecord_gns.c | 16 +--
src/gnsrecord/gnsrecord_misc.c | 54 +++++++--
src/gnsrecord/gnunet-gnsrecord-tvg.c | 6 +-
src/include/gnunet_gnsrecord_lib.h | 22 +++-
src/namestore/gnunet-service-namestore.c | 108 +++++++++--------
src/namestore/namestore.h | 6 +-
src/namestore/namestore_api.c | 36 +-----
src/zonemaster/Makefile.am | 6 +-
src/zonemaster/gnunet-service-zonemaster-monitor.c | 89 +-------------
src/zonemaster/gnunet-service-zonemaster.c | 88 +-------------
src/zonemaster/zonemaster_misc.c | 132 ---------------------
src/zonemaster/zonemaster_misc.h | 62 ----------
12 files changed, 142 insertions(+), 483 deletions(-)
diff --git a/src/gns/plugin_gnsrecord_gns.c b/src/gns/plugin_gnsrecord_gns.c
index 694dc6351..beeeda295 100644
--- a/src/gns/plugin_gnsrecord_gns.c
+++ b/src/gns/plugin_gnsrecord_gns.c
@@ -133,10 +133,7 @@ gns_value_to_string (void *cls,
return box_str;
}
case GNUNET_GNSRECORD_TYPE_TOMBSTONE: {
- const struct GNUNET_GNSRECORD_TombstoneRecord *ts = data;
- struct GNUNET_TIME_Absolute tod;
- tod = GNUNET_TIME_absolute_ntoh (ts->time_of_death);
- return GNUNET_strdup (GNUNET_STRINGS_absolute_time_to_string (tod));
+ return GNUNET_strdup ("\u271E");
}
default:
return NULL;
@@ -303,15 +300,8 @@ gns_string_to_value (void *cls,
return GNUNET_OK;
}
case GNUNET_GNSRECORD_TYPE_TOMBSTONE: {
- struct GNUNET_TIME_Absolute tod;
- struct GNUNET_TIME_AbsoluteNBO *tod_nbo;
- if (GNUNET_OK != GNUNET_STRINGS_fancy_time_to_absolute (s,
- &tod))
- return GNUNET_SYSERR;
- tod_nbo = GNUNET_new (struct GNUNET_TIME_AbsoluteNBO);
- *tod_nbo = GNUNET_TIME_absolute_hton (tod);
- *data_size = sizeof (*tod_nbo);
- *data = tod_nbo;
+ *data_size = 0;
+ *data = NULL;
return GNUNET_OK;
}
diff --git a/src/gnsrecord/gnsrecord_misc.c b/src/gnsrecord/gnsrecord_misc.c
index 61604c730..5c20dbedc 100644
--- a/src/gnsrecord/gnsrecord_misc.c
+++ b/src/gnsrecord/gnsrecord_misc.c
@@ -144,19 +144,11 @@ GNUNET_GNSRECORD_records_cmp (const struct
GNUNET_GNSRECORD_Data *a,
}
-/**
- * Returns the expiration time of the given block of records. The block
- * expiration time is the expiration time of the record with smallest
- * expiration time.
- *
- * @param rd_count number of records given in @a rd
- * @param rd array of records
- * @return absolute expiration time
- */
struct GNUNET_TIME_Absolute
GNUNET_GNSRECORD_record_get_expiration_time (unsigned int rd_count,
const struct
- GNUNET_GNSRECORD_Data *rd)
+ GNUNET_GNSRECORD_Data *rd,
+ struct GNUNET_TIME_Absolute min)
{
struct GNUNET_TIME_Absolute expire;
struct GNUNET_TIME_Absolute at;
@@ -202,6 +194,7 @@ GNUNET_GNSRECORD_record_get_expiration_time (unsigned int
rd_count,
expire = GNUNET_TIME_absolute_min (at,
expire);
}
+ expire = GNUNET_TIME_absolute_min (expire, min);
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Determined expiration time for block with %u records to be %s\n",
rd_count,
@@ -406,5 +399,46 @@ GNUNET_GNSRECORD_record_to_identity_key (const struct
GNUNET_GNSRECORD_Data *rd,
}
+unsigned int
+GNUNET_GNSRECORD_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)
+{
+ struct GNUNET_TIME_Absolute expiry_tombstone;
+ struct GNUNET_TIME_Absolute now;
+ struct GNUNET_TIME_Absolute minimum_expiration;
+ unsigned int rd_public_count;
+
+ rd_public_count = 0;
+ minimum_expiration = GNUNET_TIME_UNIT_FOREVER_ABS;
+ now = GNUNET_TIME_absolute_get ();
+ for (unsigned int i = 0; i < rd_count; i++)
+ {
+ if (GNUNET_GNSRECORD_TYPE_TOMBSTONE == rd[i].record_type)
+ {
+ minimum_expiration.abs_value_us = rd[i].expiration_time;
+ 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,
+ minimum_expiration);
+
+ return rd_public_count;
+}
+
+
/* end of gnsrecord_misc.c */
diff --git a/src/gnsrecord/gnunet-gnsrecord-tvg.c
b/src/gnsrecord/gnunet-gnsrecord-tvg.c
index f9b83e48b..dec0855eb 100644
--- a/src/gnsrecord/gnunet-gnsrecord-tvg.c
+++ b/src/gnsrecord/gnunet-gnsrecord-tvg.c
@@ -212,7 +212,8 @@ run_pkey (void)
fprintf (stdout, "RDATA:\n");
print_bytes (rdata, rdata_size, 8);
fprintf (stdout, "\n");
- expire = GNUNET_GNSRECORD_record_get_expiration_time (TEST_RRCOUNT, rd);
+ expire = GNUNET_GNSRECORD_record_get_expiration_time (TEST_RRCOUNT, rd,
+
GNUNET_TIME_UNIT_FOREVER_ABS);
GNR_derive_block_aes_key (ctr,
skey,
TEST_RECORD_LABEL,
@@ -348,7 +349,8 @@ run_edkey (void)
rdata_size = GNUNET_GNSRECORD_records_get_size (TEST_RRCOUNT,
rd);
expire = GNUNET_GNSRECORD_record_get_expiration_time (TEST_RRCOUNT,
- rd);
+ rd,
+
GNUNET_TIME_UNIT_FOREVER_ABS);
rdata = GNUNET_malloc (rdata_size);
GNUNET_GNSRECORD_records_serialize (2,
rd,
diff --git a/src/include/gnunet_gnsrecord_lib.h
b/src/include/gnunet_gnsrecord_lib.h
index 7d30055fc..fd630b987 100644
--- a/src/include/gnunet_gnsrecord_lib.h
+++ b/src/include/gnunet_gnsrecord_lib.h
@@ -631,11 +631,13 @@ GNUNET_GNSRECORD_records_cmp (const struct
GNUNET_GNSRECORD_Data *a,
*
* @param rd_count number of records given in @a rd
* @param rd array of records
+ * @param min minimum expiration time
* @return absolute expiration time
*/
struct GNUNET_TIME_Absolute
-GNUNET_GNSRECORD_record_get_expiration_time (
- unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd);
+GNUNET_GNSRECORD_record_get_expiration_time (unsigned int rd_count,
+ const struct
GNUNET_GNSRECORD_Data *rd,
+ struct GNUNET_TIME_Absolute min);
/**
@@ -724,6 +726,22 @@ GNUNET_GNSRECORD_is_zonekey_type (uint32_t type);
enum GNUNET_GenericReturnValue
GNUNET_GNSRECORD_is_critical (uint32_t type);
+/**
+ * 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 expiry the expiration of the block
+ * @return number of records written to @a rd_public
+ */
+unsigned int
+GNUNET_GNSRECORD_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);
#if 0 /* keep Emacsens' auto-indent happy */
{
diff --git a/src/namestore/gnunet-service-namestore.c
b/src/namestore/gnunet-service-namestore.c
index 7669e90f5..acf49de9e 100644
--- a/src/namestore/gnunet-service-namestore.c
+++ b/src/namestore/gnunet-service-namestore.c
@@ -948,7 +948,8 @@ refresh_block (struct NamestoreClient *nc,
GNUNET_free (res);
return;
}
- exp_time = GNUNET_GNSRECORD_record_get_expiration_time (res_count, res);
+ exp_time = GNUNET_GNSRECORD_record_get_expiration_time (res_count, res,
+
GNUNET_TIME_UNIT_FOREVER_ABS);
if (cache_keys)
GNUNET_assert (GNUNET_OK ==
GNUNET_GNSRECORD_block_create2 (zone_key, exp_time, name,
@@ -1461,25 +1462,21 @@ check_record_store (void *cls, const struct
RecordStoreMessage *rp_msg)
* @param rd records stored under @a label in the zone
*/
static void
-lookup_tombstone_it (void *cls,
- uint64_t seq,
- const struct GNUNET_IDENTITY_PrivateKey *private_key,
- const char *label,
- unsigned int rd_count,
- const struct GNUNET_GNSRECORD_Data *rd)
+get_block_exp_existing (void *cls,
+ uint64_t seq,
+ const struct
+ GNUNET_IDENTITY_PrivateKey *private_key,
+ const char *label,
+ unsigned int rd_count,
+ const struct GNUNET_GNSRECORD_Data *rd)
{
- struct GNUNET_GNSRECORD_TombstoneRecord *ts = cls;
+ struct GNUNET_TIME_Absolute *exp = cls;
+ struct GNUNET_GNSRECORD_Data rd_pub[rd_count];
- (void) private_key;
- GNUNET_assert (0 != seq);
- for (unsigned int c = 0; c < rd_count; c++)
- {
- if (GNUNET_GNSRECORD_TYPE_TOMBSTONE == rd[c].record_type)
- {
- memcpy (ts, rd[c].data, rd[c].data_size);
- return;
- }
- }
+ GNUNET_GNSRECORD_convert_records_for_export (rd,
+ rd_count,
+ rd_pub,
+ exp);
}
@@ -1502,11 +1499,14 @@ handle_record_store (void *cls, const struct
RecordStoreMessage *rp_msg)
unsigned int rd_count;
int res;
struct StoreActivity *sa;
- struct GNUNET_GNSRECORD_TombstoneRecord tombstone;
+ struct GNUNET_TIME_Absolute existing_block_exp;
+ struct GNUNET_TIME_Absolute new_block_exp;
+ struct GNUNET_GNSRECORD_Data *tombstone_record;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Received NAMESTORE_RECORD_STORE message\n");
- tombstone.time_of_death.abs_value_us__ = 0;
+ existing_block_exp.abs_value_us = 0;
+ tombstone_record = NULL;
rid = ntohl (rp_msg->gns_header.r_id);
name_len = ntohs (rp_msg->name_len);
rd_count = ntohs (rp_msg->rd_count);
@@ -1545,8 +1545,8 @@ handle_record_store (void *cls, const struct
RecordStoreMessage *rp_msg)
if ((GNUNET_NO == GSN_database->lookup_records (GSN_database->cls,
&rp_msg->private_key,
conv_name,
- &lookup_tombstone_it,
- &tombstone)) &&
+ &get_block_exp_existing,
+ &existing_block_exp)) &&
(rd_count == 0))
{
/* This name does not exist, so cannot be removed */
@@ -1559,28 +1559,20 @@ handle_record_store (void *cls, const struct
RecordStoreMessage *rp_msg)
{
/* remove "NICK" records, unless this is for the
#GNUNET_GNS_EMPTY_LABEL_AT label
- Also, add or update tombstone record if this is a zonemaster request.
- Also, add existing tombstone record to set if this is not a zonemaster
- request if one existed in the old set.
- This is why we (may) need one additional record */
+ We may need one additional record later for tombstone.
+ */
struct GNUNET_GNSRECORD_Data rd_clean[GNUNET_NZL (rd_count) + 1];
unsigned int rd_clean_off;
int have_nick;
- int have_tombstone;
rd_clean_off = 0;
have_nick = GNUNET_NO;
- have_tombstone = GNUNET_NO;
for (unsigned int i = 0; i < rd_count; i++)
{
/* Do not allow to set tombstone records unless zonemaster */
- if (GNUNET_GNSRECORD_TYPE_TOMBSTONE == rd[i].record_type)
- {
- if (1 != ntohs (rp_msg->is_zonemaster))
- continue;
- have_tombstone = GNUNET_YES;
- }
rd_clean[rd_clean_off] = rd[i];
+ if (GNUNET_GNSRECORD_TYPE_TOMBSTONE == rd[i].record_type)
+ tombstone_record = &rd_clean[rd_clean_off];
if (GNUNET_YES == GNUNET_GNSRECORD_is_critical (rd[i].record_type))
rd_clean[rd_clean_off].flags |= GNUNET_GNSRECORD_RF_CRITICAL;
@@ -1595,24 +1587,38 @@ handle_record_store (void *cls, const struct
RecordStoreMessage *rp_msg)
have_nick = GNUNET_YES;
}
}
- /* At this point we are either zonemaster and have set a new tombstone
- * (have_tombstone)
- * or we are not zonemaster and we may want to
- * add the old tombstone (if there was any and if it is not already
- * old).
+ GNUNET_GNSRECORD_convert_records_for_export (rd,
+ rd_clean_off,
+ rd_clean,
+ &new_block_exp);
+ /*
+ * If existing_block_exp is 0, then there was not record set
+ * and no tombstone.
+ * Otherwise, if the existing block expiration is after the
+ * new block expiration would be, we need to add a tombstone
+ * or update it.
*/
- if ((GNUNET_NO == have_tombstone) &&
- GNUNET_TIME_absolute_cmp (
- GNUNET_TIME_absolute_get (), <, GNUNET_TIME_absolute_ntoh (
- tombstone.time_of_death)))
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "New exp: %s\n",
+ GNUNET_STRINGS_absolute_time_to_string (new_block_exp));
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Old exp: %s\n",
+ GNUNET_STRINGS_absolute_time_to_string (existing_block_exp));
+ if (GNUNET_TIME_absolute_cmp (new_block_exp, <=, existing_block_exp))
{
- rd_clean[rd_clean_off].record_type = GNUNET_GNSRECORD_TYPE_TOMBSTONE;
- rd_clean[rd_clean_off].expiration_time =
- GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us;
- rd_clean[rd_clean_off].data = &tombstone;
- rd_clean[rd_clean_off].data_size = sizeof (tombstone);
- rd_clean[rd_clean_off].flags |= GNUNET_GNSRECORD_RF_PRIVATE;
- rd_clean_off++;
+ /* There was already a TS record in the set given */
+ if (NULL != tombstone_record)
+ {
+ tombstone_record->expiration_time = existing_block_exp.abs_value_us;
+ }
+ else {
+ rd_clean[rd_clean_off].record_type = GNUNET_GNSRECORD_TYPE_TOMBSTONE;
+ rd_clean[rd_clean_off].expiration_time =
existing_block_exp.abs_value_us;
+ rd_clean[rd_clean_off].data = NULL;
+ rd_clean[rd_clean_off].data_size = 0;
+ rd_clean[rd_clean_off].flags |= GNUNET_GNSRECORD_RF_PRIVATE;
+ rd_clean_off++;
+ }
}
if ((0 == strcmp (GNUNET_GNS_EMPTY_LABEL_AT, conv_name)) &&
(GNUNET_NO == have_nick))
@@ -1627,7 +1633,7 @@ handle_record_store (void *cls, const struct
RecordStoreMessage *rp_msg)
rd_clean);
}
- if ((GNUNET_OK != res) || (1 == ntohs (rp_msg->is_zonemaster)))
+ if (GNUNET_OK != res)
{
/* store not successful or zonemaster, not need to tell monitors */
send_store_response (nc, res, rid);
diff --git a/src/namestore/namestore.h b/src/namestore/namestore.h
index bcc8f5d4e..05a1d97ad 100644
--- a/src/namestore/namestore.h
+++ b/src/namestore/namestore.h
@@ -83,11 +83,9 @@ struct RecordStoreMessage
uint16_t rd_count GNUNET_PACKED;
/**
- * This is a zonemaster request.
- * It means more authoritative tombstone processing
- * and not notification of monitors.
+ * Reserved for alignment.
*/
- uint16_t is_zonemaster GNUNET_PACKED;
+ uint16_t reserved GNUNET_PACKED;
/**
* The private key of the authority.
diff --git a/src/namestore/namestore_api.c b/src/namestore/namestore_api.c
index 935357d36..d4d06bab9 100644
--- a/src/namestore/namestore_api.c
+++ b/src/namestore/namestore_api.c
@@ -970,13 +970,12 @@ warn_delay (void *cls)
}
struct GNUNET_NAMESTORE_QueueEntry *
-GNUNET_NAMESTORE_records_store_ (
+GNUNET_NAMESTORE_records_store (
struct GNUNET_NAMESTORE_Handle *h,
const struct GNUNET_IDENTITY_PrivateKey *pkey,
const char *label,
unsigned int rd_count,
const struct GNUNET_GNSRECORD_Data *rd,
- int is_zonemaster,
GNUNET_NAMESTORE_ContinuationWithStatus cont,
void *cont_cls)
{
@@ -1023,7 +1022,7 @@ GNUNET_NAMESTORE_records_store_ (
msg->name_len = htons (name_len);
msg->rd_count = htons (rd_count);
msg->rd_len = htons (rd_ser_len);
- msg->is_zonemaster = (GNUNET_YES == is_zonemaster) ? ntohs(1) : ntohs(0);
+ msg->reserved = ntohs(0);
msg->private_key = *pkey;
name_tmp = (char *) &msg[1];
@@ -1056,37 +1055,6 @@ GNUNET_NAMESTORE_records_store_ (
return qe;
}
-/**
- * Store an item in the namestore. If the item is already present,
- * it is replaced with the new record. Use an empty array to
- * remove all records under the given name.
- *
- * @param h handle to the namestore
- * @param pkey private key of the zone
- * @param label name that is being mapped (at most 255 characters long)
- * @param rd_count number of records in the @a rd array
- * @param rd array of records with data to store
- * @param cont continuation to call when done
- * @param cont_cls closure for @a cont
- * @return handle to abort the request
- */
-struct GNUNET_NAMESTORE_QueueEntry *
-GNUNET_NAMESTORE_records_store (
- struct GNUNET_NAMESTORE_Handle *h,
- const struct GNUNET_IDENTITY_PrivateKey *pkey,
- const char *label,
- unsigned int rd_count,
- const struct GNUNET_GNSRECORD_Data *rd,
- GNUNET_NAMESTORE_ContinuationWithStatus cont,
- void *cont_cls)
-{
- return GNUNET_NAMESTORE_records_store_ (h, pkey, label, rd_count, rd,
- GNUNET_NO, cont, cont_cls);
-}
-
-
-
-
/**
* Lookup an item in the namestore.
*
diff --git a/src/zonemaster/Makefile.am b/src/zonemaster/Makefile.am
index d561d75fe..f2d569c75 100644
--- a/src/zonemaster/Makefile.am
+++ b/src/zonemaster/Makefile.am
@@ -20,8 +20,7 @@ libexec_PROGRAMS = \
gnunet-service-zonemaster-monitor
gnunet_service_zonemaster_SOURCES = \
- gnunet-service-zonemaster.c \
- zonemaster_misc.c zonemaster_misc.h
+ gnunet-service-zonemaster.c
gnunet_service_zonemaster_LDADD = \
$(top_builddir)/src/dht/libgnunetdht.la \
$(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \
@@ -33,8 +32,7 @@ gnunet_service_zonemaster_LDADD = \
gnunet_service_zonemaster_monitor_SOURCES = \
- gnunet-service-zonemaster-monitor.c \
- zonemaster_misc.c zonemaster_misc.h
+ gnunet-service-zonemaster-monitor.c
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 dcacec60f..fef9e6b82 100644
--- a/src/zonemaster/gnunet-service-zonemaster-monitor.c
+++ b/src/zonemaster/gnunet-service-zonemaster-monitor.c
@@ -28,7 +28,6 @@
#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", \
@@ -58,30 +57,6 @@
*/
#define DHT_GNS_REPLICATION_LEVEL 5
-/**
- * Handle for tombston updates which are executed for each published
- * record set.
- */
-struct TombstoneActivity
-{
- /**
- * Kept in a DLL.
- */
- struct TombstoneActivity *next;
-
- /**
- * Kept in a DLL.
- */
- struct TombstoneActivity *prev;
-
- /**
- * Handle for the store operation.
- */
- struct GNUNET_NAMESTORE_QueueEntry *ns_qe;
-
-};
-
-
/**
* Handle for DHT PUT activity triggered from the namestore monitor.
*/
@@ -129,17 +104,6 @@ static struct GNUNET_NAMESTORE_Handle *namestore_handle;
*/
static struct GNUNET_NAMESTORE_ZoneMonitor *zmon;
-/**
- * Head of the tombstone operations
- */
-static struct TombstoneActivity *ta_head;
-
-/**
- * Tail of the tombstone operations
- */
-static struct TombstoneActivity *ta_tail;
-
-
/**
* Head of monitor activities; kept in a DLL.
*/
@@ -186,14 +150,6 @@ shutdown_task (void *cls)
ma);
GNUNET_free (ma);
}
- while (NULL != (ta = ta_head))
- {
- GNUNET_NAMESTORE_cancel (ta->ns_qe);
- GNUNET_CONTAINER_DLL_remove (ta_head,
- ta_tail,
- ta);
- GNUNET_free (ta);
- }
if (NULL != statistics)
{
GNUNET_STATISTICS_destroy (statistics,
@@ -309,21 +265,6 @@ perform_dht_put (const struct GNUNET_IDENTITY_PrivateKey
*key,
return ret;
}
-static void
-ts_store_cont (void *cls, int32_t success, const char *emsg)
-{
- struct TombstoneActivity *ta = cls;
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Tombstone update complete\n");
- GNUNET_CONTAINER_DLL_remove (ta_head,
- ta_tail,
- ta);
- GNUNET_free (ta);
-
-}
-
-
/**
* Process a record that was stored in the namestore
* (invoked by the monitor).
@@ -346,7 +287,6 @@ handle_monitor_event (void *cls,
unsigned int rd_public_count;
unsigned int rd_fresh_count;
struct DhtPutActivity *ma;
- struct TombstoneActivity *ta;
struct GNUNET_TIME_Absolute expire;
(void) cls;
@@ -360,10 +300,10 @@ handle_monitor_event (void *cls,
label);
/* filter out records that are not public, and convert to
absolute expiration time. */
- rd_public_count = ZMSTR_convert_records_for_export (rd,
- rd_count,
- rd_public,
- &expire);
+ rd_public_count = GNUNET_GNSRECORD_convert_records_for_export (rd,
+ rd_count,
+ rd_public,
+ &expire);
if (0 == rd_public_count)
{
GNUNET_NAMESTORE_zone_monitor_next (zmon,
@@ -378,27 +318,6 @@ handle_monitor_event (void *cls,
rd_count,
expire,
ma);
- ta = GNUNET_new (struct TombstoneActivity);
- 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);
if (NULL == ma->ph)
{
/* PUT failed, do not remember operation */
diff --git a/src/zonemaster/gnunet-service-zonemaster.c
b/src/zonemaster/gnunet-service-zonemaster.c
index 9f0de8a54..9eb3432ee 100644
--- a/src/zonemaster/gnunet-service-zonemaster.c
+++ b/src/zonemaster/gnunet-service-zonemaster.c
@@ -29,7 +29,6 @@
#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", \
@@ -90,30 +89,6 @@
*/
#define DHT_GNS_REPLICATION_LEVEL 5
-/**
- * Handle for tombston updates which are executed for each published
- * record set.
- */
-struct TombstoneActivity
-{
- /**
- * Kept in a DLL.
- */
- struct TombstoneActivity *next;
-
- /**
- * Kept in a DLL.
- */
- struct TombstoneActivity *prev;
-
- /**
- * Handle for the store operation.
- */
- struct GNUNET_NAMESTORE_QueueEntry *ns_qe;
-
-};
-
-
/**
* Handle for DHT PUT activity triggered from the namestore monitor.
*/
@@ -171,16 +146,6 @@ static struct DhtPutActivity *it_head;
*/
static struct DhtPutActivity *it_tail;
-/**
- * Head of the tombstone operations
- */
-static struct TombstoneActivity *ta_head;
-
-/**
- * Tail of the tombstone operations
- */
-static struct TombstoneActivity *ta_tail;
-
/**
* Number of entries in the DHT queue #it_head.
*/
@@ -296,14 +261,6 @@ shutdown_task (void *cls)
dht_queue_length--;
GNUNET_free (ma);
}
- while (NULL != (ta = ta_head))
- {
- GNUNET_NAMESTORE_cancel (ta->ns_qe);
- GNUNET_CONTAINER_DLL_remove (ta_head,
- ta_tail,
- ta);
- GNUNET_free (ta);
- }
if (NULL != statistics)
{
GNUNET_STATISTICS_destroy (statistics,
@@ -713,21 +670,6 @@ zone_iteration_finished (void *cls)
}
}
-static void
-ts_store_cont (void *cls, int32_t success, const char *emsg)
-{
- struct TombstoneActivity *ta = cls;
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Tombstone update complete\n");
- GNUNET_CONTAINER_DLL_remove (ta_head,
- ta_tail,
- ta);
- GNUNET_free (ta);
-
-}
-
-
/**
* Function used to put all records successively into the DHT.
*
@@ -749,15 +691,14 @@ put_gns_record (void *cls,
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 = ZMSTR_convert_records_for_export (rd,
- rd_count,
- rd_public,
- &expire);
+ rd_public_count = GNUNET_GNSRECORD_convert_records_for_export (rd,
+ rd_count,
+ rd_public,
+ &expire);
if (0 == rd_public_count)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -790,27 +731,6 @@ put_gns_record (void *cls,
rd_public_count,
expire,
ma);
- ta = GNUNET_new (struct TombstoneActivity);
- 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);
put_cnt++;
if (0 == put_cnt % DELTA_INTERVAL)
update_velocity (DELTA_INTERVAL);
diff --git a/src/zonemaster/zonemaster_misc.c b/src/zonemaster/zonemaster_misc.c
deleted file mode 100644
index f067e9c62..000000000
--- a/src/zonemaster/zonemaster_misc.c
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- 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
deleted file mode 100644
index 27ef3aab7..000000000
--- a/src/zonemaster/zonemaster_misc.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- 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.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnunet] branch master updated: -simlify and correct tombstone logic,
gnunet <=