+insert_hostlist ( )
+{
+ struct Hostlist * lowest_quality;
+
+ if (MAX_NUMBER_HOSTLISTS <= linked_list_size)
+ {
+ /* No free entries available, replace existing entry */
+ lowest_quality = linked_list_get_lowest_quality();
+ GNUNET_assert (lowest_quality != NULL);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Removing hostlist with URI `%s' which has the worst quality of all (%llu)\n",
+ lowest_quality->hostlist_uri,
+ (unsigned long long) lowest_quality->quality);
+ GNUNET_CONTAINER_DLL_remove (linked_list_head, linked_list_tail, lowest_quality);
+ linked_list_size--;
+ GNUNET_free (lowest_quality);
+ }
+ GNUNET_CONTAINER_DLL_insert(linked_list_head,
+ linked_list_tail,
+ hostlist_to_test);
+ linked_list_size++;
+ GNUNET_STATISTICS_set (stats,
+ gettext_noop("# advertised hostlist URIs"),
+ linked_list_size,
+ GNUNET_NO);
+ stat_testing_hostlist = GNUNET_NO;
+}
+
+
+/**
+ * Method updating hostlist statistics
+ */
+static void update_hostlist ( )
+{
+ char *stat;
+ if ( ((stat_use_bootstrap == GNUNET_NO) && ( NULL != current_hostlist )) ||
+ ((stat_testing_hostlist == GNUNET_YES) && ( NULL != current_hostlist )) )
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Updating hostlist statics for URI `%s'\n",current_hostlist->hostlist_uri );
+ current_hostlist->hello_count = stat_hellos_obtained;
+ current_hostlist->time_last_usage = GNUNET_TIME_absolute_get();
+ current_hostlist->quality = checked_add ( current_hostlist->quality, (stat_hellos_obtained * HOSTLIST_SUCCESSFUL_HELLO));
+ if ( GNUNET_YES == stat_download_successful )
+ {
+ current_hostlist->times_used++;
+ current_hostlist->quality = checked_add ( current_hostlist->quality, HOSTLIST_SUCCESSFUL_DOWNLOAD);
+ GNUNET_asprintf (&stat,
+ gettext_noop("# advertised URI `%s' downloaded"),
+ current_hostlist->hostlist_uri);
+
+ GNUNET_STATISTICS_update ( stats,
+ stat,
+ 1,
+ GNUNET_YES);
+ GNUNET_free (stat);
+ }
+ else
+ current_hostlist->quality = checked_sub ( current_hostlist->quality, HOSTLIST_FAILED_DOWNLOAD );
+ }
+ current_hostlist = NULL;
+ /* Alternating the usage of preconfigured and learned hostlists */
+
+ if (stat_testing_hostlist == GNUNET_YES)
+ return;