GNUnet  0.10.x
gnunet-service-zonemaster.c
Go to the documentation of this file.
1 /*
2  This file is part of GNUnet.
3  Copyright (C) 2012, 2013, 2014, 2017, 2018 GNUnet e.V.
4 
5  GNUnet is free software: you can redistribute it and/or modify it
6  under the terms of the GNU Affero General Public License as published
7  by the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  GNUnet is distributed in the hope that it will be useful, but
11  WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Affero General Public License for more details.
14 
15  You should have received a copy of the GNU Affero General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17 
18  SPDX-License-Identifier: AGPL3.0-or-later
19 */
20 
26 #include "platform.h"
27 #include "gnunet_util_lib.h"
28 #include "gnunet_dnsparser_lib.h"
29 #include "gnunet_dht_service.h"
32 
33 
34 #define LOG_STRERROR_FILE(kind,syscall,filename) GNUNET_log_from_strerror_file (kind, "util", syscall, filename)
35 
36 
41 #define PUBLISH_OPS_PER_EXPIRATION 4
42 
48 #define DELTA_INTERVAL 100
49 
53 #define NS_BLOCK_SIZE 1000
54 
58 #define DHT_QUEUE_LIMIT 2000
59 
64 #define NAMESTORE_QUEUE_LIMIT 50
65 
70 #define INITIAL_ZONE_ITERATION_INTERVAL GNUNET_TIME_UNIT_MILLISECONDS
71 
76 #define MAXIMUM_ZONE_ITERATION_INTERVAL GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 15)
77 
82 #define LATE_ITERATION_SPEEDUP_FACTOR 2
83 
87 #define DHT_GNS_REPLICATION_LEVEL 5
88 
89 
93 struct DhtPutActivity
94 {
98  struct DhtPutActivity *next;
99 
103  struct DhtPutActivity *prev;
104 
108  struct GNUNET_DHT_PutHandle *ph;
109 
113  struct GNUNET_TIME_Absolute start_date;
114 };
115 
116 
121 
126 
131 
136 
140 static struct DhtPutActivity *it_head;
141 
145 static struct DhtPutActivity *it_tail;
146 
150 static unsigned int dht_queue_length;
151 
155 static unsigned long long num_public_records;
156 
160 static unsigned long long last_num_public_records;
161 
166 static unsigned long long put_cnt;
167 
176 
182 
188 
193 
199 
205 
213 
218 
223 static unsigned int ns_iteration_left;
224 
229 
234 static int cache_keys;
235 
236 
243 static void
244 shutdown_task (void *cls)
245 {
246  struct DhtPutActivity *ma;
247 
248  (void) cls;
250  "Shutting down!\n");
251  while (NULL != (ma = it_head))
252  {
256  it_tail,
257  ma);
259  GNUNET_free (ma);
260  }
261  if (NULL != statistics)
262  {
263  GNUNET_STATISTICS_destroy (statistics,
264  GNUNET_NO);
265  statistics = NULL;
266  }
267  if (NULL != zone_publish_task)
268  {
269  GNUNET_SCHEDULER_cancel (zone_publish_task);
270  zone_publish_task = NULL;
271  }
272  if (NULL != namestore_iter)
273  {
274  GNUNET_NAMESTORE_zone_iteration_stop (namestore_iter);
275  namestore_iter = NULL;
276  }
277  if (NULL != namestore_handle)
278  {
279  GNUNET_NAMESTORE_disconnect (namestore_handle);
280  namestore_handle = NULL;
281  }
282  if (NULL != dht_handle)
283  {
284  GNUNET_DHT_disconnect (dht_handle);
285  dht_handle = NULL;
286  }
287 }
288 
289 
295 static void
297 {
298  (void) cls;
299  zone_publish_task = NULL;
300  GNUNET_assert (NULL != namestore_iter);
303  GNUNET_NAMESTORE_zone_iterator_next (namestore_iter,
304  NS_BLOCK_SIZE);
305 }
306 
307 
313 static void
314 publish_zone_dht_start (void *cls);
315 
316 
320 static void
322 {
323  if (0 == num_public_records)
324  {
332  "No records in namestore database.\n");
333  }
334  else
335  {
346  }
350  GNUNET_STATISTICS_set (statistics,
351  "Minimum relative record expiration (in μs)",
353  GNUNET_NO);
354  GNUNET_STATISTICS_set (statistics,
355  "Zone publication time window (in μs)",
357  GNUNET_NO);
358  GNUNET_STATISTICS_set (statistics,
359  "Target zone iteration velocity (μs)",
361  GNUNET_NO);
362 }
363 
364 
372 static void
373 update_velocity (unsigned int cnt)
374 {
375  struct GNUNET_TIME_Relative delta;
376  unsigned long long pct = 0;
377 
378  if (0 == cnt)
379  return;
380  /* How fast were we really? */
382  delta.rel_value_us /= cnt;
384 
385  /* calculate expected frequency */
388  {
390  "Last record count was lower than current record count. Reducing interval.\n");
393  }
395  "Desired global zone iteration interval is %s/record!\n",
397  GNUNET_YES));
398 
399  /* Tell statistics actual vs. desired speed */
400  GNUNET_STATISTICS_set (statistics,
401  "Current zone iteration velocity (μs/record)",
402  delta.rel_value_us,
403  GNUNET_NO);
404  /* update "sub_delta" based on difference, taking
405  previous sub_delta into account! */
407  {
408  /* We were too fast, reduce sub_delta! */
409  struct GNUNET_TIME_Relative corr;
410 
412  delta);
413  if (sub_delta.rel_value_us > delta.rel_value_us)
414  {
415  /* Reduce sub_delta by corr */
417  corr);
418  }
419  else
420  {
421  /* We're doing fine with waiting the full time, this
422  should theoretically only happen if we run at
423  infinite speed. */
425  }
426  }
428  {
429  /* We were too slow, increase sub_delta! */
430  struct GNUNET_TIME_Relative corr;
431 
432  corr = GNUNET_TIME_relative_subtract (delta,
435  corr);
437  {
438  /* CPU overload detected, we cannot go at desired speed,
439  as this would mean using a negative delay. */
440  /* compute how much faster we would want to be for
441  the desired velocity */
443  pct = UINT64_MAX; /* desired speed is infinity ... */
444  else
445  pct = (sub_delta.rel_value_us -
449  }
450  }
451  GNUNET_STATISTICS_set (statistics,
452  "# size of the DHT queue (it)",
454  GNUNET_NO);
455  GNUNET_STATISTICS_set (statistics,
456  "% speed increase needed for target velocity",
457  pct,
458  GNUNET_NO);
459  GNUNET_STATISTICS_set (statistics,
460  "# records processed in current iteration",
462  GNUNET_NO);
463 }
464 
465 
470 static void
472 {
473  struct GNUNET_TIME_Relative delay;
474 
475  if (0 != ns_iteration_left)
476  return; /* current NAMESTORE iteration not yet done */
478  put_cnt = 0;
480  sub_delta);
481  /* We delay *once* per #NS_BLOCK_SIZE, so we need to multiply the
482  per-record delay calculated so far with the #NS_BLOCK_SIZE */
483  GNUNET_STATISTICS_set (statistics,
484  "Current artificial NAMESTORE delay (μs/record)",
485  delay.rel_value_us,
486  GNUNET_NO);
487  delay = GNUNET_TIME_relative_multiply (delay,
488  NS_BLOCK_SIZE);
489  /* make sure we do not overshoot because of the #NS_BLOCK_SIZE factor */
491  delay);
492  /* no delays on first iteration */
494  delay = GNUNET_TIME_UNIT_ZERO;
495  GNUNET_assert (NULL == zone_publish_task);
496  zone_publish_task = GNUNET_SCHEDULER_add_delayed (delay,
498  NULL);
499 }
500 
501 
507 static void
509 {
510  struct DhtPutActivity *ma = cls;
511 
513  "PUT complete\n");
516  it_tail,
517  ma);
518  GNUNET_free (ma);
519 }
520 
521 
532 static unsigned int
534  unsigned int rd_count,
535  struct GNUNET_GNSRECORD_Data *rd_public)
536 {
537  struct GNUNET_TIME_Absolute now;
538  unsigned int rd_public_count;
539 
540  rd_public_count = 0;
541  now = GNUNET_TIME_absolute_get ();
542  for (unsigned int i=0;i<rd_count;i++)
543  {
544  if (0 != (rd[i].flags & GNUNET_GNSRECORD_RF_PRIVATE))
545  continue;
546  if ( (0 == (rd[i].flags & GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION)) &&
547  (rd[i].expiration_time < now.abs_value_us) )
548  continue; /* record already expired, skip it */
549  if (0 != (rd[i].flags & GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION))
550  {
551  /* GNUNET_GNSRECORD_block_create will convert to absolute time;
552  we just need to adjust our iteration frequency */
554  GNUNET_MIN (rd[i].expiration_time,
556  }
557  rd_public[rd_public_count++] = rd[i];
558  }
559  return rd_public_count;
560 }
561 
562 
573 static struct GNUNET_DHT_PutHandle *
575  const char *label,
576  const struct GNUNET_GNSRECORD_Data *rd_public,
577  unsigned int rd_public_count,
578  struct DhtPutActivity *ma)
579 {
580  struct GNUNET_GNSRECORD_Block *block;
581  struct GNUNET_HashCode query;
582  struct GNUNET_TIME_Absolute expire;
583  size_t block_size;
584  struct GNUNET_DHT_PutHandle *ret;
585 
586  expire = GNUNET_GNSRECORD_record_get_expiration_time (rd_public_count,
587  rd_public);
588  if (cache_keys)
589  block = GNUNET_GNSRECORD_block_create2 (key,
590  expire,
591  label,
592  rd_public,
593  rd_public_count);
594  else
595  block = GNUNET_GNSRECORD_block_create (key,
596  expire,
597  label,
598  rd_public,
599  rd_public_count);
600  if (NULL == block)
601  {
602  GNUNET_break (0);
603  return NULL; /* whoops */
604  }
605  block_size = ntohl (block->purpose.size)
606  + sizeof (struct GNUNET_CRYPTO_EcdsaSignature)
607  + sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey);
609  label,
610  &query);
611  GNUNET_STATISTICS_update (statistics,
612  "DHT put operations initiated",
613  1,
614  GNUNET_NO);
616  "Storing %u record(s) for label `%s' in DHT with expiration `%s' under key %s\n",
617  rd_public_count,
618  label,
620  GNUNET_h2s (&query));
622  ret = GNUNET_DHT_put (dht_handle,
623  &query,
627  block_size,
628  block,
629  expire,
631  ma);
632  GNUNET_free (block);
633  return ret;
634 }
635 
636 
642 static void
644 {
645  (void) cls;
647  "Got disconnected from namestore database, retrying.\n");
648  namestore_iter = NULL;
649  /* We end up here on error/disconnect/shutdown, so potentially
650  while a zone publish task or a DHT put is still running; hence
651  we need to cancel those. */
652  if (NULL != zone_publish_task)
653  {
654  GNUNET_SCHEDULER_cancel (zone_publish_task);
655  zone_publish_task = NULL;
656  }
657  zone_publish_task = GNUNET_SCHEDULER_add_now (&publish_zone_dht_start,
658  NULL);
659 }
660 
661 
667 static void
669 {
670  (void) cls;
671  /* we're done with one iteration, calculate when to do the next one */
672  namestore_iter = NULL;
677  /* reset for next iteration */
681  "Zone iteration finished. Adjusted zone iteration interval to %s\n",
683  GNUNET_YES));
684  GNUNET_STATISTICS_set (statistics,
685  "Target zone iteration velocity (μs)",
687  GNUNET_NO);
688  GNUNET_STATISTICS_set (statistics,
689  "Number of public records in DHT",
691  GNUNET_NO);
692  GNUNET_assert (NULL == zone_publish_task);
693  if (0 == last_num_public_records)
694  {
697  NULL);
698  }
699  else
700  {
701  zone_publish_task = GNUNET_SCHEDULER_add_now (&publish_zone_dht_start,
702  NULL);
703  }
704 }
705 
706 
716 static void
717 put_gns_record (void *cls,
718  const struct GNUNET_CRYPTO_EcdsaPrivateKey *key,
719  const char *label,
720  unsigned int rd_count,
721  const struct GNUNET_GNSRECORD_Data *rd)
722 {
723  struct GNUNET_GNSRECORD_Data rd_public[rd_count];
724  unsigned int rd_public_count;
725  struct DhtPutActivity *ma;
726 
727  (void) cls;
729  rd_public_count = convert_records_for_export (rd,
730  rd_count,
731  rd_public);
732  if (0 == rd_public_count)
733  {
735  "Record set empty, moving to next record set\n");
737  return;
738  }
739  /* We got a set of records to publish */
741  "Starting DHT PUT\n");
742  ma = GNUNET_new (struct DhtPutActivity);
744  ma->ph = perform_dht_put (key,
745  label,
746  rd_public,
747  rd_public_count,
748  ma);
749  put_cnt++;
750  if (0 == put_cnt % DELTA_INTERVAL)
751  update_velocity (DELTA_INTERVAL);
753  if (NULL == ma->ph)
754  {
756  "Could not perform DHT PUT, is the DHT running?\n");
757  GNUNET_free (ma);
758  return;
759  }
762  it_tail,
763  ma);
765  {
766  ma = it_head;
768  it_tail,
769  ma);
773  "DHT PUT unconfirmed after %s, aborting PUT\n",
775  GNUNET_YES));
776  GNUNET_free (ma);
777  }
778 }
779 
780 
786 static void
788 {
789  (void) cls;
790  zone_publish_task = NULL;
791  GNUNET_STATISTICS_update (statistics,
792  "Full zone iterations launched",
793  1,
794  GNUNET_NO);
796  "Starting DHT zone update!\n");
797  /* start counting again */
798  num_public_records = 0;
799  GNUNET_assert (NULL == namestore_iter);
800  ns_iteration_left = 1;
801  namestore_iter
802  = GNUNET_NAMESTORE_zone_iteration_start (namestore_handle,
803  NULL, /* All zones */
805  NULL,
807  NULL,
809  NULL);
810  GNUNET_assert (NULL != namestore_iter);
811 }
812 
813 
821 static void
822 run (void *cls,
823  const struct GNUNET_CONFIGURATION_Handle *c,
825 {
826  unsigned long long max_parallel_bg_queries = 128;
827 
828  (void) cls;
829  (void) service;
830  last_put_100 = GNUNET_TIME_absolute_get (); /* first time! */
834  namestore_handle = GNUNET_NAMESTORE_connect (c);
835  if (NULL == namestore_handle)
836  {
838  _("Failed to connect to the namestore!\n"));
840  return;
841  }
843  "namestore",
844  "CACHE_KEYS");
846  if (GNUNET_OK ==
848  "zonemaster",
849  "ZONE_PUBLISH_TIME_WINDOW",
851  {
853  "Time window for zone iteration: %s\n",
855  GNUNET_YES));
856  }
858  if (GNUNET_OK ==
860  "zonemaster",
861  "MAX_PARALLEL_BACKGROUND_QUERIES",
862  &max_parallel_bg_queries))
863  {
865  "Number of allowed parallel background queries: %llu\n",
866  max_parallel_bg_queries);
867  }
868  if (0 == max_parallel_bg_queries)
869  max_parallel_bg_queries = 1;
870  dht_handle = GNUNET_DHT_connect (c,
871  (unsigned int) max_parallel_bg_queries);
872  if (NULL == dht_handle)
873  {
875  _("Could not connect to DHT!\n"));
877  NULL);
878  return;
879  }
880 
881  /* Schedule periodic put for our records. */
883  statistics = GNUNET_STATISTICS_create ("zonemaster",
884  c);
885  GNUNET_STATISTICS_set (statistics,
886  "Target zone iteration velocity (μs)",
888  GNUNET_NO);
889  zone_publish_task = GNUNET_SCHEDULER_add_now (&publish_zone_dht_start,
890  NULL);
892  NULL);
893 }
894 
895 
900 ("zonemaster",
902  &run,
903  NULL,
904  NULL,
905  NULL,
907 
908 
909 /* end of gnunet-service-zonemaster.c */
static void dht_put_continuation(void *cls)
Continuation called from DHT once the PUT operation is done.
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
static struct GNUNET_TIME_Relative min_relative_record_time
Minimum relative expiration time of records seem during the current zone iteration.
#define NS_BLOCK_SIZE
How many records do we fetch in one shot from the namestore?
GNUNET_SERVICE_MAIN("zonemaster", GNUNET_SERVICE_OPTION_NONE, &run, NULL, NULL, NULL, GNUNET_MQ_handler_end())
Define "main" method using service macro.
static struct GNUNET_SERVICE_Handle * service
Handle to our service instance.
struct GNUNET_DHT_PutHandle * ph
Handle for the DHT PUT operation.
int GNUNET_CONFIGURATION_get_value_time(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, struct GNUNET_TIME_Relative *time)
Get a configuration value that should be a relative time.
struct DhtPutActivity * prev
Kept in a DLL.
int GNUNET_CONFIGURATION_get_value_number(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, unsigned long long *number)
Get a configuration value that should be a number.
uint64_t rel_value_us
The actual value.
void GNUNET_DHT_put_cancel(struct GNUNET_DHT_PutHandle *ph)
Cancels a DHT PUT operation.
Definition: dht_api.c:1040
static void shutdown_task(void *cls)
Task run during shutdown.
static void update_velocity(unsigned int cnt)
Re-calculate our velocity and the desired velocity.
static unsigned long long last_num_public_records
Last seen record count.
struct GNUNET_GNSRECORD_Block * GNUNET_GNSRECORD_block_create(const struct GNUNET_CRYPTO_EcdsaPrivateKey *key, struct GNUNET_TIME_Absolute expire, const char *label, const struct GNUNET_GNSRECORD_Data *rd, unsigned int rd_count)
Sign name and records.
Handle to a service.
Definition: service.c:116
static unsigned int dht_queue_length
Number of entries in the DHT queue it_head.
static int first_zone_iteration
GNUNET_YES if zone has never been published before
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_shutdown(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run on shutdown, that is when a CTRL-C signal is received, or when GNUNET_SCHEDULER_shutdown() is being invoked.
Definition: scheduler.c:1293
struct GNUNET_NAMESTORE_ZoneIterator * GNUNET_NAMESTORE_zone_iteration_start(struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, GNUNET_SCHEDULER_TaskCallback error_cb, void *error_cb_cls, GNUNET_NAMESTORE_RecordMonitor proc, void *proc_cls, GNUNET_SCHEDULER_TaskCallback finish_cb, void *finish_cb_cls)
Starts a new zone iteration (used to periodically PUT all of our records into our DHT)...
#define DELTA_INTERVAL
How often do we measure the delta between desired zone iteration speed and actual speed...
static struct GNUNET_DHT_PutHandle * perform_dht_put(const struct GNUNET_CRYPTO_EcdsaPrivateKey *key, const char *label, const struct GNUNET_GNSRECORD_Data *rd_public, unsigned int rd_public_count, struct DhtPutActivity *ma)
Store GNS records in the DHT.
struct GNUNET_STATISTICS_Handle * GNUNET_STATISTICS_create(const char *subsystem, const struct GNUNET_CONFIGURATION_Handle *cfg)
Get handle for the statistics service.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
static void zone_iteration_error(void *cls)
We encountered an error in our zone iteration.
struct GNUNET_GNSRECORD_Block * GNUNET_GNSRECORD_block_create2(const struct GNUNET_CRYPTO_EcdsaPrivateKey *key, struct GNUNET_TIME_Absolute expire, const char *label, const struct GNUNET_GNSRECORD_Data *rd, unsigned int rd_count)
Sign name and records, cache derived public key (also keeps the private key in static memory...
struct GNUNET_TIME_Absolute start_date
When was this PUT initiated?
static struct GNUNET_TIME_Relative zone_publish_time_window
Time window for zone iteration, adjusted based on relative record expiration times in our zone...
static void publish_zone_namestore_next(void *cls)
Method called periodically that triggers iteration over authoritative records.
static struct GNUNET_TIME_Relative zone_publish_time_window_default
Default time window for zone iteration.
#define GNUNET_NO
Definition: gnunet_common.h:81
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
#define GNUNET_new(type)
Allocate a struct or union of the given type.
void GNUNET_NAMESTORE_zone_iterator_next(struct GNUNET_NAMESTORE_ZoneIterator *it, uint64_t limit)
Calls the record processor specified in GNUNET_NAMESTORE_zone_iteration_start for the next record...
Private ECC key encoded for transmission.
static struct DhtPutActivity * it_tail
Tail of iteration put activities; kept in a DLL.
#define PUBLISH_OPS_PER_EXPIRATION
How often should we (re)publish each record before it expires?
Information we have in an encrypted block with record data (i.e.
void GNUNET_STATISTICS_destroy(struct GNUNET_STATISTICS_Handle *h, int sync_first)
Destroy a handle (free all state associated with it).
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:524
static int ret
Final status code.
Definition: gnunet-arm.c:89
Handle for the service.
static struct GNUNET_TIME_Relative last_min_relative_record_time
Minimum relative expiration time of records seem during the last zone iteration.
uint64_t abs_value_us
The actual value.
static unsigned long long num_public_records
Useful for zone update for DHT put.
static void put_gns_record(void *cls, const struct GNUNET_CRYPTO_EcdsaPrivateKey *key, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
Function used to put all records successively into the DHT.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
Handle for DHT PUT activity triggered from the namestore monitor.
Connection to the DHT service.
Definition: dht_api.c:205
#define MAXIMUM_ZONE_ITERATION_INTERVAL
The upper bound for the zone iteration interval (per record).
static struct GNUNET_STATISTICS_Handle * statistics
Handle to the statistics service.
#define _(String)
GNU gettext support macro.
Definition: platform.h:208
#define GNUNET_DHT_DEFAULT_REPUBLISH_FREQUENCY
Default republication frequency for stored data in the DHT.
void GNUNET_GNSRECORD_query_from_private_key(const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, const char *label, struct GNUNET_HashCode *query)
Calculate the DHT query for a given label in a given zone.
void GNUNET_NAMESTORE_disconnect(struct GNUNET_NAMESTORE_Handle *h)
Disconnect from the namestore service (and free associated resources).
Handle for a zone iterator operation.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_delayed(struct GNUNET_TIME_Relative delay, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay.
Definition: scheduler.c:1246
static unsigned int convert_records_for_export(const struct GNUNET_GNSRECORD_Data *rd, unsigned int rd_count, struct GNUNET_GNSRECORD_Data *rd_public)
Convert namestore records from the internal format to that suitable for publication (removes private ...
#define LATE_ITERATION_SPEEDUP_FACTOR
The factor the current zone iteration interval is divided by for each additional new record...
Connection to the NAMESTORE service.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
Definition: scheduler.c:1273
#define INITIAL_ZONE_ITERATION_INTERVAL
The initial interval in milliseconds btween puts in a zone iteration.
#define GNUNET_MIN(a, b)
Definition: gnunet_common.h:83
static void calculate_put_interval()
Calculate target_iteration_velocity_per_record.
const char * GNUNET_STRINGS_relative_time_to_string(struct GNUNET_TIME_Relative delta, int do_round)
Give relative time in human-readable fancy format.
Definition: strings.c:727
#define DHT_GNS_REPLICATION_LEVEL
What replication level do we use for DHT PUT operations?
an ECC signature using ECDSA
static struct GNUNET_TIME_Relative sub_delta
By how much should we try to increase our per-record iteration speed (over the desired speed calculat...
struct GNUNET_TIME_Relative GNUNET_TIME_relative_multiply(struct GNUNET_TIME_Relative rel, unsigned long long factor)
Multiply relative time by a given factor.
Definition: time.c:439
#define GNUNET_TIME_UNIT_FOREVER_REL
Constant used to specify "forever".
This is a private record of this peer and it should thus not be handed out to other peers...
uint32_t size
How many bytes does this signature sign? (including this purpose header); in network byte order (!)...
struct GNUNET_TIME_Relative GNUNET_TIME_relative_subtract(struct GNUNET_TIME_Relative a1, struct GNUNET_TIME_Relative a2)
Subtract relative timestamp from the other.
Definition: time.c:601
void GNUNET_STATISTICS_set(struct GNUNET_STATISTICS_Handle *handle, const char *name, uint64_t value, int make_persistent)
Set statistic value for the peer.
Block for storing record data.
void GNUNET_NAMESTORE_zone_iteration_stop(struct GNUNET_NAMESTORE_ZoneIterator *it)
Stops iteration and releases the namestore handle for further calls.
A 512-bit hashcode.
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition: time.c:118
struct GNUNET_TIME_Absolute GNUNET_GNSRECORD_record_get_expiration_time(unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
Returns the expiration time of the given block of records.
struct GNUNET_TIME_Relative GNUNET_TIME_relative_min(struct GNUNET_TIME_Relative t1, struct GNUNET_TIME_Relative t2)
Return the minimum of two relative time values.
Definition: time.c:271
struct GNUNET_HashCode key
The key used in the DHT.
struct GNUNET_DHT_PutHandle * GNUNET_DHT_put(struct GNUNET_DHT_Handle *handle, const struct GNUNET_HashCode *key, uint32_t desired_replication_level, enum GNUNET_DHT_RouteOption options, enum GNUNET_BLOCK_Type type, size_t size, const void *data, struct GNUNET_TIME_Absolute exp, GNUNET_SCHEDULER_TaskCallback cont, void *cont_cls)
Perform a PUT operation storing data in the DHT.
Definition: dht_api.c:971
#define DHT_QUEUE_LIMIT
How many pending DHT operations do we allow at most?
static struct DhtPutActivity * it_head
Head of iteration put activities; kept in a DLL.
struct GNUNET_DHT_Handle * GNUNET_DHT_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, unsigned int ht_len)
Initialize the connection with the DHT service.
Definition: dht_api.c:895
static struct GNUNET_DHT_Handle * dht_handle
Our handle to the DHT.
struct GNUNET_NAMESTORE_Handle * GNUNET_NAMESTORE_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the namestore service.
void GNUNET_DHT_disconnect(struct GNUNET_DHT_Handle *handle)
Shutdown connection with the DHT service.
Definition: dht_api.c:923
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
static struct GNUNET_NAMESTORE_ZoneIterator * namestore_iter
Handle to iterate over our authoritative zone in namestore.
static struct GNUNET_TIME_Relative target_iteration_velocity_per_record
What is the frequency at which we currently would like to perform DHT puts (per record)? Calculated in update_velocity() from the zone_publish_time_window() and the total number of record sets we have (so far) observed in the zone.
#define GNUNET_TIME_UNIT_ZERO
Relative time zero.
static void check_zone_namestore_next()
Check if the current zone iteration needs to be continued by calling publish_zone_namestore_next(), and if so with what delay.
static struct GNUNET_SCHEDULER_Task * zone_publish_task
zone publish task
static void publish_zone_dht_start(void *cls)
Periodically iterate over our zone and store everything in dht.
static int cache_keys
Optimize block insertion by caching map of private keys to public keys in memory? ...
struct GNUNET_TIME_Relative GNUNET_TIME_relative_add(struct GNUNET_TIME_Relative a1, struct GNUNET_TIME_Relative a2)
Add relative times together.
Definition: time.c:576
Handle to a PUT request.
Definition: dht_api.c:43
configuration data
Definition: configuration.c:85
static unsigned int ns_iteration_left
How many more values are left for the current query before we need to explicitly ask the namestore fo...
static unsigned long long put_cnt
Number of successful put operations performed in the current measurement cycle (as measured in check_...
struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_duration(struct GNUNET_TIME_Absolute whence)
Get the duration of an operation as the difference of the current time and the given start time "henc...
Definition: time.c:373
static struct GNUNET_NAMESTORE_Handle * namestore_handle
Our handle to the namestore service.
static void run(void *cls, const struct GNUNET_CONFIGURATION_Handle *c, struct GNUNET_SERVICE_Handle *service)
Performe zonemaster duties: watch namestore, publish records.
#define GNUNET_log(kind,...)
Entry in list of pending tasks.
Definition: scheduler.c:134
static struct GNUNET_TIME_Absolute last_put_100
When did we last start measuring the DELTA_INTERVAL successful DHT puts? Used for velocity calculatio...
static void zone_iteration_finished(void *cls)
Zone iteration is completed.
struct GNUNET_TIME_Relative GNUNET_TIME_relative_divide(struct GNUNET_TIME_Relative rel, unsigned long long factor)
Divide relative time by a given factor.
Definition: time.c:525
Time for absolute times used by GNUnet, in microseconds.
#define GNUNET_YES
Definition: gnunet_common.h:80
This flag is currently unused; former RF_PENDING flag.
const char * GNUNET_STRINGS_absolute_time_to_string(struct GNUNET_TIME_Absolute t)
Like asctime, except for GNUnet time.
Definition: strings.c:792
int GNUNET_CONFIGURATION_get_value_yesno(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option)
Get a configuration value that should be in a set of "YES" or "NO".
struct GNUNET_CRYPTO_EccSignaturePurpose purpose
Number of bytes signed; also specifies the number of bytes of encrypted data that follow...
struct DhtPutActivity * next
Kept in a DLL.
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
Each peer along the way should look at &#39;enc&#39; (otherwise only the k-peers closest to the key should lo...
#define GNUNET_free(ptr)
Wrapper around free.
Time for relative time used by GNUnet, in microseconds.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:965