[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r20621 - gnunet/src/gns
From: |
gnunet |
Subject: |
[GNUnet-SVN] r20621 - gnunet/src/gns |
Date: |
Mon, 19 Mar 2012 20:27:05 +0100 |
Author: grothoff
Date: 2012-03-19 20:27:05 +0100 (Mon, 19 Mar 2012)
New Revision: 20621
Modified:
gnunet/src/gns/gnunet-gns-fcfsd.c
Log:
-allow registering one name per zone key in fcfsd
Modified: gnunet/src/gns/gnunet-gns-fcfsd.c
===================================================================
--- gnunet/src/gns/gnunet-gns-fcfsd.c 2012-03-19 19:22:34 UTC (rev 20620)
+++ gnunet/src/gns/gnunet-gns-fcfsd.c 2012-03-19 19:27:05 UTC (rev 20621)
@@ -342,7 +342,7 @@
/**
- * Process a record that was stored in the namestore.
+ * Test if a name mapping was found, if so, refuse. If not, initiate storing
of the record.
*
* @param cls closure
* @param zone_key public key of the zone
@@ -358,6 +358,65 @@
* because the user queried for a particular record type only)
*/
static void
+zone_to_name_cb (void *cls,
+ const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *zone_key,
+ struct GNUNET_TIME_Absolute expire,
+ const char *name,
+ unsigned int rd_count,
+ const struct GNUNET_NAMESTORE_RecordData *rd,
+ const struct GNUNET_CRYPTO_RsaSignature *signature)
+{
+ struct Request *request = cls;
+ struct GNUNET_NAMESTORE_RecordData r;
+ struct GNUNET_CRYPTO_ShortHashCode pub;
+
+ request->qe = NULL;
+ if (NULL != name)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ _("Found existing name `%s' for the given key\n"),
+ name);
+ request->phase = RP_FAIL;
+ run_httpd_now ();
+ return;
+ }
+ GNUNET_assert (GNUNET_OK ==
+ GNUNET_CRYPTO_short_hash_from_string2 (request->public_key,
+ strlen
(request->public_key),
+ &pub));
+ r.data = &pub;
+ r.data_size = sizeof (pub);
+ r.expiration = GNUNET_TIME_UNIT_FOREVER_ABS;
+ r.record_type = GNUNET_NAMESTORE_TYPE_PKEY;
+ r.flags = GNUNET_NAMESTORE_RF_AUTHORITY;
+ request->qe = GNUNET_NAMESTORE_record_create (ns,
+ fcfs_zone_pkey,
+ request->domain_name,
+ &r,
+ &put_continuation,
+ request);
+}
+
+
+/**
+ * Process a record that was stored in the namestore. Used to check if
+ * the requested name already exists in the namestore. If not,
+ * proceed to check if the requested key already exists.
+ *
+ * @param cls closure
+ * @param zone_key public key of the zone
+ * @param expire when does the corresponding block in the DHT expire (until
+ * when should we never do a DHT lookup for the same name
again)?;
+ * GNUNET_TIME_UNIT_ZERO_ABS if there are no records of any type
in the namestore,
+ * or the expiration time of the block in the namestore (even if
there are zero
+ * records matching the desired record type)
+ * @param name name that is being mapped (at most 255 characters long)
+ * @param rd_count number of entries in 'rd' array
+ * @param rd array of records with data to store
+ * @param signature signature of the record block, NULL if signature is
unavailable (i.e.
+ * because the user queried for a particular record type only)
+ */
+static void
lookup_result_processor (void *cls,
const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded
*zone_key,
struct GNUNET_TIME_Absolute expire,
@@ -367,14 +426,13 @@
const struct GNUNET_CRYPTO_RsaSignature *signature)
{
struct Request *request = cls;
- struct GNUNET_NAMESTORE_RecordData r;
struct GNUNET_CRYPTO_ShortHashCode pub;
+ request->qe = NULL;
GNUNET_assert (GNUNET_OK ==
GNUNET_CRYPTO_short_hash_from_string2 (request->public_key,
strlen
(request->public_key),
&pub));
- request->qe = NULL;
if (0 != rd_count)
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
@@ -385,17 +443,11 @@
run_httpd_now ();
return;
}
- r.data = &pub;
- r.data_size = sizeof (pub);
- r.expiration = GNUNET_TIME_UNIT_FOREVER_ABS;
- r.record_type = GNUNET_NAMESTORE_TYPE_PKEY;
- r.flags = GNUNET_NAMESTORE_RF_AUTHORITY;
- request->qe = GNUNET_NAMESTORE_record_create (ns,
- fcfs_zone_pkey,
- request->domain_name,
- &r,
- &put_continuation,
- request);
+ request->qe = GNUNET_NAMESTORE_zone_to_name (ns,
+ &fcfsd_zone,
+ &pub,
+ &zone_to_name_cb,
+ request);
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r20621 - gnunet/src/gns,
gnunet <=