- else
- {
- GNUNET_CONTAINER_DLL_remove (ma_head,
- ma_tail,
- ma);
- GNUNET_free (ma);
- }
-}
-
-
-/**
- * Convert namestore records from the internal format to that
- * suitable for publication (removes private records, converts
- * to absolute expiration time).
- *
- * @param rd input records
- * @param rd_count size of the @a rd and @a rd_public arrays
- * @param rd_public where to write the converted records
- * @return number of records written to @a rd_public
- */
-static unsigned int
-convert_records_for_export (const struct GNUNET_GNSRECORD_Data *rd,
- unsigned int rd_count,
- struct GNUNET_GNSRECORD_Data *rd_public)
-{
- struct GNUNET_TIME_Absolute now;
- unsigned int rd_public_count;
- unsigned int i;
-
- rd_public_count = 0;
- now = GNUNET_TIME_absolute_get ();
- for (i=0;i<rd_count;i++)
- if (0 == (rd[i].flags & GNUNET_GNSRECORD_RF_PRIVATE))
- {
- rd_public[rd_public_count] = rd[i];
- if (0 != (rd[i].flags & GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION))
- {
- /* GNUNET_GNSRECORD_block_create will convert to absolute time;
- we just need to adjust our iteration frequency */
- min_relative_record_time.rel_value_us =
- GNUNET_MIN (rd_public[rd_public_count].expiration_time,
- min_relative_record_time.rel_value_us);
- }
- else if (rd_public[rd_public_count].expiration_time < now.abs_value_us)
- {
- /* record already expired, skip it */
- continue;
- }
- rd_public_count++;
- }
- return rd_public_count;
-}
-
-
-/**
- * Store GNS records in the DHT.
- *
- * @param key key of the zone
- * @param label label to store under
- * @param rd_public public record data
- * @param rd_public_count number of records in @a rd_public
- * @param pc_arg closure argument to pass to the #dht_put_continuation
- * @return DHT PUT handle, NULL on error
- */
-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,
- void *pc_arg)
-{
- struct GNUNET_GNSRECORD_Block *block;
- struct GNUNET_HashCode query;
- struct GNUNET_TIME_Absolute expire;
- size_t block_size;
- struct GNUNET_DHT_PutHandle *ret;
-
- expire = GNUNET_GNSRECORD_record_get_expiration_time (rd_public_count,
- rd_public);
- block = GNUNET_GNSRECORD_block_create (key,
- expire,
- label,
- rd_public,
- rd_public_count);
- if (NULL == block)
- return NULL; /* whoops */
- block_size = ntohl (block->purpose.size)
- + sizeof (struct GNUNET_CRYPTO_EcdsaSignature)
- + sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey);
- GNUNET_GNSRECORD_query_from_private_key (key,
- label,
- &query);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Storing %u record(s) for label `%s' in DHT with expiration `%s' under key %s\n",
- rd_public_count,
- label,
- GNUNET_STRINGS_absolute_time_to_string (expire),
- GNUNET_h2s (&query));
- ret = GNUNET_DHT_put (dht_handle, &query,
- DHT_GNS_REPLICATION_LEVEL,
- GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE,
- GNUNET_BLOCK_TYPE_GNS_NAMERECORD,
- block_size,
- block,
- expire,
- DHT_OPERATION_TIMEOUT,
- &dht_put_continuation,
- pc_arg);
- GNUNET_free (block);
- return ret;