/**
* Process a record that was stored in the namestore.
*
- * @param cls closure
- * @param zone_key private key of the zone
* @param rname name that is being mapped (at most 255 characters long)
* @param rd_len number of entries in @a rd array
* @param rd array of records with data to store
*/
static void
-display_record (void *cls,
- const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone_key,
- const char *rname,
+display_record (const char *rname,
unsigned int rd_len,
const struct GNUNET_GNSRECORD_Data *rd)
{
struct GNUNET_TIME_Absolute at;
struct GNUNET_TIME_Relative rt;
- (void) cls;
- (void) zone_key;
if ( (NULL != name) &&
(0 != strcmp (name, rname)) )
{
GNUNET_free (s);
}
FPRINTF (stdout, "%s", "\n");
+}
+
+
+/**
+ * Process a record that was stored in the namestore.
+ *
+ * @param cls closure
+ * @param zone_key private key of the zone
+ * @param rname name that is being mapped (at most 255 characters long)
+ * @param rd_len number of entries in @a rd array
+ * @param rd array of records with data to store
+ */
+static void
+display_record_iterator (void *cls,
+ const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone_key,
+ const char *rname,
+ unsigned int rd_len,
+ const struct GNUNET_GNSRECORD_Data *rd)
+{
+ (void) cls;
+ (void) zone_key;
+ display_record (rname,
+ rd_len,
+ rd);
GNUNET_NAMESTORE_zone_iterator_next (list_it,
1);
}
+/**
+ * Process a record that was stored in the namestore.
+ *
+ * @param cls closure
+ * @param zone_key private key of the zone
+ * @param rname name that is being mapped (at most 255 characters long)
+ * @param rd_len number of entries in @a rd array
+ * @param rd array of records with data to store
+ */
+static void
+display_record_monitor (void *cls,
+ const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone_key,
+ const char *rname,
+ unsigned int rd_len,
+ const struct GNUNET_GNSRECORD_Data *rd)
+{
+ (void) cls;
+ (void) zone_key;
+ display_record (rname,
+ rd_len,
+ rd);
+ GNUNET_NAMESTORE_zone_monitor_next (zm,
+ 1);
+}
+
+
/**
* Function called once we are in sync in monitor mode.
*
&zone_pkey,
&zone_iteration_error_cb,
NULL,
- &display_record,
+ &display_record_iterator,
NULL,
&zone_iteration_finished,
NULL);
GNUNET_YES,
&monitor_error_cb,
NULL,
- &display_record,
+ &display_record_monitor,
NULL,
&sync_cb,
NULL);
/*
This file is part of GNUnet.
- Copyright (C) 2013 GNUnet e.V.
+ Copyright (C) 2013, 2018 GNUnet e.V.
GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
GNUNET_break (0);
fail = GNUNET_YES;
}
-
+ GNUNET_NAMESTORE_zone_monitor_next (zm,
+ 1);
if (2 == ++returned_records)
{
if (endbadly_task != NULL)
"Comparing results name %s\n",
name);
- if (0 != memcmp (zone_key, privkey, sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey)))
+ if (0 != memcmp (zone_key,
+ privkey,
+ sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey)))
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Monitoring returned wrong zone key\n");
GNUNET_break (0);
GNUNET_SCHEDULER_cancel (endbadly_task);
- endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly, NULL);
+ endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly,
+ NULL);
return;
}
if (0 == strcmp (name, s_name_1))
{
- if (GNUNET_YES != GNUNET_GNSRECORD_records_cmp(rd, s_rd_1))
+ if (GNUNET_YES !=
+ GNUNET_GNSRECORD_records_cmp (rd,
+ s_rd_1))
{
GNUNET_break (0);
fail = GNUNET_YES;
}
else if (0 == strcmp (name, s_name_2))
{
- if (GNUNET_YES != GNUNET_GNSRECORD_records_cmp(rd, s_rd_2))
+ if (GNUNET_YES !=
+ GNUNET_GNSRECORD_records_cmp (rd,
+ s_rd_2))
{
GNUNET_break (0);
fail = GNUNET_YES;
GNUNET_break (0);
fail = GNUNET_YES;
}
-
+ GNUNET_NAMESTORE_zone_monitor_next (zm,
+ 1);
if (2 == ++returned_records)
{
if (endbadly_task != NULL)
endbadly_task = NULL;
}
if (GNUNET_YES == fail)
- GNUNET_SCHEDULER_add_now (&endbadly, NULL);
+ GNUNET_SCHEDULER_add_now (&endbadly,
+ NULL);
else
- GNUNET_SCHEDULER_add_now (&end, NULL);
+ GNUNET_SCHEDULER_add_now (&end,
+ NULL);
}
}
static void
-put_cont (void *cls, int32_t success, const char *emsg)
+put_cont (void *cls,
+ int32_t success,
+ const char *emsg)
{
static int c = 0;
char *label = cls;
if (success == GNUNET_OK)
{
c++;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created record %u: `%s'\n", c, label);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Created record %u: `%s'\n",
+ c,
+ label);
}
else
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to created records\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Failed to created records\n");
GNUNET_break (0);
GNUNET_SCHEDULER_cancel (endbadly_task);
endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly, NULL);
NULL);
if (NULL == zm)
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to create zone monitor\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Failed to create zone monitor\n");
GNUNET_break (0);
- endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly, NULL);
+ endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly,
+ NULL);
return;
}
}
GNUNET_assert (NULL != (ns_ops[0] = GNUNET_NAMESTORE_records_store(nsh, privkey, s_name_1,
1, s_rd_1, &put_cont, s_name_1)));
-
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created record 2 \n");
GNUNET_asprintf(&s_name_2, "dummy2");
s_rd_2 = create_record(1);
- GNUNET_assert (NULL != (ns_ops[1] = GNUNET_NAMESTORE_records_store(nsh, privkey, s_name_2,
- 1, s_rd_2, &put_cont, s_name_2)));
-
-
+ GNUNET_assert (NULL != (ns_ops[1] =
+ GNUNET_NAMESTORE_records_store (nsh,
+ privkey,
+ s_name_2,
+ 1,
+ s_rd_2,
+ &put_cont,
+ s_name_2)));
}
*/
#define DHT_QUEUE_LIMIT 2000
+/**
+ * How many events may the namestore give us before it has to wait
+ * for us to keep up?
+ */
+#define NAMESTORE_QUEUE_LIMIT 50
+
/**
* The initial interval in milliseconds btween puts in
* a zone iteration
{
struct DhtPutActivity *ma = cls;
+ GNUNET_NAMESTORE_zone_monitor_next (zmon,
+ 1);
ma_queue_length--;
GNUNET_CONTAINER_DLL_remove (ma_head,
ma_tail,
rd_count,
rd_public);
if (0 == rd_public_count)
+ {
+ GNUNET_NAMESTORE_zone_monitor_next (zmon,
+ 1);
return; /* nothing to do */
+ }
num_public_records++;
ma = GNUNET_new (struct DhtPutActivity);
ma->start_date = GNUNET_TIME_absolute_get ();
{
/* PUT failed, do not remember operation */
GNUNET_free (ma);
+ GNUNET_NAMESTORE_zone_monitor_next (zmon,
+ 1);
return;
}
GNUNET_CONTAINER_DLL_insert_tail (ma_head,
NULL,
&monitor_sync_event,
NULL);
+ GNUNET_NAMESTORE_zone_monitor_next (zmon,
+ NAMESTORE_QUEUE_LIMIT - 1);
GNUNET_break (NULL != zmon);
GNUNET_SCHEDULER_add_shutdown (&shutdown_task,
NULL);