![]() |
GNUnet
0.11.x
|
publish records from namestore to GNUnet name system More...
#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_dnsparser_lib.h"
#include "gnunet_dht_service.h"
#include "gnunet_namestore_service.h"
#include "gnunet_statistics_service.h"
Go to the source code of this file.
Data Structures | |
struct | DhtPutActivity |
Handle for DHT PUT activity triggered from the namestore monitor. More... | |
Macros | |
#define | LOG_STRERROR_FILE(kind, syscall, filename) |
#define | PUBLISH_OPS_PER_EXPIRATION 4 |
How often should we (re)publish each record before it expires? More... | |
#define | DELTA_INTERVAL 100 |
How often do we measure the delta between desired zone iteration speed and actual speed, and tell statistics service about it? More... | |
#define | NS_BLOCK_SIZE 1000 |
How many records do we fetch in one shot from the namestore? More... | |
#define | DHT_QUEUE_LIMIT 2000 |
How many pending DHT operations do we allow at most? More... | |
#define | NAMESTORE_QUEUE_LIMIT 50 |
How many events may the namestore give us before it has to wait for us to keep up? More... | |
#define | INITIAL_ZONE_ITERATION_INTERVAL GNUNET_TIME_UNIT_MILLISECONDS |
The initial interval in milliseconds btween puts in a zone iteration. More... | |
#define | MAXIMUM_ZONE_ITERATION_INTERVAL |
The upper bound for the zone iteration interval (per record). More... | |
#define | LATE_ITERATION_SPEEDUP_FACTOR 2 |
The factor the current zone iteration interval is divided by for each additional new record. More... | |
#define | DHT_GNS_REPLICATION_LEVEL 5 |
What replication level do we use for DHT PUT operations? More... | |
Functions | |
static void | shutdown_task (void *cls) |
Task run during shutdown. More... | |
static void | publish_zone_namestore_next (void *cls) |
Method called periodically that triggers iteration over authoritative records. More... | |
static void | publish_zone_dht_start (void *cls) |
Periodically iterate over our zone and store everything in dht. More... | |
static void | calculate_put_interval () |
Calculate target_iteration_velocity_per_record. More... | |
static void | update_velocity (unsigned int cnt) |
Re-calculate our velocity and the desired velocity. More... | |
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. More... | |
static void | dht_put_continuation (void *cls) |
Continuation called from DHT once the PUT operation is done. More... | |
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 records, converts to absolute expiration time). More... | |
static struct GNUNET_DHT_PutHandle * | perform_dht_put (const struct GNUNET_IDENTITY_PrivateKey *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. More... | |
static void | zone_iteration_error (void *cls) |
We encountered an error in our zone iteration. More... | |
static void | zone_iteration_finished (void *cls) |
Zone iteration is completed. More... | |
static void | put_gns_record (void *cls, const struct GNUNET_IDENTITY_PrivateKey *key, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd) |
Function used to put all records successively into the DHT. More... | |
static void | run (void *cls, const struct GNUNET_CONFIGURATION_Handle *c, struct GNUNET_SERVICE_Handle *service) |
Performe zonemaster duties: watch namestore, publish records. More... | |
GNUNET_SERVICE_MAIN ("zonemaster", GNUNET_SERVICE_OPTION_NONE, &run, NULL, NULL, NULL, GNUNET_MQ_handler_end()) | |
Define "main" method using service macro. More... | |
Variables | |
static struct GNUNET_STATISTICS_Handle * | statistics |
Handle to the statistics service. More... | |
static struct GNUNET_DHT_Handle * | dht_handle |
Our handle to the DHT. More... | |
static struct GNUNET_NAMESTORE_Handle * | namestore_handle |
Our handle to the namestore service. More... | |
static struct GNUNET_NAMESTORE_ZoneIterator * | namestore_iter |
Handle to iterate over our authoritative zone in namestore. More... | |
static struct DhtPutActivity * | it_head |
Head of iteration put activities; kept in a DLL. More... | |
static struct DhtPutActivity * | it_tail |
Tail of iteration put activities; kept in a DLL. More... | |
static unsigned int | dht_queue_length |
Number of entries in the DHT queue it_head. More... | |
static unsigned long long | num_public_records |
Useful for zone update for DHT put. More... | |
static unsigned long long | last_num_public_records |
Last seen record count. More... | |
static unsigned long long | put_cnt |
Number of successful put operations performed in the current measurement cycle (as measured in check_zone_namestore_next()). More... | |
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. More... | |
static struct GNUNET_TIME_Relative | min_relative_record_time |
Minimum relative expiration time of records seem during the current zone iteration. More... | |
static struct GNUNET_TIME_Relative | last_min_relative_record_time |
Minimum relative expiration time of records seem during the last zone iteration. More... | |
static struct GNUNET_TIME_Relative | zone_publish_time_window_default |
Default time window for zone iteration. More... | |
static struct GNUNET_TIME_Relative | zone_publish_time_window |
Time window for zone iteration, adjusted based on relative record expiration times in our zone. More... | |
static struct GNUNET_TIME_Absolute | last_put_100 |
When did we last start measuring the DELTA_INTERVAL successful DHT puts? Used for velocity calculations. More... | |
static struct GNUNET_TIME_Relative | sub_delta |
By how much should we try to increase our per-record iteration speed (over the desired speed calculated directly from the #put_interval)? Basically this value corresponds to the per-record CPU time overhead we have. More... | |
static struct GNUNET_SCHEDULER_Task * | zone_publish_task |
zone publish task More... | |
static unsigned int | ns_iteration_left |
How many more values are left for the current query before we need to explicitly ask the namestore for more? More... | |
static int | first_zone_iteration |
GNUNET_YES if zone has never been published before More... | |
static int | cache_keys |
Optimize block insertion by caching map of private keys to public keys in memory? More... | |
publish records from namestore to GNUnet name system
Definition in file gnunet-service-zonemaster.c.
#define LOG_STRERROR_FILE | ( | kind, | |
syscall, | |||
filename | |||
) |
Definition at line 34 of file gnunet-service-zonemaster.c.
#define PUBLISH_OPS_PER_EXPIRATION 4 |
How often should we (re)publish each record before it expires?
Definition at line 44 of file gnunet-service-zonemaster.c.
Referenced by calculate_put_interval().
#define DELTA_INTERVAL 100 |
How often do we measure the delta between desired zone iteration speed and actual speed, and tell statistics service about it?
Definition at line 51 of file gnunet-service-zonemaster.c.
Referenced by put_gns_record().
#define NS_BLOCK_SIZE 1000 |
How many records do we fetch in one shot from the namestore?
Definition at line 56 of file gnunet-service-zonemaster.c.
Referenced by check_zone_namestore_next(), and publish_zone_namestore_next().
#define DHT_QUEUE_LIMIT 2000 |
How many pending DHT operations do we allow at most?
Definition at line 61 of file gnunet-service-zonemaster.c.
Referenced by put_gns_record().
#define NAMESTORE_QUEUE_LIMIT 50 |
How many events may the namestore give us before it has to wait for us to keep up?
Definition at line 67 of file gnunet-service-zonemaster.c.
#define INITIAL_ZONE_ITERATION_INTERVAL GNUNET_TIME_UNIT_MILLISECONDS |
The initial interval in milliseconds btween puts in a zone iteration.
Definition at line 73 of file gnunet-service-zonemaster.c.
Referenced by run().
#define MAXIMUM_ZONE_ITERATION_INTERVAL |
The upper bound for the zone iteration interval (per record).
Definition at line 79 of file gnunet-service-zonemaster.c.
Referenced by calculate_put_interval(), and check_zone_namestore_next().
#define LATE_ITERATION_SPEEDUP_FACTOR 2 |
The factor the current zone iteration interval is divided by for each additional new record.
Definition at line 86 of file gnunet-service-zonemaster.c.
Referenced by update_velocity().
#define DHT_GNS_REPLICATION_LEVEL 5 |
What replication level do we use for DHT PUT operations?
Definition at line 91 of file gnunet-service-zonemaster.c.
Referenced by perform_dht_put().
|
static |
Task run during shutdown.
cls | unused |
tc | unused |
Definition at line 248 of file gnunet-service-zonemaster.c.
References dht_queue_length, GNUNET_CONTAINER_DLL_remove, GNUNET_DHT_disconnect(), GNUNET_DHT_put_cancel(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, GNUNET_NAMESTORE_disconnect(), GNUNET_NAMESTORE_zone_iteration_stop(), GNUNET_NO, GNUNET_SCHEDULER_cancel(), GNUNET_STATISTICS_destroy(), and DhtPutActivity::ph.
Referenced by run().
|
static |
Method called periodically that triggers iteration over authoritative records.
cls | NULL |
Definition at line 300 of file gnunet-service-zonemaster.c.
References GNUNET_assert, GNUNET_NAMESTORE_zone_iterator_next(), NS_BLOCK_SIZE, ns_iteration_left, and publish_zone_dht_start().
Referenced by check_zone_namestore_next().
|
static |
Periodically iterate over our zone and store everything in dht.
Periodically iterate over all zones and store everything in DHT.
cls | NULL |
Definition at line 796 of file gnunet-service-zonemaster.c.
References GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_NAMESTORE_zone_iteration_start(), GNUNET_NO, GNUNET_STATISTICS_update(), ns_iteration_left, num_public_records, put_gns_record(), zone_iteration_error(), and zone_iteration_finished().
Referenced by publish_zone_namestore_next(), run(), zone_iteration_error(), and zone_iteration_finished().
|
static |
Calculate target_iteration_velocity_per_record.
If no records are known (startup) or none present we can safely set the interval to the value for a single record
Definition at line 325 of file gnunet-service-zonemaster.c.
References GNUNET_ERROR_TYPE_BULK, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_NO, GNUNET_STATISTICS_set(), GNUNET_TIME_relative_divide(), GNUNET_TIME_relative_min(), last_min_relative_record_time, last_num_public_records, MAXIMUM_ZONE_ITERATION_INTERVAL, min_relative_record_time, num_public_records, PUBLISH_OPS_PER_EXPIRATION, GNUNET_TIME_Relative::rel_value_us, target_iteration_velocity_per_record, zone_publish_time_window, and zone_publish_time_window_default.
Referenced by update_velocity(), and zone_iteration_finished().
|
static |
Re-calculate our velocity and the desired velocity.
We have succeeded in making DELTA_INTERVAL puts, so now calculate the new desired delay between puts.
cnt | how many records were processed since the last call? |
Definition at line 377 of file gnunet-service-zonemaster.c.
References calculate_put_interval(), dht_queue_length, first_zone_iteration, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_NO, GNUNET_STATISTICS_set(), GNUNET_STRINGS_relative_time_to_string(), GNUNET_TIME_absolute_get(), GNUNET_TIME_absolute_get_duration(), GNUNET_TIME_relative_add(), GNUNET_TIME_relative_subtract(), GNUNET_TIME_UNIT_ZERO, GNUNET_YES, last_num_public_records, last_put_100, LATE_ITERATION_SPEEDUP_FACTOR, num_public_records, GNUNET_TIME_Relative::rel_value_us, sub_delta, and target_iteration_velocity_per_record.
Referenced by check_zone_namestore_next(), and put_gns_record().
|
static |
Check if the current zone iteration needs to be continued by calling publish_zone_namestore_next(), and if so with what delay.
Definition at line 479 of file gnunet-service-zonemaster.c.
References first_zone_iteration, GNUNET_assert, GNUNET_NO, GNUNET_SCHEDULER_add_delayed(), GNUNET_STATISTICS_set(), GNUNET_TIME_relative_min(), GNUNET_TIME_relative_multiply(), GNUNET_TIME_relative_subtract(), GNUNET_TIME_UNIT_ZERO, GNUNET_YES, MAXIMUM_ZONE_ITERATION_INTERVAL, NS_BLOCK_SIZE, ns_iteration_left, publish_zone_namestore_next(), put_cnt, GNUNET_TIME_Relative::rel_value_us, sub_delta, target_iteration_velocity_per_record, and update_velocity().
Referenced by put_gns_record().
|
static |
Continuation called from DHT once the PUT operation is done.
cls | a struct DhtPutActivity |
Definition at line 516 of file gnunet-service-zonemaster.c.
References dht_queue_length, GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, and GNUNET_log.
Referenced by perform_dht_put().
|
static |
Convert namestore records from the internal format to that suitable for publication (removes private records, converts to absolute expiration time).
rd | input records |
rd_count | size of the rd and rd_public arrays |
rd_public | where to write the converted records |
Definition at line 541 of file gnunet-service-zonemaster.c.
References GNUNET_TIME_Absolute::abs_value_us, GNUNET_GNSRECORD_RF_PRIVATE, GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION, GNUNET_MIN, GNUNET_TIME_absolute_get(), min_relative_record_time, and GNUNET_TIME_Relative::rel_value_us.
Referenced by put_gns_record().
|
static |
Store GNS records in the DHT.
key | key of the zone |
label | label to store under |
rd_public | public record data |
rd_public_count | number of records in rd_public |
ma | handle for the put operation |
Definition at line 582 of file gnunet-service-zonemaster.c.
References cache_keys, DHT_GNS_REPLICATION_LEVEL, dht_put_continuation(), GNUNET_BLOCK_TYPE_GNS_NAMERECORD, GNUNET_break, GNUNET_DHT_put(), GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_GNSRECORD_block_create(), GNUNET_GNSRECORD_block_create2(), GNUNET_GNSRECORD_block_get_size(), GNUNET_GNSRECORD_query_from_private_key(), GNUNET_GNSRECORD_record_get_expiration_time(), GNUNET_h2s(), GNUNET_log, GNUNET_NO, GNUNET_STATISTICS_update(), GNUNET_STRINGS_absolute_time_to_string(), num_public_records, and ret.
Referenced by put_gns_record().
|
static |
We encountered an error in our zone iteration.
cls | NULL |
Definition at line 649 of file gnunet-service-zonemaster.c.
References GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_SCHEDULER_add_now(), GNUNET_SCHEDULER_cancel(), and publish_zone_dht_start().
Referenced by publish_zone_dht_start().
|
static |
Zone iteration is completed.
cls | NULL |
Definition at line 674 of file gnunet-service-zonemaster.c.
References calculate_put_interval(), first_zone_iteration, GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_NO, GNUNET_SCHEDULER_add_delayed(), GNUNET_SCHEDULER_add_now(), GNUNET_STATISTICS_set(), GNUNET_STRINGS_relative_time_to_string(), GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_YES, last_min_relative_record_time, last_num_public_records, min_relative_record_time, num_public_records, publish_zone_dht_start(), GNUNET_TIME_Relative::rel_value_us, and target_iteration_velocity_per_record.
Referenced by publish_zone_dht_start().
|
static |
Function used to put all records successively into the DHT.
cls | the closure (NULL) |
key | the private key of the authority (ours) |
label | the name of the records, NULL once the iteration is done |
rd_count | the number of records in rd |
rd | the record data |
Definition at line 725 of file gnunet-service-zonemaster.c.
References check_zone_namestore_next(), convert_records_for_export(), DELTA_INTERVAL, dht_queue_length, DHT_QUEUE_LIMIT, GNUNET_CONTAINER_DLL_insert_tail, GNUNET_CONTAINER_DLL_remove, GNUNET_DHT_put_cancel(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_log, GNUNET_new, GNUNET_STRINGS_relative_time_to_string(), GNUNET_TIME_absolute_get(), GNUNET_TIME_absolute_get_duration(), GNUNET_YES, it_head, ns_iteration_left, perform_dht_put(), DhtPutActivity::ph, put_cnt, DhtPutActivity::start_date, and update_velocity().
Referenced by publish_zone_dht_start().
|
static |
Performe zonemaster duties: watch namestore, publish records.
cls | closure |
server | the initialized server |
c | configuration to use |
Definition at line 831 of file gnunet-service-zonemaster.c.
References _, cache_keys, first_zone_iteration, GNUNET_CONFIGURATION_get_value_number(), GNUNET_CONFIGURATION_get_value_time(), GNUNET_CONFIGURATION_get_value_yesno(), GNUNET_DHT_connect(), GNUNET_DHT_DEFAULT_REPUBLISH_FREQUENCY, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_log, GNUNET_MQ_handler_end, GNUNET_NAMESTORE_connect(), GNUNET_NO, GNUNET_OK, GNUNET_SCHEDULER_add_now(), GNUNET_SCHEDULER_add_shutdown(), GNUNET_SCHEDULER_shutdown(), GNUNET_SERVICE_MAIN(), GNUNET_SERVICE_OPTION_NONE, GNUNET_STATISTICS_create(), GNUNET_STATISTICS_set(), GNUNET_STRINGS_relative_time_to_string(), GNUNET_TIME_absolute_get(), GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_YES, INITIAL_ZONE_ITERATION_INTERVAL, last_put_100, min_relative_record_time, publish_zone_dht_start(), GNUNET_TIME_Relative::rel_value_us, shutdown_task(), target_iteration_velocity_per_record, zone_publish_time_window, and zone_publish_time_window_default.
GNUNET_SERVICE_MAIN | ( | "zonemaster" | , |
GNUNET_SERVICE_OPTION_NONE | , | ||
& | run, | ||
NULL | , | ||
NULL | , | ||
NULL | , | ||
GNUNET_MQ_handler_end() | |||
) |
Define "main" method using service macro.
Referenced by run().
|
static |
Handle to the statistics service.
Definition at line 124 of file gnunet-service-zonemaster.c.
|
static |
Our handle to the DHT.
Definition at line 129 of file gnunet-service-zonemaster.c.
|
static |
Our handle to the namestore service.
Definition at line 134 of file gnunet-service-zonemaster.c.
|
static |
Handle to iterate over our authoritative zone in namestore.
Definition at line 139 of file gnunet-service-zonemaster.c.
|
static |
Head of iteration put activities; kept in a DLL.
Definition at line 144 of file gnunet-service-zonemaster.c.
Referenced by put_gns_record().
|
static |
Tail of iteration put activities; kept in a DLL.
Definition at line 149 of file gnunet-service-zonemaster.c.
|
static |
Number of entries in the DHT queue it_head.
Definition at line 154 of file gnunet-service-zonemaster.c.
Referenced by dht_put_continuation(), put_gns_record(), shutdown_task(), and update_velocity().
|
static |
Useful for zone update for DHT put.
Definition at line 159 of file gnunet-service-zonemaster.c.
Referenced by calculate_put_interval(), perform_dht_put(), publish_zone_dht_start(), update_velocity(), and zone_iteration_finished().
|
static |
Last seen record count.
Definition at line 164 of file gnunet-service-zonemaster.c.
Referenced by calculate_put_interval(), update_velocity(), and zone_iteration_finished().
|
static |
Number of successful put operations performed in the current measurement cycle (as measured in check_zone_namestore_next()).
Definition at line 170 of file gnunet-service-zonemaster.c.
Referenced by check_zone_namestore_next(), and put_gns_record().
|
static |
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.
Definition at line 179 of file gnunet-service-zonemaster.c.
Referenced by calculate_put_interval(), check_zone_namestore_next(), run(), update_velocity(), and zone_iteration_finished().
|
static |
Minimum relative expiration time of records seem during the current zone iteration.
Definition at line 185 of file gnunet-service-zonemaster.c.
Referenced by calculate_put_interval(), convert_records_for_export(), run(), and zone_iteration_finished().
|
static |
Minimum relative expiration time of records seem during the last zone iteration.
Definition at line 191 of file gnunet-service-zonemaster.c.
Referenced by calculate_put_interval(), and zone_iteration_finished().
|
static |
Default time window for zone iteration.
Definition at line 196 of file gnunet-service-zonemaster.c.
Referenced by calculate_put_interval(), and run().
|
static |
Time window for zone iteration, adjusted based on relative record expiration times in our zone.
Definition at line 202 of file gnunet-service-zonemaster.c.
Referenced by calculate_put_interval(), and run().
|
static |
When did we last start measuring the DELTA_INTERVAL successful DHT puts? Used for velocity calculations.
Definition at line 208 of file gnunet-service-zonemaster.c.
Referenced by run(), and update_velocity().
|
static |
By how much should we try to increase our per-record iteration speed (over the desired speed calculated directly from the #put_interval)? Basically this value corresponds to the per-record CPU time overhead we have.
Definition at line 216 of file gnunet-service-zonemaster.c.
Referenced by check_zone_namestore_next(), and update_velocity().
|
static |
zone publish task
Definition at line 221 of file gnunet-service-zonemaster.c.
|
static |
How many more values are left for the current query before we need to explicitly ask the namestore for more?
Definition at line 227 of file gnunet-service-zonemaster.c.
Referenced by check_zone_namestore_next(), publish_zone_dht_start(), publish_zone_namestore_next(), and put_gns_record().
|
static |
GNUNET_YES if zone has never been published before
Definition at line 232 of file gnunet-service-zonemaster.c.
Referenced by check_zone_namestore_next(), run(), update_velocity(), and zone_iteration_finished().
|
static |
Optimize block insertion by caching map of private keys to public keys in memory?
Definition at line 238 of file gnunet-service-zonemaster.c.
Referenced by perform_dht_put(), and run().