GNUNET_NAMESTORE_zone_iterator_next(namestore_iter);
}
+/* prototype */
+static void
+update_zone_dht_start(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc);
+
/**
* Function used to put all records successively into the DHT.
* FIXME bug here
if (NULL == name) //We're done
{
+ GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Zone iteration finished\n");
GNUNET_NAMESTORE_zone_iteration_stop (namestore_iter);
+ GNUNET_SCHEDULER_add_now (&update_zone_dht_start, NULL);
return;
}
/**
update_zone_dht_start(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Update zone!\n");
- dht_update_interval = GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS,
+ if (0 == num_public_records)
+ {
+ dht_update_interval = GNUNET_TIME_relative_multiply(
+ GNUNET_TIME_UNIT_SECONDS,
+ 1);
+ }
+ else
+ {
+ dht_update_interval = GNUNET_TIME_relative_multiply(
+ GNUNET_TIME_UNIT_SECONDS,
(3600/num_public_records));
+ }
num_public_records = 0; //start counting again
namestore_iter = GNUNET_NAMESTORE_zone_iteration_start (namestore_handle,
&zone_hash,
* We have roughly an hour for all records;
*/
dht_update_interval = GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS,
- 60); //FIXME from cfg
- //GNUNET_SCHEDULER_add_delayed (dht_update_interval,
- // &update_zone_dht_start,
- // NULL);
+ 1); //FIXME from cfg
+ GNUNET_SCHEDULER_add_now (&update_zone_dht_start, NULL);
GNUNET_log(GNUNET_ERROR_TYPE_INFO, "GNS Init done!\n");
}
uint32_t no_flags;
uint32_t flags;
struct GNUNET_NAMESTORE_Handle *h;
+ struct GNUNET_NAMESTORE_SimpleRecord *sr;
};
struct GNUNET_NAMESTORE_SimpleRecord
h->locked = 1;
it = GNUNET_malloc(sizeof(struct GNUNET_NAMESTORE_ZoneIterator));
it->h = h;
+ it->sr = h->records_head;
it->proc = proc;
it->proc_cls = proc_cls;
it->zone = zone;
void
GNUNET_NAMESTORE_zone_iterator_next(struct GNUNET_NAMESTORE_ZoneIterator *it)
{
- struct GNUNET_NAMESTORE_SimpleRecord *sr;
if (it->h->locked == 0)
return;
+ if (it->sr == NULL)
+ {
+ it->proc(it->proc_cls, NULL, GNUNET_TIME_UNIT_ZERO_ABS,
+ NULL, 0, NULL, NULL);
+ return;
+ }
- sr = it->h->records_head;
- for (; sr != NULL; sr = sr->next)
+ if (GNUNET_CRYPTO_hash_cmp(it->sr->zone, it->zone))
{
- if (GNUNET_CRYPTO_hash_cmp(sr->zone, it->zone))
- {
- //Simply always return all records
- //check flags
- it->proc(it->proc_cls, sr->zone_key, GNUNET_TIME_UNIT_FOREVER_ABS, //FIXME
- sr->name, sr->rd_count, sr->rd, NULL);
- }
+ //Simply always return all records
+ //check flags
+ it->proc(it->proc_cls, it->sr->zone_key, GNUNET_TIME_UNIT_FOREVER_ABS,
+ it->sr->name, it->sr->rd_count, it->sr->rd, NULL);
}
- it->proc(it->proc_cls, NULL, GNUNET_TIME_UNIT_ZERO_ABS, NULL, 0, NULL, NULL);
+ it->sr = it->sr->next;
}
void
GNUNET_NAMESTORE_zone_iteration_stop(struct GNUNET_NAMESTORE_ZoneIterator *it)
{
- it->h->locked = 0;
- GNUNET_free(it);
+ //it->h->locked = 0;
}
/**