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 {
97  struct DhtPutActivity *next;
98 
102  struct DhtPutActivity *prev;
103 
107  struct GNUNET_DHT_PutHandle *ph;
108 
112  struct GNUNET_TIME_Absolute start_date;
113 };
114 
115 
120 
125 
130 
135 
139 static struct DhtPutActivity *it_head;
140 
144 static struct DhtPutActivity *it_tail;
145 
149 static unsigned int dht_queue_length;
150 
154 static unsigned long long num_public_records;
155 
159 static unsigned long long last_num_public_records;
160 
165 static unsigned long long put_cnt;
166 
175 
181 
187 
192 
198 
204 
212 
217 
222 static unsigned int ns_iteration_left;
223 
228 
233 static int cache_keys;
234 
235 
242 static void
243 shutdown_task(void *cls)
244 {
245  struct DhtPutActivity *ma;
246 
247  (void)cls;
249  "Shutting down!\n");
250  while (NULL != (ma = it_head))
251  {
255  it_tail,
256  ma);
258  GNUNET_free(ma);
259  }
260  if (NULL != statistics)
261  {
262  GNUNET_STATISTICS_destroy(statistics,
263  GNUNET_NO);
264  statistics = NULL;
265  }
266  if (NULL != zone_publish_task)
267  {
268  GNUNET_SCHEDULER_cancel(zone_publish_task);
269  zone_publish_task = NULL;
270  }
271  if (NULL != namestore_iter)
272  {
273  GNUNET_NAMESTORE_zone_iteration_stop(namestore_iter);
274  namestore_iter = NULL;
275  }
276  if (NULL != namestore_handle)
277  {
278  GNUNET_NAMESTORE_disconnect(namestore_handle);
279  namestore_handle = NULL;
280  }
281  if (NULL != dht_handle)
282  {
283  GNUNET_DHT_disconnect(dht_handle);
284  dht_handle = NULL;
285  }
286 }
287 
288 
294 static void
296 {
297  (void)cls;
298  zone_publish_task = NULL;
299  GNUNET_assert(NULL != namestore_iter);
303  NS_BLOCK_SIZE);
304 }
305 
306 
312 static void
313 publish_zone_dht_start(void *cls);
314 
315 
319 static void
321 {
322  if (0 == num_public_records)
323  {
331  "No records in namestore database.\n");
332  }
333  else
334  {
345  }
349  GNUNET_STATISTICS_set(statistics,
350  "Minimum relative record expiration (in μs)",
352  GNUNET_NO);
353  GNUNET_STATISTICS_set(statistics,
354  "Zone publication time window (in μs)",
356  GNUNET_NO);
357  GNUNET_STATISTICS_set(statistics,
358  "Target zone iteration velocity (μs)",
360  GNUNET_NO);
361 }
362 
363 
371 static void
372 update_velocity(unsigned int cnt)
373 {
374  struct GNUNET_TIME_Relative delta;
375  unsigned long long pct = 0;
376 
377  if (0 == cnt)
378  return;
379  /* How fast were we really? */
381  delta.rel_value_us /= cnt;
383 
384  /* calculate expected frequency */
387  {
389  "Last record count was lower than current record count. Reducing interval.\n");
392  }
394  "Desired global zone iteration interval is %s/record!\n",
396  GNUNET_YES));
397 
398  /* Tell statistics actual vs. desired speed */
399  GNUNET_STATISTICS_set(statistics,
400  "Current zone iteration velocity (μs/record)",
401  delta.rel_value_us,
402  GNUNET_NO);
403  /* update "sub_delta" based on difference, taking
404  previous sub_delta into account! */
406  {
407  /* We were too fast, reduce sub_delta! */
408  struct GNUNET_TIME_Relative corr;
409 
411  delta);
412  if (sub_delta.rel_value_us > delta.rel_value_us)
413  {
414  /* Reduce sub_delta by corr */
416  corr);
417  }
418  else
419  {
420  /* We're doing fine with waiting the full time, this
421  should theoretically only happen if we run at
422  infinite speed. */
424  }
425  }
427  {
428  /* We were too slow, increase sub_delta! */
429  struct GNUNET_TIME_Relative corr;
430 
431  corr = GNUNET_TIME_relative_subtract(delta,
434  corr);
436  {
437  /* CPU overload detected, we cannot go at desired speed,
438  as this would mean using a negative delay. */
439  /* compute how much faster we would want to be for
440  the desired velocity */
442  pct = UINT64_MAX; /* desired speed is infinity ... */
443  else
444  pct = (sub_delta.rel_value_us -
448  }
449  }
450  GNUNET_STATISTICS_set(statistics,
451  "# size of the DHT queue (it)",
453  GNUNET_NO);
454  GNUNET_STATISTICS_set(statistics,
455  "% speed increase needed for target velocity",
456  pct,
457  GNUNET_NO);
458  GNUNET_STATISTICS_set(statistics,
459  "# records processed in current iteration",
461  GNUNET_NO);
462 }
463 
464 
469 static void
471 {
472  struct GNUNET_TIME_Relative delay;
473 
474  if (0 != ns_iteration_left)
475  return; /* current NAMESTORE iteration not yet done */
477  put_cnt = 0;
479  sub_delta);
480  /* We delay *once* per #NS_BLOCK_SIZE, so we need to multiply the
481  per-record delay calculated so far with the #NS_BLOCK_SIZE */
482  GNUNET_STATISTICS_set(statistics,
483  "Current artificial NAMESTORE delay (μs/record)",
484  delay.rel_value_us,
485  GNUNET_NO);
486  delay = GNUNET_TIME_relative_multiply(delay,
487  NS_BLOCK_SIZE);
488  /* make sure we do not overshoot because of the #NS_BLOCK_SIZE factor */
490  delay);
491  /* no delays on first iteration */
493  delay = GNUNET_TIME_UNIT_ZERO;
494  GNUNET_assert(NULL == zone_publish_task);
495  zone_publish_task = GNUNET_SCHEDULER_add_delayed(delay,
497  NULL);
498 }
499 
500 
506 static void
508 {
509  struct DhtPutActivity *ma = cls;
510 
512  "PUT complete\n");
515  it_tail,
516  ma);
517  GNUNET_free(ma);
518 }
519 
520 
531 static unsigned int
533  unsigned int rd_count,
534  struct GNUNET_GNSRECORD_Data *rd_public)
535 {
536  struct GNUNET_TIME_Absolute now;
537  unsigned int rd_public_count;
538 
539  rd_public_count = 0;
540  now = GNUNET_TIME_absolute_get();
541  for (unsigned int i = 0; i < rd_count; i++)
542  {
543  if (0 != (rd[i].flags & GNUNET_GNSRECORD_RF_PRIVATE))
544  continue;
545  if ((0 == (rd[i].flags & GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION)) &&
546  (rd[i].expiration_time < now.abs_value_us))
547  continue; /* record already expired, skip it */
548  if (0 != (rd[i].flags & GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION))
549  {
550  /* GNUNET_GNSRECORD_block_create will convert to absolute time;
551  we just need to adjust our iteration frequency */
553  GNUNET_MIN(rd[i].expiration_time,
555  }
556  rd_public[rd_public_count++] = rd[i];
557  }
558  return rd_public_count;
559 }
560 
561 
572 static struct GNUNET_DHT_PutHandle *
574  const char *label,
575  const struct GNUNET_GNSRECORD_Data *rd_public,
576  unsigned int rd_public_count,
577  struct DhtPutActivity *ma)
578 {
579  struct GNUNET_GNSRECORD_Block *block;
580  struct GNUNET_HashCode query;
581  struct GNUNET_TIME_Absolute expire;
582  size_t block_size;
583  struct GNUNET_DHT_PutHandle *ret;
584 
585  expire = GNUNET_GNSRECORD_record_get_expiration_time(rd_public_count,
586  rd_public);
587  if (cache_keys)
588  block = GNUNET_GNSRECORD_block_create2(key,
589  expire,
590  label,
591  rd_public,
592  rd_public_count);
593  else
594  block = GNUNET_GNSRECORD_block_create(key,
595  expire,
596  label,
597  rd_public,
598  rd_public_count);
599  if (NULL == block)
600  {
601  GNUNET_break(0);
602  return NULL; /* whoops */
603  }
604  block_size = ntohl(block->purpose.size)
605  + sizeof(struct GNUNET_CRYPTO_EcdsaSignature)
606  + sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey);
608  label,
609  &query);
610  GNUNET_STATISTICS_update(statistics,
611  "DHT put operations initiated",
612  1,
613  GNUNET_NO);
615  "Storing %u record(s) for label `%s' in DHT with expiration `%s' under key %s\n",
616  rd_public_count,
617  label,
619  GNUNET_h2s(&query));
621  ret = GNUNET_DHT_put(dht_handle,
622  &query,
626  block_size,
627  block,
628  expire,
630  ma);
631  GNUNET_free(block);
632  return ret;
633 }
634 
635 
641 static void
643 {
644  (void)cls;
646  "Got disconnected from namestore database, retrying.\n");
647  namestore_iter = NULL;
648  /* We end up here on error/disconnect/shutdown, so potentially
649  while a zone publish task or a DHT put is still running; hence
650  we need to cancel those. */
651  if (NULL != zone_publish_task)
652  {
653  GNUNET_SCHEDULER_cancel(zone_publish_task);
654  zone_publish_task = NULL;
655  }
657  NULL);
658 }
659 
660 
666 static void
668 {
669  (void)cls;
670  /* we're done with one iteration, calculate when to do the next one */
671  namestore_iter = NULL;
676  /* reset for next iteration */
680  "Zone iteration finished. Adjusted zone iteration interval to %s\n",
682  GNUNET_YES));
683  GNUNET_STATISTICS_set(statistics,
684  "Target zone iteration velocity (μs)",
686  GNUNET_NO);
687  GNUNET_STATISTICS_set(statistics,
688  "Number of public records in DHT",
690  GNUNET_NO);
691  GNUNET_assert(NULL == zone_publish_task);
692  if (0 == last_num_public_records)
693  {
696  NULL);
697  }
698  else
699  {
701  NULL);
702  }
703 }
704 
705 
715 static void
716 put_gns_record(void *cls,
717  const struct GNUNET_CRYPTO_EcdsaPrivateKey *key,
718  const char *label,
719  unsigned int rd_count,
720  const struct GNUNET_GNSRECORD_Data *rd)
721 {
722  struct GNUNET_GNSRECORD_Data rd_public[rd_count];
723  unsigned int rd_public_count;
724  struct DhtPutActivity *ma;
725 
726  (void)cls;
728  rd_public_count = convert_records_for_export(rd,
729  rd_count,
730  rd_public);
731  if (0 == rd_public_count)
732  {
734  "Record set empty, moving to next record set\n");
736  return;
737  }
738  /* We got a set of records to publish */
740  "Starting DHT PUT\n");
741  ma = GNUNET_new(struct DhtPutActivity);
743  ma->ph = perform_dht_put(key,
744  label,
745  rd_public,
746  rd_public_count,
747  ma);
748  put_cnt++;
749  if (0 == put_cnt % DELTA_INTERVAL)
750  update_velocity(DELTA_INTERVAL);
752  if (NULL == ma->ph)
753  {
755  "Could not perform DHT PUT, is the DHT running?\n");
756  GNUNET_free(ma);
757  return;
758  }
761  it_tail,
762  ma);
764  {
765  ma = it_head;
767  it_tail,
768  ma);
772  "DHT PUT unconfirmed after %s, aborting PUT\n",
774  GNUNET_YES));
775  GNUNET_free(ma);
776  }
777 }
778 
779 
785 static void
787 {
788  (void)cls;
789  zone_publish_task = NULL;
790  GNUNET_STATISTICS_update(statistics,
791  "Full zone iterations launched",
792  1,
793  GNUNET_NO);
795  "Starting DHT zone update!\n");
796  /* start counting again */
797  num_public_records = 0;
798  GNUNET_assert(NULL == namestore_iter);
799  ns_iteration_left = 1;
800  namestore_iter
801  = GNUNET_NAMESTORE_zone_iteration_start(namestore_handle,
802  NULL, /* All zones */
804  NULL,
806  NULL,
808  NULL);
809  GNUNET_assert(NULL != namestore_iter);
810 }
811 
812 
820 static void
821 run(void *cls,
822  const struct GNUNET_CONFIGURATION_Handle *c,
824 {
825  unsigned long long max_parallel_bg_queries = 128;
826 
827  (void)cls;
828  (void)service;
829  last_put_100 = GNUNET_TIME_absolute_get(); /* first time! */
833  namestore_handle = GNUNET_NAMESTORE_connect(c);
834  if (NULL == namestore_handle)
835  {
837  _("Failed to connect to the namestore!\n"));
839  return;
840  }
842  "namestore",
843  "CACHE_KEYS");
845  if (GNUNET_OK ==
847  "zonemaster",
848  "ZONE_PUBLISH_TIME_WINDOW",
850  {
852  "Time window for zone iteration: %s\n",
854  GNUNET_YES));
855  }
857  if (GNUNET_OK ==
859  "zonemaster",
860  "MAX_PARALLEL_BACKGROUND_QUERIES",
861  &max_parallel_bg_queries))
862  {
864  "Number of allowed parallel background queries: %llu\n",
865  max_parallel_bg_queries);
866  }
867  if (0 == max_parallel_bg_queries)
868  max_parallel_bg_queries = 1;
869  dht_handle = GNUNET_DHT_connect(c,
870  (unsigned int)max_parallel_bg_queries);
871  if (NULL == dht_handle)
872  {
874  _("Could not connect to DHT!\n"));
876  NULL);
877  return;
878  }
879 
880  /* Schedule periodic put for our records. */
882  statistics = GNUNET_STATISTICS_create("zonemaster",
883  c);
884  GNUNET_STATISTICS_set(statistics,
885  "Target zone iteration velocity (μs)",
887  GNUNET_NO);
889  NULL);
891  NULL);
892 }
893 
894 
899  ("zonemaster",
901  &run,
902  NULL,
903  NULL,
904  NULL,
906 
907 
908 /* 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:1030
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:114
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:1284
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:78
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
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:517
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:198
#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:181
#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:1237
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:1264
#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:80
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:686
#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:440
#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:602
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:272
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:961
#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:885
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:913
#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:577
Handle to a PUT request.
Definition: dht_api.c:43
configuration data
Definition: configuration.c:83
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:131
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:77
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:741
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:956