gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r30237 - in gnunet/src: gns include namecache namestore


From: gnunet
Subject: [GNUnet-SVN] r30237 - in gnunet/src: gns include namecache namestore
Date: Wed, 16 Oct 2013 23:52:04 +0200

Author: grothoff
Date: 2013-10-16 23:52:04 +0200 (Wed, 16 Oct 2013)
New Revision: 30237

Removed:
   gnunet/src/namestore/test_namestore_api_cache_block.c
Modified:
   gnunet/src/gns/Makefile.am
   gnunet/src/gns/gnunet-service-gns.c
   gnunet/src/gns/gnunet-service-gns_resolver.c
   gnunet/src/gns/gnunet-service-gns_resolver.h
   gnunet/src/gns/gnunet-service-gns_shorten.c
   gnunet/src/gns/gnunet-service-gns_shorten.h
   gnunet/src/include/gnunet_namestore_plugin.h
   gnunet/src/include/gnunet_namestore_service.h
   gnunet/src/namecache/namecache.conf.in
   gnunet/src/namecache/namecache_api.c
   gnunet/src/namestore/Makefile.am
   gnunet/src/namestore/gnunet-namestore-fcfsd.c
   gnunet/src/namestore/gnunet-namestore.c
   gnunet/src/namestore/gnunet-service-namestore.c
   gnunet/src/namestore/namestore_api.c
   gnunet/src/namestore/plugin_namestore_postgres.c
   gnunet/src/namestore/plugin_namestore_sqlite.c
   gnunet/src/namestore/test_namestore_api.conf
   gnunet/src/namestore/test_namestore_api_lookup_public.c
   gnunet/src/namestore/test_namestore_api_remove.c
   gnunet/src/namestore/test_namestore_api_store.c
   gnunet/src/namestore/test_namestore_api_store_update.c
   gnunet/src/namestore/test_namestore_api_zone_iteration.c
Log:
-finishing split of namestore into namestore and namecache (#3065) -- in 
theory; in practice, somehow something broke badly, so the tests are now failing

Modified: gnunet/src/gns/Makefile.am
===================================================================
--- gnunet/src/gns/Makefile.am  2013-10-16 21:03:53 UTC (rev 30236)
+++ gnunet/src/gns/Makefile.am  2013-10-16 21:52:04 UTC (rev 30237)
@@ -165,6 +165,7 @@
   $(top_builddir)/src/dns/libgnunetdnsparser.la \
   $(top_builddir)/src/dns/libgnunetdnsstub.la \
   $(top_builddir)/src/dht/libgnunetdht.la \
+  $(top_builddir)/src/namecache/libgnunetnamecache.la \
   $(top_builddir)/src/namestore/libgnunetnamestore.la \
   $(USE_VPN) \
   $(GN_LIBINTL)

Modified: gnunet/src/gns/gnunet-service-gns.c
===================================================================
--- gnunet/src/gns/gnunet-service-gns.c 2013-10-16 21:03:53 UTC (rev 30236)
+++ gnunet/src/gns/gnunet-service-gns.c 2013-10-16 21:52:04 UTC (rev 30237)
@@ -28,6 +28,7 @@
 #include "gnunet_dns_service.h"
 #include "gnunet_dnsparser_lib.h"
 #include "gnunet_dht_service.h"
+#include "gnunet_namecache_service.h"
 #include "gnunet_namestore_service.h"
 #include "gnunet_gns_service.h"
 #include "gnunet_statistics_service.h"
@@ -121,6 +122,11 @@
 static struct GNUNET_NAMESTORE_Handle *namestore_handle;
 
 /**
+ * Our handle to the namecache service
+ */
+static struct GNUNET_NAMECACHE_Handle *namecache_handle;
+
+/**
  * Handle to iterate over our authoritative zone in namestore
  */
 static struct GNUNET_NAMESTORE_ZoneIterator *namestore_iter;
@@ -231,6 +237,11 @@
     GNUNET_NAMESTORE_disconnect (namestore_handle);
     namestore_handle = NULL;
   }
+  if (NULL != namecache_handle)
+  {
+    GNUNET_NAMECACHE_disconnect (namecache_handle);
+    namecache_handle = NULL;
+  }
   if (NULL != active_put)
   {
     GNUNET_DHT_put_cancel (active_put);
@@ -645,6 +656,14 @@
     GNUNET_SCHEDULER_shutdown ();
     return;
   }
+  namecache_handle = GNUNET_NAMECACHE_connect (c);
+  if (NULL == namecache_handle)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+               _("Failed to connect to the namecache!\n"));
+    GNUNET_SCHEDULER_shutdown ();
+    return;
+  }
 
   put_interval = INITIAL_PUT_INTERVAL;
   zone_publish_time_window = DEFAULT_ZONE_PUBLISH_TIME_WINDOW;
@@ -705,10 +724,14 @@
       return;
     }
   }
-  GNS_resolver_init (namestore_handle, dht_handle,
+  GNS_resolver_init (namestore_handle,
+                     namecache_handle,
+                     dht_handle,
                     c,
                     max_parallel_bg_queries);
-  GNS_shorten_init (namestore_handle, dht_handle);
+  GNS_shorten_init (namestore_handle,
+                    namecache_handle,
+                    dht_handle);
   GNUNET_SERVER_disconnect_notify (server,
                                   &notify_client_disconnect,
                                   NULL);

Modified: gnunet/src/gns/gnunet-service-gns_resolver.c
===================================================================
--- gnunet/src/gns/gnunet-service-gns_resolver.c        2013-10-16 21:03:53 UTC 
(rev 30236)
+++ gnunet/src/gns/gnunet-service-gns_resolver.c        2013-10-16 21:52:04 UTC 
(rev 30237)
@@ -35,6 +35,7 @@
 #include "gnunet_dnsstub_lib.h"
 #include "gnunet_dht_service.h"
 #include "gnunet_gnsrecord_lib.h"
+#include "gnunet_namecache_service.h"
 #include "gnunet_namestore_service.h"
 #include "gnunet_dns_service.h"
 #include "gnunet_resolver_service.h"
@@ -264,9 +265,9 @@
   struct GNUNET_RESOLVER_RequestHandle *std_resolve;
 
   /**
-   * Pending Namestore lookup task
+   * Pending Namecache lookup task
    */
-  struct GNUNET_NAMESTORE_QueueEntry *namestore_qe;
+  struct GNUNET_NAMECACHE_QueueEntry *namecache_qe;
 
   /**
    * Heap node associated with this lookup.  Used to limit number of
@@ -353,7 +354,7 @@
   /**
    * Pending Namestore caching task.
    */
-  struct GNUNET_NAMESTORE_QueueEntry *namestore_qe_cache;
+  struct GNUNET_NAMECACHE_QueueEntry *namecache_qe_cache;
 
 };
 
@@ -364,6 +365,11 @@
 static struct GNUNET_NAMESTORE_Handle *namestore_handle;
 
 /**
+ * Our handle to the namecache service
+ */
+static struct GNUNET_NAMECACHE_Handle *namecache_handle;
+
+/**
  * Our handle to the vpn service
  */
 static struct GNUNET_VPN_Handle *vpn_handle;
@@ -1672,13 +1678,13 @@
  * @param emsg error message
  */
 static void
-namestore_cache_continuation (void *cls,
+namecache_cache_continuation (void *cls,
                              int32_t success,
                              const char *emsg)
 {
   struct CacheOps *co = cls;
 
-  co->namestore_qe_cache = NULL;
+  co->namecache_qe_cache = NULL;
   if (NULL != emsg)
     GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
                _("Failed to cache GNS resolution: %s\n"),
@@ -1765,9 +1771,9 @@
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
              "Caching response from the DHT in namestore\n");
   co = GNUNET_new (struct CacheOps);
-  co->namestore_qe_cache = GNUNET_NAMESTORE_block_cache (namestore_handle,
+  co->namecache_qe_cache = GNUNET_NAMECACHE_block_cache (namecache_handle,
                                                         block,
-                                                        
&namestore_cache_continuation,
+                                                        
&namecache_cache_continuation,
                                                         co);
   GNUNET_CONTAINER_DLL_insert (co_head,
                               co_tail,
@@ -1795,8 +1801,8 @@
   GNUNET_GNSRECORD_query_from_public_key (auth,
                                          label,
                                          &query);
-  GNUNET_assert (NULL != rh->namestore_qe);
-  rh->namestore_qe = NULL;
+  GNUNET_assert (NULL != rh->namecache_qe);
+  rh->namecache_qe = NULL;
   if ( (GNUNET_NO == rh->only_cached) &&
        ( (NULL == block) ||
         (0 == GNUNET_TIME_absolute_get_remaining (GNUNET_TIME_absolute_ntoh 
(block->expiration_time)).rel_value_us) ) )
@@ -1874,11 +1880,11 @@
   GNUNET_GNSRECORD_query_from_public_key (&ac->authority_info.gns_authority,
                                          ac->label,
                                          &query);
-  rh->namestore_qe = GNUNET_NAMESTORE_lookup_block (namestore_handle,
+  rh->namecache_qe = GNUNET_NAMECACHE_lookup_block (namecache_handle,
                                                    &query,
                                                    
&handle_namestore_block_response,
                                                    rh);
-  GNUNET_assert (NULL != rh->namestore_qe);
+  GNUNET_assert (NULL != rh->namecache_qe);
 }
 
 
@@ -2100,10 +2106,10 @@
     GNUNET_DNSSTUB_resolve_cancel (rh->dns_request);
     rh->dns_request = NULL;
   }
-  if (NULL != rh->namestore_qe)
+  if (NULL != rh->namecache_qe)
   {
-    GNUNET_NAMESTORE_cancel (rh->namestore_qe);
-    rh->namestore_qe = NULL;
+    GNUNET_NAMECACHE_cancel (rh->namecache_qe);
+    rh->namecache_qe = NULL;
   }
   if (NULL != rh->std_resolve)
   {
@@ -2132,12 +2138,14 @@
  * Initialize the resolver
  *
  * @param nh the namestore handle
+ * @param nc the namecache handle
  * @param dht the dht handle
  * @param c configuration handle
  * @param max_bg_queries maximum number of parallel background queries in dht
  */
 void
 GNS_resolver_init (struct GNUNET_NAMESTORE_Handle *nh,
+                   struct GNUNET_NAMECACHE_Handle *nc,
                   struct GNUNET_DHT_Handle *dht,
                   const struct GNUNET_CONFIGURATION_Handle *c,
                   unsigned long long max_bg_queries)
@@ -2145,6 +2153,7 @@
   char *dns_ip;
 
   cfg = c;
+  namecache_handle = nc;
   namestore_handle = nh;
   dht_handle = dht;
   dht_lookup_heap =
@@ -2185,7 +2194,7 @@
     GNUNET_CONTAINER_DLL_remove (co_head,
                                 co_tail,
                                 co);
-    GNUNET_NAMESTORE_cancel (co->namestore_qe_cache);
+    GNUNET_NAMECACHE_cancel (co->namecache_qe_cache);
     GNUNET_free (co);
   }
   GNUNET_CONTAINER_heap_destroy (dht_lookup_heap);
@@ -2195,6 +2204,7 @@
   GNUNET_VPN_disconnect (vpn_handle);
   vpn_handle = NULL;
   dht_handle = NULL;
+  namecache_handle = NULL;
   namestore_handle = NULL;
 }
 

Modified: gnunet/src/gns/gnunet-service-gns_resolver.h
===================================================================
--- gnunet/src/gns/gnunet-service-gns_resolver.h        2013-10-16 21:03:53 UTC 
(rev 30236)
+++ gnunet/src/gns/gnunet-service-gns_resolver.h        2013-10-16 21:52:04 UTC 
(rev 30237)
@@ -26,19 +26,21 @@
 #define GNS_RESOLVER_H
 #include "gns.h"
 #include "gnunet_dht_service.h"
+#include "gnunet_namecache_service.h"
 
-
 /**
  * Initialize the resolver subsystem.
  * MUST be called before #GNS_resolver_lookup.
  *
  * @param nh handle to the namestore
+ * @param nc the namecache handle
  * @param dht handle to the dht
  * @param c configuration handle
  * @param max_bg_queries maximum amount of background queries
  */
 void
 GNS_resolver_init (struct GNUNET_NAMESTORE_Handle *nh,
+                   struct GNUNET_NAMECACHE_Handle *nc,
                   struct GNUNET_DHT_Handle *dht,
                   const struct GNUNET_CONFIGURATION_Handle *c,
                   unsigned long long max_bg_queries);

Modified: gnunet/src/gns/gnunet-service-gns_shorten.c
===================================================================
--- gnunet/src/gns/gnunet-service-gns_shorten.c 2013-10-16 21:03:53 UTC (rev 
30236)
+++ gnunet/src/gns/gnunet-service-gns_shorten.c 2013-10-16 21:52:04 UTC (rev 
30237)
@@ -94,6 +94,11 @@
   struct GNUNET_NAMESTORE_QueueEntry *namestore_task;
 
   /**
+   * Handle to namecache request
+   */
+  struct GNUNET_NAMECACHE_QueueEntry *namecache_task;
+
+  /**
    * Task to abort DHT lookup operation.
    */
   GNUNET_SCHEDULER_TaskIdentifier timeout_task;
@@ -117,6 +122,11 @@
 static struct GNUNET_NAMESTORE_Handle *namestore_handle;
 
 /**
+ * Our handle to the namecache service
+ */
+static struct GNUNET_NAMECACHE_Handle *namecache_handle;
+
+/**
  * Resolver handle to the dht
  */
 static struct GNUNET_DHT_Handle *dht_handle;
@@ -140,6 +150,11 @@
     GNUNET_NAMESTORE_cancel (gph->namestore_task);
     gph->namestore_task = NULL;
   }
+  if (NULL != gph->namecache_task)
+  {
+    GNUNET_NAMECACHE_cancel (gph->namecache_task);
+    gph->namecache_task = NULL;
+  }
   if (GNUNET_SCHEDULER_NO_TASK != gph->timeout_task)
   {
     GNUNET_SCHEDULER_cancel (gph->timeout_task);
@@ -198,7 +213,7 @@
   struct GetPseuAuthorityHandle *gph = cls;
   struct GNUNET_CRYPTO_EcdsaPublicKey pub;
 
-  gph->namestore_task = NULL;
+  gph->namecache_task = NULL;
   if (NULL == block)
   {
     process_pseu_lookup_ns (gph, 0, NULL);
@@ -240,7 +255,7 @@
   GNUNET_GNSRECORD_query_from_public_key (&pub,
                                          label,
                                          &query);
-  gph->namestore_task = GNUNET_NAMESTORE_lookup_block (namestore_handle,
+  gph->namecache_task = GNUNET_NAMECACHE_lookup_block (namecache_handle,
                                                       &query,
                                                       &process_pseu_block_ns,
                                                       gph);
@@ -553,13 +568,16 @@
  * Initialize the shortening subsystem
  *
  * @param nh the namestore handle
+ * @param nc the namecache handle
  * @param dht the dht handle
  */
 void
 GNS_shorten_init (struct GNUNET_NAMESTORE_Handle *nh,
+                  struct GNUNET_NAMECACHE_Handle *nc,
                  struct GNUNET_DHT_Handle *dht)
 {
   namestore_handle = nh;
+  namecache_handle = nc;
   dht_handle = dht;
 }
 
@@ -575,6 +593,7 @@
     free_get_pseu_authority_handle (gph_head);
   dht_handle = NULL;
   namestore_handle = NULL;
+  namecache_handle = NULL;
 }
 
 /* end of gnunet-service-gns_shorten.c */

Modified: gnunet/src/gns/gnunet-service-gns_shorten.h
===================================================================
--- gnunet/src/gns/gnunet-service-gns_shorten.h 2013-10-16 21:03:53 UTC (rev 
30236)
+++ gnunet/src/gns/gnunet-service-gns_shorten.h 2013-10-16 21:52:04 UTC (rev 
30237)
@@ -26,6 +26,7 @@
 #define GNS_SHORTEN_H
 #include "gns.h"
 #include "gnunet_dht_service.h"
+#include "gnunet_namecache_service.h"
 #include "gnunet_namestore_service.h"
 
 
@@ -34,10 +35,12 @@
  * MUST be called before #GNS_shorten_start.
  *
  * @param nh handle to the namestore
+ * @param nc the namecache handle
  * @param dht handle to the dht
  */
 void
 GNS_shorten_init (struct GNUNET_NAMESTORE_Handle *nh,
+                  struct GNUNET_NAMECACHE_Handle *nc,
                  struct GNUNET_DHT_Handle *dht);
 
 

Modified: gnunet/src/include/gnunet_namestore_plugin.h
===================================================================
--- gnunet/src/include/gnunet_namestore_plugin.h        2013-10-16 21:03:53 UTC 
(rev 30236)
+++ gnunet/src/include/gnunet_namestore_plugin.h        2013-10-16 21:52:04 UTC 
(rev 30237)
@@ -39,16 +39,6 @@
 
 
 /**
- * Function called for matching blocks.
- *
- * @param cls closure
- * @param block lookup result
- */
-typedef void (*GNUNET_GNSRECORD_BlockCallback) (void *cls,
-                                               const struct 
GNUNET_GNSRECORD_Block *block);
-
-
-/**
  * Function called by for each matching record.
  *
  * @param cls closure
@@ -76,34 +66,6 @@
   void *cls;
 
   /**
-   * Cache a block in the datastore. Overwrites existing blocks
-   * for the same zone and label.
-   *
-   * @param cls closure (internal context for the plugin)
-   * @param block block to cache
-   * @return #GNUNET_OK on success, else #GNUNET_SYSERR
-   */
-  int (*cache_block) (void *cls,
-                     const struct GNUNET_GNSRECORD_Block *block);
-
-
-  /**
-   * Get the block for a particular zone and label in the
-   * datastore.  Will return at most one result to the iterator.
-   *
-   * @param cls closure (internal context for the plugin)
-   * @param query hash of public key derived from the zone and the label
-   * @param iter function to call with the result
-   * @param iter_cls closure for @a iter
-   * @return #GNUNET_OK on success, #GNUNET_NO if there were no results, 
#GNUNET_SYSERR on error
-   */
-  int (*lookup_block) (void *cls,
-                      const struct GNUNET_HashCode *query,
-                      GNUNET_GNSRECORD_BlockCallback iter, void *iter_cls);
-
-
-
-  /**
    * Store a record in the datastore for which we are the authority.
    * Removes any existing record in the same zone with the same name.
    *

Modified: gnunet/src/include/gnunet_namestore_service.h
===================================================================
--- gnunet/src/include/gnunet_namestore_service.h       2013-10-16 21:03:53 UTC 
(rev 30236)
+++ gnunet/src/include/gnunet_namestore_service.h       2013-10-16 21:52:04 UTC 
(rev 30237)
@@ -96,23 +96,6 @@
 
 /**
  * Store an item in the namestore.  If the item is already present,
- * it is replaced with the new record.
- *
- * @param h handle to the namestore
- * @param block block to store
- * @param cont continuation to call when done
- * @param cont_cls closure for @a cont
- * @return handle to abort the request
- */
-struct GNUNET_NAMESTORE_QueueEntry *
-GNUNET_NAMESTORE_block_cache (struct GNUNET_NAMESTORE_Handle *h,
-                             const struct GNUNET_GNSRECORD_Block *block,
-                             GNUNET_NAMESTORE_ContinuationWithStatus cont,
-                             void *cont_cls);
-
-
-/**
- * Store an item in the namestore.  If the item is already present,
  * it is replaced with the new record.  Use an empty array to
  * remove all records under the given name.
  *
@@ -135,35 +118,8 @@
                                void *cont_cls);
 
 
-/**
- * Process a record that was stored in the namestore.
- *
- * @param cls closure
- * @param block block that was stored in the namestore
- */
-typedef void (*GNUNET_GNSRECORD_BlockProcessor) (void *cls,
-                                                const struct 
GNUNET_GNSRECORD_Block *block);
 
-
 /**
- * Get a result for a particular key from the namestore.  The processor
- * will only be called once.
- *
- * @param h handle to the namestore
- * @param derived_hash hash of zone key combined with name to lookup
- *        then at the end once with NULL
- * @param proc function to call on the matching block, or with
- *        NULL if there is no matching block
- * @param proc_cls closure for @a proc
- * @return a handle that can be used to cancel
- */
-struct GNUNET_NAMESTORE_QueueEntry *
-GNUNET_NAMESTORE_lookup_block (struct GNUNET_NAMESTORE_Handle *h,
-                              const struct GNUNET_HashCode *derived_hash,
-                              GNUNET_GNSRECORD_BlockProcessor proc, void 
*proc_cls);
-
-
-/**
  * Process a record that was stored in the namestore.
  *
  * @param cls closure
@@ -223,7 +179,7 @@
  * @param zone zone to access, NULL for all zones
  * @param proc function to call on each name from the zone; it
  *        will be called repeatedly with a value (if available)
- *        and always once at the end with a name of NULL.
+ *        and always once at the end with a label of NULL.
  * @param proc_cls closure for @a proc
  * @return an iterator handle to use for iteration
  */

Modified: gnunet/src/namecache/namecache.conf.in
===================================================================
--- gnunet/src/namecache/namecache.conf.in      2013-10-16 21:03:53 UTC (rev 
30236)
+++ gnunet/src/namecache/namecache.conf.in      2013-10-16 21:52:04 UTC (rev 
30237)
@@ -4,7 +4,7 @@
 UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-service-namecache.sock
 UNIX_MATCH_UID = NO
 UNIX_MATCH_GID = YES
address@hidden@ PORT = 2099
address@hidden@ PORT = 2113
 HOSTNAME = localhost
 BINARY = gnunet-service-namecache
 ACCEPT_FROM = 127.0.0.1;

Modified: gnunet/src/namecache/namecache_api.c
===================================================================
--- gnunet/src/namecache/namecache_api.c        2013-10-16 21:03:53 UTC (rev 
30236)
+++ gnunet/src/namecache/namecache_api.c        2013-10-16 21:52:04 UTC (rev 
30237)
@@ -31,7 +31,7 @@
 #include "gnunet_crypto_lib.h"
 #include "gnunet_constants.h"
 #include "gnunet_dnsparser_lib.h"
-#include "gnunet_arm_service.h"
+#include "gnunet_gnsrecord_lib.h"
 #include "gnunet_signatures.h"
 #include "gnunet_namecache_service.h"
 #include "gnunet_namestore_service.h"
@@ -76,7 +76,7 @@
   /**
    * Function to call with the blocks we get back; or NULL.
    */
-  GNUNET_GNSRECORD_BlockProcessor block_proc;
+  GNUNET_NAMECACHE_BlockProcessor block_proc;
 
   /**
    * Closure for @e block_proc.
@@ -683,7 +683,7 @@
 struct GNUNET_NAMECACHE_QueueEntry *
 GNUNET_NAMECACHE_lookup_block (struct GNUNET_NAMECACHE_Handle *h,
                               const struct GNUNET_HashCode *derived_hash,
-                              GNUNET_GNSRECORD_BlockProcessor proc, void 
*proc_cls)
+                              GNUNET_NAMECACHE_BlockProcessor proc, void 
*proc_cls)
 {
   struct GNUNET_NAMECACHE_QueueEntry *qe;
   struct PendingMessage *pe;

Modified: gnunet/src/namestore/Makefile.am
===================================================================
--- gnunet/src/namestore/Makefile.am    2013-10-16 21:03:53 UTC (rev 30236)
+++ gnunet/src/namestore/Makefile.am    2013-10-16 21:52:04 UTC (rev 30237)
@@ -39,7 +39,6 @@
 TESTING_TESTS = \
  test_namestore_api_store \
  test_namestore_api_store_update \
- test_namestore_api_cache_block \
  test_namestore_api_lookup_public \
  test_namestore_api_remove \
  test_namestore_api_remove_not_existing_record \
@@ -123,6 +122,7 @@
  gnunet-service-namestore.c
 
 gnunet_service_namestore_LDADD = \
+  $(top_builddir)/src/namecache/libgnunetnamecache.la \
   $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \
   $(top_builddir)/src/statistics/libgnunetstatistics.la \
   $(top_builddir)/src/util/libgnunetutil.la \
@@ -183,22 +183,16 @@
   $(top_builddir)/src/testing/libgnunettesting.la \
   $(top_builddir)/src/util/libgnunetutil.la \
   $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \
+  $(top_builddir)/src/namecache/libgnunetnamecache.la \
   $(top_builddir)/src/namestore/libgnunetnamestore.la
 
-test_namestore_api_cache_block_SOURCES = \
- test_namestore_api_cache_block.c
-test_namestore_api_cache_block_LDADD = \
-  $(top_builddir)/src/testing/libgnunettesting.la \
-  $(top_builddir)/src/util/libgnunetutil.la \
-  $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \
-  $(top_builddir)/src/namestore/libgnunetnamestore.la
-
 test_namestore_api_lookup_public_SOURCES = \
  test_namestore_api_lookup_public.c
 test_namestore_api_lookup_public_LDADD = \
   $(top_builddir)/src/testing/libgnunettesting.la \
   $(top_builddir)/src/util/libgnunetutil.la \
   $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \
+  $(top_builddir)/src/namecache/libgnunetnamecache.la \
   $(top_builddir)/src/namestore/libgnunetnamestore.la
 
 test_namestore_api_put_SOURCES = \

Modified: gnunet/src/namestore/gnunet-namestore-fcfsd.c
===================================================================
--- gnunet/src/namestore/gnunet-namestore-fcfsd.c       2013-10-16 21:03:53 UTC 
(rev 30236)
+++ gnunet/src/namestore/gnunet-namestore-fcfsd.c       2013-10-16 21:52:04 UTC 
(rev 30237)
@@ -132,6 +132,11 @@
   struct GNUNET_NAMESTORE_QueueEntry *qe;
 
   /**
+   * Active iteration with the namestore.
+   */
+  struct GNUNET_NAMESTORE_ZoneIterator *zi;
+
+  /**
    * Current processing phase.
    */
   enum Phase phase;
@@ -460,16 +465,14 @@
 }
 
 
-
-
 /**
  * Continuation called to notify client about result of the
  * operation.
  *
  * @param cls closure
- * @param success GNUNET_SYSERR on failure (including timeout/queue 
drop/failure to validate)
- *                GNUNET_NO if content was already there
- *                GNUNET_YES (or other positive value) on success
+ * @param success #GNUNET_SYSERR on failure (including timeout/queue 
drop/failure to validate)
+ *                #GNUNET_NO if content was already there
+ *                #GNUNET_YES (or other positive value) on success
  * @param emsg NULL on success, otherwise an error message
  */
 static void
@@ -500,7 +503,7 @@
  * @param cls closure
  * @param zone_key public key of the zone
  * @param name name that is being mapped (at most 255 characters long)
- * @param rd_count number of entries in 'rd' array
+ * @param rd_count number of entries in @a rd array
  * @param rd array of records with data to store
  */
 static void
@@ -541,84 +544,62 @@
 
 
 /**
- * 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 rd_count number of entries in 'rd' array
- * @param rd array of records with data to store
- */
-static void
-lookup_result_processor (void *cls,
-                        unsigned int rd_count,
-                        const struct GNUNET_GNSRECORD_Data *rd)
-{
-  struct Request *request = cls;
-  struct GNUNET_CRYPTO_EcdsaPublicKey pub;
-
-  if (0 != rd_count)
-  {
-    GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-               _("Found %u existing records for domain `%s'\n"),
-               rd_count,
-               request->domain_name);
-    request->phase = RP_FAIL;
-    run_httpd_now ();
-    return;
-  }
-  if (GNUNET_OK !=
-      GNUNET_CRYPTO_ecdsa_public_key_from_string (request->public_key,
-                                               strlen (request->public_key),
-                                               &pub))
-  {
-    GNUNET_break (0);
-    request->phase = RP_FAIL;
-    run_httpd_now ();
-    return;
-  }
-  request->qe = GNUNET_NAMESTORE_zone_to_name (ns,
-                                              &fcfs_zone_pkey,
-                                              &pub,
-                                              &zone_to_name_cb,
-                                              request);
-}
-
-
-/**
  * We got a block back from the namestore.  Decrypt it
  * and continue to process the result.
  *
  * @param cls the 'struct Request' we are processing
- * @param block block returned form namestore, NULL on error
+ * @param zone private key of the zone; NULL on disconnect
+ * @param label label of the records; NULL on disconnect
+ * @param rd_count number of entries in @a rd array, 0 if label was deleted
+ * @param rd array of records with data to store
  */
 static void
 lookup_block_processor (void *cls,
-                       const struct GNUNET_GNSRECORD_Block *block)
+                        const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone,
+                        const char *label,
+                        unsigned int rd_count,
+                        const struct GNUNET_GNSRECORD_Data *rd)
 {
   struct Request *request = cls;
   struct GNUNET_CRYPTO_EcdsaPublicKey pub;
 
   request->qe = NULL;
-  if (NULL == block)
+  if (NULL == label)
   {
-    lookup_result_processor (request, 0, NULL);
+    request->zi = NULL;
+    if (GNUNET_OK !=
+        GNUNET_CRYPTO_ecdsa_public_key_from_string (request->public_key,
+                                                    strlen 
(request->public_key),
+                                                    &pub))
+    {
+      GNUNET_break (0);
+      request->phase = RP_FAIL;
+      run_httpd_now ();
+      return;
+    }
+    request->qe = GNUNET_NAMESTORE_zone_to_name (ns,
+                                                 &fcfs_zone_pkey,
+                                                 &pub,
+                                                 &zone_to_name_cb,
+                                                 request);
     return;
   }
-  GNUNET_CRYPTO_ecdsa_key_get_public (&fcfs_zone_pkey,
-                                   &pub);
-  if (GNUNET_OK !=
-      GNUNET_GNSRECORD_block_decrypt (block,
-                                     &pub,
-                                     request->domain_name,
-                                     &lookup_result_processor,
-                                     request))
+  if (0 != strcmp (label,
+                   request->domain_name))
   {
-    GNUNET_break (0);
-    request->phase = RP_FAIL;
-    run_httpd_now ();
+    GNUNET_NAMESTORE_zone_iterator_next (request->zi);
     return;
   }
+  GNUNET_NAMESTORE_zone_iteration_stop (request->zi);
+  request->zi = NULL;
+  GNUNET_break (0 != rd_count);
+  GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+              _("Found %u existing records for domain `%s'\n"),
+              rd_count,
+              request->domain_name);
+  request->phase = RP_FAIL;
+  run_httpd_now ();
+  return;
 }
 
 
@@ -638,7 +619,7 @@
  *        data *will* be made available incrementally in
  *        upload_data)
  * @param upload_data_size set initially to the size of the
- *        upload_data provided; the method must update this
+ *        @a upload_data provided; the method must update this
  *        value to the number of bytes NOT processed;
  * @param ptr pointer to location where we store the 'struct Request'
  * @return MHD_YES if the connection was handled successfully,
@@ -657,9 +638,8 @@
 {
   struct MHD_Response *response;
   struct Request *request;
+  struct GNUNET_CRYPTO_EcdsaPublicKey pub;
   int ret;
-  struct GNUNET_CRYPTO_EcdsaPublicKey pub;
-  struct GNUNET_HashCode query;
 
   if ( (0 == strcmp (method, MHD_HTTP_METHOD_GET)) ||
        (0 == strcmp (method, MHD_HTTP_METHOD_HEAD)) )
@@ -709,8 +689,8 @@
       }
       if (GNUNET_OK !=
          GNUNET_CRYPTO_ecdsa_public_key_from_string (request->public_key,
-                                                   strlen 
(request->public_key),
-                                                   &pub))
+                                                      strlen 
(request->public_key),
+                                                      &pub))
       {
        /* parse error */
        return fill_s_reply ("Failed to parse given public key",
@@ -736,15 +716,11 @@
                                 request, connection);
          }
          request->phase = RP_LOOKUP;
-         GNUNET_CRYPTO_ecdsa_key_get_public (&fcfs_zone_pkey,
-                                           &pub);
-         GNUNET_GNSRECORD_query_from_public_key (&pub,
-                                                 request->domain_name,
-                                                 &query);
-         request->qe = GNUNET_NAMESTORE_lookup_block (ns,
-                                                      &query,
-                                                      &lookup_block_processor,
-                                                      request);
+          /* FIXME: would be nice to have a more efficient API for this */
+         request->zi = GNUNET_NAMESTORE_zone_iteration_start (ns,
+                                                               &fcfs_zone_pkey,
+                                                               
&lookup_block_processor,
+                                                               request);
          break;
        case RP_LOOKUP:
          break;

Modified: gnunet/src/namestore/gnunet-namestore.c
===================================================================
--- gnunet/src/namestore/gnunet-namestore.c     2013-10-16 21:03:53 UTC (rev 
30236)
+++ gnunet/src/namestore/gnunet-namestore.c     2013-10-16 21:52:04 UTC (rev 
30237)
@@ -75,11 +75,6 @@
 static struct GNUNET_NAMESTORE_QueueEntry *add_qe;
 
 /**
- * Queue entry for the 'list' operation (in combination with a name).
- */
-static struct GNUNET_NAMESTORE_QueueEntry *list_qe;
-
-/**
  * Queue entry for the 'reverse lookup' operation (in combination with a name).
  */
 static struct GNUNET_NAMESTORE_QueueEntry *reverse_qe;
@@ -215,11 +210,6 @@
     GNUNET_NAMESTORE_cancel (add_qe);
     add_qe = NULL;
   }
-  if (NULL != list_qe)
-  {
-    GNUNET_NAMESTORE_cancel (list_qe);
-    list_qe = NULL;
-  }
   if (NULL != add_qe_uri)
   {
     GNUNET_NAMESTORE_cancel (add_qe_uri);
@@ -261,7 +251,6 @@
 test_finished ()
 {
   if ( (NULL == add_qe) &&
-       (NULL == list_qe) &&
        (NULL == add_qe_uri) &&
        (NULL == del_qe) &&
        (NULL == reverse_qe) &&
@@ -329,14 +318,14 @@
  *
  * @param cls closure
  * @param zone_key private key of the zone
- * @param name name that is being mapped (at most 255 characters long)
+ * @param rname name that is being mapped (at most 255 characters long)
  * @param rd_len number of entries in @a rd array
  * @param rd array of records with data to store
  */
 static void
 display_record (void *cls,
                const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone_key,
-               const char *name,
+               const char *rname,
                unsigned int rd_len,
                const struct GNUNET_GNSRECORD_Data *rd)
 {
@@ -347,15 +336,21 @@
   struct GNUNET_TIME_Absolute at;
   struct GNUNET_TIME_Relative rt;
 
-  if (NULL == name)
+  if (NULL == rname)
   {
     list_it = NULL;
     test_finished ();
     return;
   }
+  if ( (NULL != name) &&
+       (0 != strcmp (name, rname)) )
+  {
+    GNUNET_NAMESTORE_zone_iterator_next (list_it);
+    return;
+  }
   FPRINTF (stdout,
           "%s:\n",
-          name);
+          rname);
   for (i=0;i<rd_len;i++)
   {
     typestring = GNUNET_GNSRECORD_number_to_typename (rd[i].record_type);
@@ -466,90 +461,7 @@
 }
 
 
-
 /**
- * Process a record that was stored in the namestore in a block.
- *
- * @param cls closure, NULL
- * @param rd_len number of entries in @a rd array
- * @param rd array of records with data to store
- */
-static void
-display_records_from_block (void *cls,
-                           unsigned int rd_len,
-                           const struct GNUNET_GNSRECORD_Data *rd)
-{
-  const char *typestring;
-  char *s;
-  unsigned int i;
-
-  if (0 == rd_len)
-  {
-    FPRINTF (stdout,
-            _("No records found for `%s'"),
-            name);
-    return;
-  }
-  FPRINTF (stdout,
-          "%s:\n",
-          name);
-  for (i=0;i<rd_len;i++)
-  {
-    typestring = GNUNET_GNSRECORD_number_to_typename (rd[i].record_type);
-    s = GNUNET_GNSRECORD_value_to_string (rd[i].record_type,
-                                         rd[i].data,
-                                         rd[i].data_size);
-    if (NULL == s)
-    {
-      FPRINTF (stdout, _("\tCorrupt or unsupported record of type %u\n"),
-              (unsigned int) rd[i].record_type);
-      continue;
-    }
-    FPRINTF (stdout,
-            "\t%s: %s\n",
-            typestring,
-            s);
-    GNUNET_free (s);
-  }
-  FPRINTF (stdout, "%s", "\n");
-}
-
-
-/**
- * Display block obtained from listing (by name).
- *
- * @param cls NULL
- * @param block NULL if not found
- */
-static void
-handle_block (void *cls,
-             const struct GNUNET_GNSRECORD_Block *block)
-{
-  struct GNUNET_CRYPTO_EcdsaPublicKey zone_pubkey;
-
-  list_qe = NULL;
-  GNUNET_CRYPTO_ecdsa_key_get_public (&zone_pkey,
-                                                 &zone_pubkey);
-  if (NULL == block)
-  {
-    fprintf (stderr,
-            "No matching block found\n");
-  }
-  else if (GNUNET_OK !=
-          GNUNET_GNSRECORD_block_decrypt (block,
-                                          &zone_pubkey,
-                                          name,
-                                          &display_records_from_block,
-                                          NULL))
-  {
-    fprintf (stderr,
-            "Failed to decrypt block!\n");
-  }
-  test_finished ();
-}
-
-
-/**
  * Function called with the result of our attempt to obtain a name for a given
  * public key.
  *
@@ -729,28 +641,10 @@
   }
   if (list)
   {
-    if (NULL == name)
-    {
-      list_it = GNUNET_NAMESTORE_zone_iteration_start (ns,
-                                                      &zone_pkey,
-                                                      &display_record,
-                                                      NULL);
-    }
-    else
-    {
-      struct GNUNET_HashCode query;
-      struct GNUNET_CRYPTO_EcdsaPublicKey zone_pubkey;
-
-      GNUNET_CRYPTO_ecdsa_key_get_public (&zone_pkey,
-                                                     &zone_pubkey);
-      GNUNET_GNSRECORD_query_from_public_key (&zone_pubkey,
-                                             name,
-                                             &query);
-      list_qe = GNUNET_NAMESTORE_lookup_block (ns,
-                                              &query,
-                                              &handle_block,
-                                              NULL);
-    }
+    list_it = GNUNET_NAMESTORE_zone_iteration_start (ns,
+                                                     &zone_pkey,
+                                                     &display_record,
+                                                     NULL);
   }
   if (NULL != reverse_pkey)
   {

Modified: gnunet/src/namestore/gnunet-service-namestore.c
===================================================================
--- gnunet/src/namestore/gnunet-service-namestore.c     2013-10-16 21:03:53 UTC 
(rev 30236)
+++ gnunet/src/namestore/gnunet-service-namestore.c     2013-10-16 21:52:04 UTC 
(rev 30237)
@@ -27,6 +27,7 @@
 #include "platform.h"
 #include "gnunet_util_lib.h"
 #include "gnunet_dnsparser_lib.h"
+#include "gnunet_namecache_service.h"
 #include "gnunet_namestore_service.h"
 #include "gnunet_namestore_plugin.h"
 #include "gnunet_signatures.h"
@@ -165,11 +166,49 @@
 
 
 /**
+ * Pending operation on the namecache.
+ */
+struct CacheOperation
+{
+
+  /**
+   * Kept in a DLL.
+   */
+  struct CacheOperation *prev;
+
+  /**
+   * Kept in a DLL.
+   */
+  struct CacheOperation *next;
+
+  /**
+   * Handle to namecache queue.
+   */
+  struct GNUNET_NAMECACHE_QueueEntry *qe;
+
+  /**
+   * Client to notify about the result.
+   */
+  struct GNUNET_SERVER_Client *client;
+
+  /**
+   * Client's request ID.
+   */
+  uint32_t rid;
+};
+
+
+/**
  * Configuration handle.
  */
 static const struct GNUNET_CONFIGURATION_Handle *GSN_cfg;
 
 /**
+ * Namecache handle.
+ */
+static struct GNUNET_NAMECACHE_Handle *namecache;
+
+/**
  * Database handle
  */
 static struct GNUNET_NAMESTORE_PluginFunctions *GSN_database;
@@ -195,6 +234,16 @@
 static struct NamestoreClient *client_tail;
 
 /**
+ * Head of cop DLL.
+ */
+static struct CacheOperation *cop_head;
+
+/**
+ * Tail of cop DLL.
+ */
+static struct CacheOperation *cop_tail;
+
+/**
  * First active zone monitor.
  */
 static struct ZoneMonitor *monitor_head;
@@ -222,6 +271,7 @@
 {
   struct ZoneIteration *no;
   struct NamestoreClient *nc;
+  struct CacheOperation *cop;
 
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
              "Stopping namestore service\n");
@@ -230,6 +280,16 @@
     GNUNET_SERVER_notification_context_destroy (snc);
     snc = NULL;
   }
+  while (NULL != (cop = cop_head))
+  {
+    GNUNET_NAMECACHE_cancel (cop->qe);
+    GNUNET_CONTAINER_DLL_remove (cop_head,
+                                 cop_tail,
+                                 cop);
+    GNUNET_free (cop);
+  }
+  GNUNET_NAMECACHE_disconnect (namecache);
+  namecache = NULL;
   while (NULL != (nc = client_head))
   {
     while (NULL != (no = nc->op_head))
@@ -266,6 +326,7 @@
   struct ZoneIteration *no;
   struct NamestoreClient *nc;
   struct ZoneMonitor *zm;
+  struct CacheOperation *cop;
 
   if (NULL == client)
     return;
@@ -297,6 +358,9 @@
       break;
     }
   }
+  for (cop = cop_head; NULL != cop; cop = cop->next)
+    if (client == cop->client)
+      cop->client = NULL;
 }
 
 
@@ -328,175 +392,6 @@
 
 
 /**
- * Context for name lookups passed from #handle_lookup_block to
- * #handle_lookup_block_it as closure
- */
-struct LookupBlockContext
-{
-  /**
-   * The client to send the response to
-   */
-  struct NamestoreClient *nc;
-
-  /**
-   * Operation id for the name lookup
-   */
-  uint32_t request_id;
-
-};
-
-
-/**
- * A #GNUNET_GNSRECORD_BlockCallback for name lookups in #handle_lookup_block
- *
- * @param cls a `struct LookupNameContext *` with information about the request
- * @param block the block
- */
-static void
-handle_lookup_block_it (void *cls,
-                       const struct GNUNET_GNSRECORD_Block *block)
-{
-  struct LookupBlockContext *lnc = cls;
-  struct LookupBlockResponseMessage *r;
-  size_t esize;
-
-  esize = ntohl (block->purpose.size)
-    - sizeof (struct GNUNET_CRYPTO_EccSignaturePurpose)
-    - sizeof (struct GNUNET_TIME_AbsoluteNBO);
-  r = GNUNET_malloc (sizeof (struct LookupBlockResponseMessage) + esize);
-  r->gns_header.header.type = htons 
(GNUNET_MESSAGE_TYPE_NAMESTORE_LOOKUP_BLOCK_RESPONSE);
-  r->gns_header.header.size = htons (sizeof (struct 
LookupBlockResponseMessage) + esize);
-  r->gns_header.r_id = htonl (lnc->request_id);
-  r->expire = block->expiration_time;
-  r->signature = block->signature;
-  r->derived_key = block->derived_key;
-  memcpy (&r[1], &block[1], esize);
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-             "Sending `%s' message with expiration time %s\n",
-             "NAMESTORE_LOOKUP_BLOCK_RESPONSE",
-              GNUNET_STRINGS_absolute_time_to_string 
(GNUNET_TIME_absolute_ntoh (r->expire)));
-  GNUNET_SERVER_notification_context_unicast (snc,
-                                             lnc->nc->client,
-                                             &r->gns_header.header,
-                                             GNUNET_NO);
-  GNUNET_free (r);
-}
-
-
-/**
- * Handles a #GNUNET_MESSAGE_TYPE_NAMESTORE_LOOKUP_BLOCK message
- *
- * @param cls unused
- * @param client client sending the message
- * @param message message of type 'struct LookupNameMessage'
- */
-static void
-handle_lookup_block (void *cls,
-                    struct GNUNET_SERVER_Client *client,
-                    const struct GNUNET_MessageHeader *message)
-{
-  const struct LookupBlockMessage *ln_msg;
-  struct LookupBlockContext lnc;
-  struct NamestoreClient *nc;
-  struct LookupBlockResponseMessage zir_end;
-  int ret;
-
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-             "Received `%s' message\n",
-             "NAMESTORE_LOOKUP_BLOCK");
-  nc = client_lookup(client);
-  ln_msg = (const struct LookupBlockMessage *) message;
-  lnc.request_id = ntohl (ln_msg->gns_header.r_id);
-  lnc.nc = nc;
-  if (GNUNET_SYSERR ==
-      (ret = GSN_database->lookup_block (GSN_database->cls,
-                                        &ln_msg->query,
-                                        &handle_lookup_block_it, &lnc)))
-  {
-    /* internal error (in database plugin); might be best to just hang up on
-       plugin rather than to signal that there are 'no' results, which
-       might also be false... */
-    GNUNET_break (0);
-    GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
-    return;
-  }
-  if (0 == ret)
-  {
-    /* no records match at all, generate empty response */
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-               "Sending empty `%s' message\n",
-               "NAMESTORE_LOOKUP_BLOCK_RESPONSE");
-    memset (&zir_end, 0, sizeof (zir_end));
-    zir_end.gns_header.header.type = htons 
(GNUNET_MESSAGE_TYPE_NAMESTORE_LOOKUP_BLOCK_RESPONSE);
-    zir_end.gns_header.header.size = htons (sizeof (struct 
LookupBlockResponseMessage));
-    zir_end.gns_header.r_id = ln_msg->gns_header.r_id;
-    GNUNET_SERVER_notification_context_unicast (snc,
-                                               client,
-                                               &zir_end.gns_header.header,
-                                               GNUNET_NO);
-
-  }
-  GNUNET_SERVER_receive_done (client, GNUNET_OK);
-}
-
-
-/**
- * Handles a #GNUNET_MESSAGE_TYPE_NAMESTORE_BLOCK_CACHE message
- *
- * @param cls unused
- * @param client client sending the message
- * @param message message of type 'struct BlockCacheMessage'
- */
-static void
-handle_block_cache (void *cls,
-                    struct GNUNET_SERVER_Client *client,
-                    const struct GNUNET_MessageHeader *message)
-{
-  struct NamestoreClient *nc;
-  const struct BlockCacheMessage *rp_msg;
-  struct BlockCacheResponseMessage rpr_msg;
-  struct GNUNET_GNSRECORD_Block *block;
-  size_t esize;
-  int res;
-
-  nc = client_lookup (client);
-  if (ntohs (message->size) < sizeof (struct BlockCacheMessage))
-  {
-    GNUNET_break (0);
-    GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
-    return;
-  }
-  rp_msg = (const struct BlockCacheMessage *) message;
-  esize = ntohs (rp_msg->gns_header.header.size) - sizeof (struct 
BlockCacheMessage);
-  block = GNUNET_malloc (sizeof (struct GNUNET_GNSRECORD_Block) + esize);
-  block->signature = rp_msg->signature;
-  block->derived_key = rp_msg->derived_key;
-  block->purpose.size = htonl (sizeof (struct 
GNUNET_CRYPTO_EccSignaturePurpose) +
-                              sizeof (struct GNUNET_TIME_AbsoluteNBO) +
-                              esize);
-  block->expiration_time = rp_msg->expire;
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-             "Received `%s' message with expiration time %s\n",
-             "NAMESTORE_BLOCK_CACHE",
-              GNUNET_STRINGS_absolute_time_to_string 
(GNUNET_TIME_absolute_ntoh (block->expiration_time)));
-  memcpy (&block[1], &rp_msg[1], esize);
-  res = GSN_database->cache_block (GSN_database->cls,
-                                  block);
-  GNUNET_free (block);
-
-  rpr_msg.gns_header.header.type = htons 
(GNUNET_MESSAGE_TYPE_NAMESTORE_BLOCK_CACHE_RESPONSE);
-  rpr_msg.gns_header.header.size = htons (sizeof (struct 
BlockCacheResponseMessage));
-  rpr_msg.gns_header.r_id = rp_msg->gns_header.r_id;
-  rpr_msg.op_result = htonl (res);
-  GNUNET_SERVER_notification_context_unicast (snc,
-                                             nc->client,
-                                             &rpr_msg.gns_header.header,
-                                             GNUNET_NO);
-  GNUNET_SERVER_receive_done (client, GNUNET_OK);
-}
-
-
-/**
  * Generate a 'struct LookupNameResponseMessage' and send it to the
  * given client using the given notification context.
  *
@@ -554,21 +449,84 @@
 
 
 /**
+ * Send response to the store request to the client.
+ *
+ * @param client client to talk to
+ * @param res status of the operation
+ * @param rid client's request ID
+ */
+static void
+send_store_response (struct GNUNET_SERVER_Client *client,
+                     int res,
+                     uint32_t rid)
+{
+  struct RecordStoreResponseMessage rcr_msg;
+
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+             "Sending `%s' message\n",
+             "RECORD_STORE_RESPONSE");
+  rcr_msg.gns_header.header.type = htons 
(GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_STORE_RESPONSE);
+  rcr_msg.gns_header.header.size = htons (sizeof (struct 
RecordStoreResponseMessage));
+  rcr_msg.gns_header.r_id = htonl (rid);
+  rcr_msg.op_result = htonl (res);
+  GNUNET_SERVER_notification_context_unicast (snc, client,
+                                             &rcr_msg.gns_header.header,
+                                             GNUNET_NO);
+
+}
+
+
+/**
+ * Cache operation complete, clean up.
+ *
+ * @param cls the `struct CacheOperation`
+ */
+static void
+finish_cache_operation (void *cls,
+                        int32_t success,
+                        const char *emsg)
+{
+  struct CacheOperation *cop = cls;
+
+  if (NULL != emsg)
+    GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+                _("Failed to replicate block in namecache: %s\n"),
+                emsg);
+  else
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "CACHE operation completed\n");
+  GNUNET_CONTAINER_DLL_remove (cop_head,
+                               cop_tail,
+                               cop);
+  if (NULL != cop->client)
+    send_store_response (cop->client,
+                         success,
+                         cop->rid);
+  GNUNET_free (cop);
+}
+
+
+/**
  * We just touched the plaintext information about a name in our zone;
  * refresh the corresponding (encrypted) block in the namestore.
  *
+ * @param client client responsible for the request
+ * @param rid request ID of the client
  * @param zone_key private key of the zone
  * @param name label for the records
  * @param rd_count number of records
  * @param rd records stored under the given @a name
  */
 static void
-refresh_block (const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone_key,
+refresh_block (struct GNUNET_SERVER_Client *client,
+               uint32_t rid,
+               const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone_key,
                const char *name,
                unsigned int rd_count,
                const struct GNUNET_GNSRECORD_Data *rd)
 {
   struct GNUNET_GNSRECORD_Block *block;
+  struct CacheOperation *cop;
 
   if (0 == rd_count)
     block = GNUNET_GNSRECORD_block_create (zone_key,
@@ -581,13 +539,17 @@
                                                                                
         rd),
                                            name,
                                            rd, rd_count);
-  if (GNUNET_OK !=
-      GSN_database->cache_block (GSN_database->cls,
-                                 block))
-  {
-    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                _("Failed to cache encrypted block of my own zone!\n"));
-  }
+
+  cop = GNUNET_new (struct CacheOperation);
+  cop->client = client;
+  cop->rid = rid;
+  GNUNET_CONTAINER_DLL_insert (cop_head,
+                               cop_tail,
+                               cop);
+  cop->qe = GNUNET_NAMECACHE_block_cache (namecache,
+                                          block,
+                                          &finish_cache_operation,
+                                          cop);
   GNUNET_free (block);
 }
 
@@ -601,12 +563,10 @@
  */
 static void
 handle_record_store (void *cls,
-                      struct GNUNET_SERVER_Client *client,
-                      const struct GNUNET_MessageHeader *message)
+                     struct GNUNET_SERVER_Client *client,
+                     const struct GNUNET_MessageHeader *message)
 {
-  struct NamestoreClient *nc;
   const struct RecordStoreMessage *rp_msg;
-  struct RecordStoreResponseMessage rcr_msg;
   size_t name_len;
   size_t msg_size;
   size_t msg_size_exp;
@@ -629,7 +589,6 @@
     GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
     return;
   }
-  nc = client_lookup (client);
   rp_msg = (const struct RecordStoreMessage *) message;
   rid = ntohl (rp_msg->gns_header.r_id);
   name_len = ntohs (rp_msg->name_len);
@@ -705,10 +664,6 @@
                                         rd_count, rd);
       if (GNUNET_OK == res)
       {
-        refresh_block (&rp_msg->private_key,
-                       conv_name,
-                       rd_count, rd);
-
         for (zm = monitor_head; NULL != zm; zm = zm->next)
           if (0 == memcmp (&rp_msg->private_key, &zm->zone,
                            sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey)))
@@ -721,19 +676,17 @@
       }
       GNUNET_free (conv_name);
     }
+    if (GNUNET_OK == res)
+    {
+      refresh_block (client, rid,
+                     &rp_msg->private_key,
+                     conv_name,
+                     rd_count, rd);
+      GNUNET_SERVER_receive_done (client, GNUNET_OK);
+      return;
+    }
   }
-
-  /* Send response */
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-             "Sending `%s' message\n",
-             "RECORD_STORE_RESPONSE");
-  rcr_msg.gns_header.header.type = htons 
(GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_STORE_RESPONSE);
-  rcr_msg.gns_header.header.size = htons (sizeof (struct 
RecordStoreResponseMessage));
-  rcr_msg.gns_header.r_id = htonl (rid);
-  rcr_msg.op_result = htonl (res);
-  GNUNET_SERVER_notification_context_unicast (snc, nc->client,
-                                             &rcr_msg.gns_header.header,
-                                             GNUNET_NO);
+  send_store_response (client, res, rid);
   GNUNET_SERVER_receive_done (client, GNUNET_OK);
 }
 
@@ -976,7 +929,8 @@
       break;
     }
   if (GNUNET_YES == do_refresh_block)
-    refresh_block (zone_key,
+    refresh_block (NULL, 0,
+                   zone_key,
                    name,
                    rd_count,
                    rd);
@@ -1299,10 +1253,6 @@
      const struct GNUNET_CONFIGURATION_Handle *cfg)
 {
   static const struct GNUNET_SERVER_MessageHandler handlers[] = {
-    {&handle_lookup_block, NULL,
-     GNUNET_MESSAGE_TYPE_NAMESTORE_LOOKUP_BLOCK, sizeof (struct 
LookupBlockMessage)},
-    {&handle_block_cache, NULL,
-    GNUNET_MESSAGE_TYPE_NAMESTORE_BLOCK_CACHE, 0},
     {&handle_record_store, NULL,
      GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_STORE, 0},
     {&handle_zone_to_name, NULL,
@@ -1322,7 +1272,7 @@
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting namestore service\n");
   GSN_cfg = cfg;
   monitor_nc = GNUNET_SERVER_notification_context_create (server, 1);
-
+  namecache = GNUNET_NAMECACHE_connect (cfg);
   /* Loading database plugin */
   if (GNUNET_OK !=
       GNUNET_CONFIGURATION_get_value_string (cfg, "namestore", "database",

Modified: gnunet/src/namestore/namestore_api.c
===================================================================
--- gnunet/src/namestore/namestore_api.c        2013-10-16 21:03:53 UTC (rev 
30236)
+++ gnunet/src/namestore/namestore_api.c        2013-10-16 21:52:04 UTC (rev 
30237)
@@ -83,16 +83,6 @@
   void *proc_cls;
 
   /**
-   * Function to call with the blocks we get back; or NULL.
-   */
-  GNUNET_GNSRECORD_BlockProcessor block_proc;
-
-  /**
-   * Closure for @e block_proc.
-   */
-  void *block_proc_cls;
-
-  /**
    * The operation id this zone iteration operation has
    */
   uint32_t op_id;
@@ -259,91 +249,6 @@
 
 /**
  * Handle an incoming message of type
- * #GNUNET_MESSAGE_TYPE_NAMESTORE_LOOKUP_BLOCK_RESPONSE.
- *
- * @param qe the respective entry in the message queue
- * @param msg the message we received
- * @param size the message size
- * @return #GNUNET_OK on success, #GNUNET_SYSERR on error and we did NOT 
notify the client
- */
-static int
-handle_lookup_block_response (struct GNUNET_NAMESTORE_QueueEntry *qe,
-                             const struct LookupBlockResponseMessage *msg,
-                             size_t size)
-{
-  struct GNUNET_GNSRECORD_Block *block;
-  char buf[size + sizeof (struct GNUNET_GNSRECORD_Block)
-          - sizeof (struct LookupBlockResponseMessage)];
-
-  LOG (GNUNET_ERROR_TYPE_DEBUG,
-       "Received `%s'\n",
-       "LOOKUP_BLOCK_RESPONSE");
-  if (0 == GNUNET_TIME_absolute_ntoh (msg->expire).abs_value_us)
-  {
-    /* no match found */
-    if (NULL != qe->block_proc)
-      qe->block_proc (qe->block_proc_cls, NULL);
-    return GNUNET_OK;
-  }
-
-  block = (struct GNUNET_GNSRECORD_Block *) buf;
-  block->signature = msg->signature;
-  block->derived_key = msg->derived_key;
-  block->purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_GNS_RECORD_SIGN);
-  block->purpose.size = htonl (size - sizeof (struct 
LookupBlockResponseMessage) +
-                              sizeof (struct GNUNET_TIME_AbsoluteNBO) +
-                              sizeof (struct 
GNUNET_CRYPTO_EccSignaturePurpose));
-  block->expiration_time = msg->expire;
-  memcpy (&block[1],
-         &msg[1],
-         size - sizeof (struct LookupBlockResponseMessage));
-  if (GNUNET_OK !=
-      GNUNET_GNSRECORD_block_verify (block))
-  {
-    GNUNET_break (0);
-    return GNUNET_SYSERR;
-  }
-  if (NULL != qe->block_proc)
-    qe->block_proc (qe->block_proc_cls, block);
-  else
-    GNUNET_break (0);
-  return GNUNET_OK;
-}
-
-
-/**
- * Handle an incoming message of type
- * #GNUNET_MESSAGE_TYPE_NAMESTORE_BLOCK_CACHE_RESPONSE
- *
- * @param qe the respective entry in the message queue
- * @param msg the message we received
- * @param size the message size
- * @return #GNUNET_OK on success, #GNUNET_SYSERR on error and we did NOT 
notify the client
- */
-static int
-handle_block_cache_response (struct GNUNET_NAMESTORE_QueueEntry *qe,
-                           const struct BlockCacheResponseMessage *msg,
-                           size_t size)
-{
-  int res;
-
-  LOG (GNUNET_ERROR_TYPE_DEBUG,
-       "Received `%s'\n",
-       "BLOCK_CACHE_RESPONSE");
-  res = ntohl (msg->op_result);
-  /* TODO: add actual error message from namestore to response... */
-  if (NULL != qe->cont)
-    qe->cont (qe->cont_cls,
-             res,
-             (GNUNET_OK == res) ?
-             NULL
-             : _("Namestore failed to cache block"));
-  return GNUNET_OK;
-}
-
-
-/**
- * Handle an incoming message of type
  * #GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_STORE_RESPONSE
  *
  * @param qe the respective entry in the message queue
@@ -536,20 +441,6 @@
   /* handle different message type */
   switch (type)
   {
-  case GNUNET_MESSAGE_TYPE_NAMESTORE_LOOKUP_BLOCK_RESPONSE:
-    if (size < sizeof (struct LookupBlockResponseMessage))
-    {
-      GNUNET_break (0);
-      return GNUNET_SYSERR;
-    }
-    return handle_lookup_block_response (qe, (const struct 
LookupBlockResponseMessage *) msg, size);
-  case GNUNET_MESSAGE_TYPE_NAMESTORE_BLOCK_CACHE_RESPONSE:
-    if (size != sizeof (struct BlockCacheResponseMessage))
-    {
-      GNUNET_break (0);
-      return GNUNET_SYSERR;
-    }
-    return handle_block_cache_response (qe, (const struct 
BlockCacheResponseMessage *) msg, size);
   case GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_STORE_RESPONSE:
     if (size != sizeof (struct RecordStoreResponseMessage))
     {
@@ -1010,64 +901,6 @@
 
 /**
  * Store an item in the namestore.  If the item is already present,
- * it is replaced with the new record.
- *
- * @param h handle to the namestore
- * @param block block to store
- * @param cont continuation to call when done
- * @param cont_cls closure for cont
- * @return handle to abort the request
- */
-struct GNUNET_NAMESTORE_QueueEntry *
-GNUNET_NAMESTORE_block_cache (struct GNUNET_NAMESTORE_Handle *h,
-                             const struct GNUNET_GNSRECORD_Block *block,
-                             GNUNET_NAMESTORE_ContinuationWithStatus cont,
-                             void *cont_cls)
-{
-  struct GNUNET_NAMESTORE_QueueEntry *qe;
-  struct PendingMessage *pe;
-  struct BlockCacheMessage *msg;
-  uint32_t rid;
-  size_t blen;
-  size_t msg_size;
-
-  GNUNET_assert (NULL != h);
-  blen = ntohl (block->purpose.size)
-    - sizeof (struct GNUNET_TIME_AbsoluteNBO)
-    - sizeof (struct GNUNET_CRYPTO_EccSignaturePurpose);
-  rid = get_op_id (h);
-  qe = GNUNET_new (struct GNUNET_NAMESTORE_QueueEntry);
-  qe->nsh = h;
-  qe->cont = cont;
-  qe->cont_cls = cont_cls;
-  qe->op_id = rid;
-  GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, qe);
-
-  /* setup msg */
-  msg_size = sizeof (struct BlockCacheMessage) + blen;
-  pe = GNUNET_malloc (sizeof (struct PendingMessage) + msg_size);
-  pe->size = msg_size;
-  msg = (struct BlockCacheMessage *) &pe[1];
-  msg->gns_header.header.type = htons 
(GNUNET_MESSAGE_TYPE_NAMESTORE_BLOCK_CACHE);
-  msg->gns_header.header.size = htons (msg_size);
-  msg->gns_header.r_id = htonl (rid);
-  msg->expire = block->expiration_time;
-  msg->signature = block->signature;
-  msg->derived_key = block->derived_key;
-  memcpy (&msg[1], &block[1], blen);
-  LOG (GNUNET_ERROR_TYPE_DEBUG,
-       "Sending `%s' message with size %u and expiration %s\n",
-       "NAMESTORE_BLOCK_CACHE",
-       (unsigned int) msg_size,
-       GNUNET_STRINGS_absolute_time_to_string (GNUNET_TIME_absolute_ntoh 
(msg->expire)));
-  GNUNET_CONTAINER_DLL_insert_tail (h->pending_head, h->pending_tail, pe);
-  do_transmit (h);
-  return qe;
-}
-
-
-/**
- * Store an item in the namestore.  If the item is already present,
  * it is replaced with the new record.  Use an empty array to
  * remove all records under the given name.
  *
@@ -1149,55 +982,6 @@
 
 
 /**
- * Get a result for a particular key from the namestore.  The processor
- * will only be called once.
- *
- * @param h handle to the namestore
- * @param derived_hash hash of zone key combined with name to lookup
- * @param proc function to call on the matching block, or with
- *        NULL if there is no matching block
- * @param proc_cls closure for proc
- * @return a handle that can be used to cancel
- */
-struct GNUNET_NAMESTORE_QueueEntry *
-GNUNET_NAMESTORE_lookup_block (struct GNUNET_NAMESTORE_Handle *h,
-                              const struct GNUNET_HashCode *derived_hash,
-                              GNUNET_GNSRECORD_BlockProcessor proc, void 
*proc_cls)
-{
-  struct GNUNET_NAMESTORE_QueueEntry *qe;
-  struct PendingMessage *pe;
-  struct LookupBlockMessage *msg;
-  size_t msg_size;
-  uint32_t rid;
-
-  GNUNET_assert (NULL != h);
-  GNUNET_assert (NULL != derived_hash);
-  LOG (GNUNET_ERROR_TYPE_DEBUG,
-       "Looking for block under %s\n",
-       GNUNET_h2s (derived_hash));
-  rid = get_op_id(h);
-  qe = GNUNET_new (struct GNUNET_NAMESTORE_QueueEntry);
-  qe->nsh = h;
-  qe->block_proc = proc;
-  qe->block_proc_cls = proc_cls;
-  qe->op_id = rid;
-  GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, qe);
-
-  msg_size = sizeof (struct LookupBlockMessage);
-  pe = GNUNET_malloc (sizeof (struct PendingMessage) + msg_size);
-  pe->size = msg_size;
-  msg = (struct LookupBlockMessage *) &pe[1];
-  msg->gns_header.header.type = htons 
(GNUNET_MESSAGE_TYPE_NAMESTORE_LOOKUP_BLOCK);
-  msg->gns_header.header.size = htons (msg_size);
-  msg->gns_header.r_id = htonl (rid);
-  msg->query = *derived_hash;
-  GNUNET_CONTAINER_DLL_insert_tail (h->pending_head, h->pending_tail, pe);
-  do_transmit (h);
-  return qe;
-}
-
-
-/**
  * Look for an existing PKEY delegation record for a given public key.
  * Returns at most one result to the processor.
  *

Modified: gnunet/src/namestore/plugin_namestore_postgres.c
===================================================================
--- gnunet/src/namestore/plugin_namestore_postgres.c    2013-10-16 21:03:53 UTC 
(rev 30236)
+++ gnunet/src/namestore/plugin_namestore_postgres.c    2013-10-16 21:52:04 UTC 
(rev 30237)
@@ -81,12 +81,6 @@
   /* create indices */
   if ( (GNUNET_OK !=
        GNUNET_POSTGRES_exec (dbh,
-                              "CREATE INDEX ir_query_hash ON ns096blocks 
(query,expiration_time)")) ||
-       (GNUNET_OK !=
-       GNUNET_POSTGRES_exec (dbh,
-                              "CREATE INDEX ir_block_expiration ON ns096blocks 
(expiration_time)")) ||
-       (GNUNET_OK !=
-       GNUNET_POSTGRES_exec (dbh,
                               "CREATE INDEX ir_pkey_reverse ON ns097records 
(zone_private_key,pkey)")) ||
        (GNUNET_OK !=
        GNUNET_POSTGRES_exec (dbh,
@@ -159,69 +153,10 @@
     plugin->dbh = NULL;
     return GNUNET_SYSERR;
   }
+  create_indices (plugin->dbh);
 
-
-  if (GNUNET_YES ==
-      GNUNET_CONFIGURATION_get_value_yesno (plugin->cfg,
-                                           "namestore-postgres",
-                                           "TEMPORARY_TABLE"))
-  {
-    res =
-      PQexec (plugin->dbh,
-              "CREATE TEMPORARY TABLE ns096blocks ("
-             " query BYTEA NOT NULL DEFAULT '',"
-             " block BYTEA NOT NULL DEFAULT '',"
-             " expiration_time BIGINT NOT NULL DEFAULT 0"
-             ")" "WITH OIDS");
-  }
-  else
-  {
-    res =
-      PQexec (plugin->dbh,
-              "CREATE TABLE ns096blocks ("
-             " query BYTEA NOT NULL DEFAULT '',"
-             " block BYTEA NOT NULL DEFAULT '',"
-             " expiration_time BIGINT NOT NULL DEFAULT 0"
-             ")" "WITH OIDS");
-  }
-  if ( (NULL == res) ||
-       ((PQresultStatus (res) != PGRES_COMMAND_OK) &&
-        (0 != strcmp ("42P07",    /* duplicate table */
-                      PQresultErrorField
-                      (res,
-                       PG_DIAG_SQLSTATE)))))
-  {
-    (void) GNUNET_POSTGRES_check_result (plugin->dbh, res,
-                                         PGRES_COMMAND_OK, "CREATE TABLE",
-                                        "ns096blocks");
-    PQfinish (plugin->dbh);
-    plugin->dbh = NULL;
-    return GNUNET_SYSERR;
-  }
-  if (PQresultStatus (res) == PGRES_COMMAND_OK)
-    create_indices (plugin->dbh);
-  PQclear (res);
-
   if ((GNUNET_OK !=
        GNUNET_POSTGRES_prepare (plugin->dbh,
-                               "cache_block",
-                               "INSERT INTO ns096blocks (query, block, 
expiration_time) VALUES "
-                               "($1, $2, $3)", 3)) ||
-      (GNUNET_OK !=
-       GNUNET_POSTGRES_prepare (plugin->dbh,
-                               "expire_blocks",
-                               "DELETE FROM ns096blocks WHERE 
expiration_time<$1", 1)) ||
-      (GNUNET_OK !=
-       GNUNET_POSTGRES_prepare (plugin->dbh,
-                               "delete_block",
-                               "DELETE FROM ns096blocks WHERE query=$1 AND 
expiration_time<=$2", 2)) ||
-      (GNUNET_OK !=
-       GNUNET_POSTGRES_prepare (plugin->dbh,
-                               "lookup_block",
-                               "SELECT block FROM ns096blocks WHERE query=$1"
-                               " ORDER BY expiration_time DESC LIMIT 1", 1)) ||
-      (GNUNET_OK !=
-       GNUNET_POSTGRES_prepare (plugin->dbh,
                                "store_records",
                                "INSERT INTO ns097records (zone_private_key, 
pkey, rvalue, record_count, record_data, label) VALUES "
                                 "($1, $2, $3, $4, $5, $6)", 6)) ||
@@ -254,202 +189,6 @@
 
 
 /**
- * Removes any expired block.
- *
- * @param plugin the plugin
- */
-static void
-namestore_postgres_expire_blocks (struct Plugin *plugin)
-{
-  struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get ();
-  struct GNUNET_TIME_AbsoluteNBO now_be = GNUNET_TIME_absolute_hton (now);
-  const char *paramValues[] = {
-    (const char *) &now_be
-  };
-  int paramLengths[] = {
-    sizeof (now_be)
-  };
-  const int paramFormats[] = { 1 };
-  PGresult *res;
-
-  res =
-    PQexecPrepared (plugin->dbh, "expire_blocks", 1,
-                   paramValues, paramLengths, paramFormats, 1);
-  if (GNUNET_OK !=
-      GNUNET_POSTGRES_check_result (plugin->dbh,
-                                    res,
-                                    PGRES_COMMAND_OK,
-                                    "PQexecPrepared",
-                                    "expire_blocks"))
-    return;
-  PQclear (res);
-}
-
-
-/**
- * Delete older block in the datastore.
- *
- * @param the plugin
- * @param query query for the block
- * @param expiration time how old does the block have to be for deletion
- * @return #GNUNET_OK on success, else #GNUNET_SYSERR
- */
-static void
-delete_old_block (struct Plugin *plugin,
-                  const struct GNUNET_HashCode *query,
-                  struct GNUNET_TIME_AbsoluteNBO expiration_time)
-{
-  const char *paramValues[] = {
-    (const char *) query,
-    (const char *) &expiration_time
-  };
-  int paramLengths[] = {
-    sizeof (*query),
-    sizeof (expiration_time)
-  };
-  const int paramFormats[] = { 1, 1 };
-  PGresult *res;
-
-  res =
-    PQexecPrepared (plugin->dbh, "delete_block", 2,
-                   paramValues, paramLengths, paramFormats, 1);
-  if (GNUNET_OK !=
-      GNUNET_POSTGRES_check_result (plugin->dbh,
-                                    res,
-                                    PGRES_COMMAND_OK,
-                                    "PQexecPrepared",
-                                    "delete_block"))
-    return;
-  PQclear (res);
-}
-
-
-/**
- * Cache a block in the datastore.
- *
- * @param cls closure (internal context for the plugin)
- * @param block block to cache
- * @return #GNUNET_OK on success, else #GNUNET_SYSERR
- */
-static int
-namestore_postgres_cache_block (void *cls,
-                                const struct GNUNET_GNSRECORD_Block *block)
-{
-  struct Plugin *plugin = cls;
-  struct GNUNET_HashCode query;
-  size_t block_size = ntohl (block->purpose.size) +
-    sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey) +
-    sizeof (struct GNUNET_CRYPTO_EcdsaSignature);
-  const char *paramValues[] = {
-    (const char *) &query,
-    (const char *) block,
-    (const char *) &block->expiration_time
-  };
-  int paramLengths[] = {
-    sizeof (query),
-    (int) block_size,
-    sizeof (block->expiration_time)
-  };
-  const int paramFormats[] = { 1, 1, 1 };
-  PGresult *res;
-
-  namestore_postgres_expire_blocks (plugin);
-  GNUNET_CRYPTO_hash (&block->derived_key,
-                     sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey),
-                     &query);
-  if (block_size > 64 * 65536)
-  {
-    GNUNET_break (0);
-    return GNUNET_SYSERR;
-  }
-  delete_old_block (plugin, &query, block->expiration_time);
-
-  res =
-    PQexecPrepared (plugin->dbh, "cache_block", 3,
-                   paramValues, paramLengths, paramFormats, 1);
-  if (GNUNET_OK !=
-      GNUNET_POSTGRES_check_result (plugin->dbh,
-                                    res,
-                                    PGRES_COMMAND_OK,
-                                    "PQexecPrepared",
-                                    "cache_block"))
-    return GNUNET_SYSERR;
-  PQclear (res);
-  return GNUNET_OK;
-}
-
-
-/**
- * Get the block for a particular zone and label in the
- * datastore.  Will return at most one result to the iterator.
- *
- * @param cls closure (internal context for the plugin)
- * @param query hash of public key derived from the zone and the label
- * @param iter function to call with the result
- * @param iter_cls closure for @a iter
- * @return #GNUNET_OK on success, #GNUNET_NO if there were no results, 
#GNUNET_SYSERR on error
- */
-static int
-namestore_postgres_lookup_block (void *cls,
-                                 const struct GNUNET_HashCode *query,
-                                 GNUNET_GNSRECORD_BlockCallback iter, void 
*iter_cls)
-{
-  struct Plugin *plugin = cls;
-  const char *paramValues[] = {
-    (const char *) query
-  };
-  int paramLengths[] = {
-    sizeof (*query)
-  };
-  const int paramFormats[] = { 1 };
-  PGresult *res;
-  unsigned int cnt;
-  size_t bsize;
-  const struct GNUNET_GNSRECORD_Block *block;
-
-  res = PQexecPrepared (plugin->dbh,
-                        "lookup_block", 1,
-                        paramValues, paramLengths, paramFormats,
-                        1);
-  if (GNUNET_OK !=
-      GNUNET_POSTGRES_check_result (plugin->dbh, res, PGRES_TUPLES_OK,
-                                    "PQexecPrepared",
-                                   "lookup_block"))
-  {
-    LOG (GNUNET_ERROR_TYPE_DEBUG,
-        "Failing lookup (postgres error)\n");
-    return GNUNET_SYSERR;
-  }
-  if (0 == (cnt = PQntuples (res)))
-  {
-    /* no result */
-    LOG (GNUNET_ERROR_TYPE_DEBUG,
-        "Ending iteration (no more results)\n");
-    PQclear (res);
-    return GNUNET_NO;
-  }
-  GNUNET_assert (1 == cnt);
-  GNUNET_assert (1 != PQnfields (res));
-  bsize = PQgetlength (res, 0, 0);
-  block = (const struct GNUNET_GNSRECORD_Block *) PQgetvalue (res, 0, 0);
-  if ( (bsize < sizeof (*block)) ||
-       (bsize != ntohl (block->purpose.size) +
-        sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey) +
-        sizeof (struct GNUNET_CRYPTO_EcdsaSignature)) )
-  {
-    GNUNET_break (0);
-    LOG (GNUNET_ERROR_TYPE_DEBUG,
-        "Failing lookup (corrupt block)\n");
-    PQclear (res);
-    return GNUNET_SYSERR;
-  }
-  iter (iter_cls, block);
-  PQclear (res);
-  return GNUNET_OK;
-}
-
-
-/**
  * Store a record in the datastore.  Removes any existing record in the
  * same zone with the same name.
  *
@@ -773,8 +512,6 @@
   }
   api = GNUNET_new (struct GNUNET_NAMESTORE_PluginFunctions);
   api->cls = &plugin;
-  api->cache_block = &namestore_postgres_cache_block;
-  api->lookup_block = &namestore_postgres_lookup_block;
   api->store_records = &namestore_postgres_store_records;
   api->iterate_records = &namestore_postgres_iterate_records;
   api->zone_to_name = &namestore_postgres_zone_to_name;

Modified: gnunet/src/namestore/plugin_namestore_sqlite.c
===================================================================
--- gnunet/src/namestore/plugin_namestore_sqlite.c      2013-10-16 21:03:53 UTC 
(rev 30236)
+++ gnunet/src/namestore/plugin_namestore_sqlite.c      2013-10-16 21:52:04 UTC 
(rev 30237)
@@ -73,26 +73,6 @@
   sqlite3 *dbh;
 
   /**
-   * Precompiled SQL for caching a block
-   */
-  sqlite3_stmt *cache_block;
-
-  /**
-   * Precompiled SQL for deleting an older block
-   */
-  sqlite3_stmt *delete_block;
-
-  /**
-   * Precompiled SQL for looking up a block
-   */
-  sqlite3_stmt *lookup_block;
-
-  /**
-   * Precompiled SQL for removing expired blocks
-   */
-  sqlite3_stmt *expire_blocks;
-
-  /**
    * Precompiled SQL to store records.
    */
   sqlite3_stmt *store_records;
@@ -153,12 +133,6 @@
 {
   /* create indices */
   if ( (SQLITE_OK !=
-       sqlite3_exec (dbh, "CREATE INDEX IF NOT EXISTS ir_query_hash ON 
ns096blocks (query,expiration_time)",
-                     NULL, NULL, NULL)) ||
-       (SQLITE_OK !=
-       sqlite3_exec (dbh, "CREATE INDEX IF NOT EXISTS ir_block_expiration ON 
ns096blocks (expiration_time)",
-                     NULL, NULL, NULL)) ||
-       (SQLITE_OK !=
        sqlite3_exec (dbh, "CREATE INDEX IF NOT EXISTS ir_pkey_reverse ON 
ns097records (zone_private_key,pkey)",
                      NULL, NULL, NULL)) ||
        (SQLITE_OK !=
@@ -255,29 +229,9 @@
   CHECK (SQLITE_OK == sqlite3_busy_timeout (plugin->dbh, BUSY_TIMEOUT_MS));
 
 
-  /* Create tables */
+  /* Create table */
   CHECK (SQLITE_OK ==
          sq_prepare (plugin->dbh,
-                     "SELECT 1 FROM sqlite_master WHERE tbl_name = 
'ns096blocks'",
-                     &stmt));
-  if ((sqlite3_step (stmt) == SQLITE_DONE) &&
-      (sqlite3_exec
-       (plugin->dbh,
-        "CREATE TABLE ns096blocks ("
-        " query BLOB NOT NULL DEFAULT '',"
-        " block BLOB NOT NULL DEFAULT '',"
-        " expiration_time INT8 NOT NULL DEFAULT 0"
-       ")",
-       NULL, NULL, NULL) != SQLITE_OK))
-  {
-    LOG_SQLITE (plugin, GNUNET_ERROR_TYPE_ERROR, "sqlite3_exec");
-    sqlite3_finalize (stmt);
-    return GNUNET_SYSERR;
-  }
-  sqlite3_finalize (stmt);
-
-  CHECK (SQLITE_OK ==
-         sq_prepare (plugin->dbh,
                      "SELECT 1 FROM sqlite_master WHERE tbl_name = 
'ns097records'",
                      &stmt));
   if ((sqlite3_step (stmt) == SQLITE_DONE) &&
@@ -303,22 +257,6 @@
 
   if ((sq_prepare
        (plugin->dbh,
-        "INSERT INTO ns096blocks (query,block,expiration_time) VALUES (?, ?, 
?)",
-        &plugin->cache_block) != SQLITE_OK) ||
-      (sq_prepare
-       (plugin->dbh,
-        "DELETE FROM ns096blocks WHERE expiration_time<?",
-        &plugin->expire_blocks) != SQLITE_OK) ||
-      (sq_prepare
-       (plugin->dbh,
-        "DELETE FROM ns096blocks WHERE query=? AND expiration_time<=?",
-        &plugin->delete_block) != SQLITE_OK) ||
-      (sq_prepare
-       (plugin->dbh,
-        "SELECT block FROM ns096blocks WHERE query=? ORDER BY expiration_time 
DESC LIMIT 1",
-        &plugin->lookup_block) != SQLITE_OK) ||
-      (sq_prepare
-       (plugin->dbh,
         "INSERT INTO ns097records (zone_private_key, pkey, rvalue, 
record_count, record_data, label)"
        " VALUES (?, ?, ?, ?, ?, ?)",
         &plugin->store_records) != SQLITE_OK) ||
@@ -361,14 +299,6 @@
   int result;
   sqlite3_stmt *stmt;
 
-  if (NULL != plugin->cache_block)
-    sqlite3_finalize (plugin->cache_block);
-  if (NULL != plugin->lookup_block)
-    sqlite3_finalize (plugin->lookup_block);
-  if (NULL != plugin->expire_blocks)
-    sqlite3_finalize (plugin->expire_blocks);
-  if (NULL != plugin->delete_block)
-    sqlite3_finalize (plugin->delete_block);
   if (NULL != plugin->store_records)
     sqlite3_finalize (plugin->store_records);
   if (NULL != plugin->delete_records)
@@ -405,246 +335,6 @@
 
 
 /**
- * Removes any expired block.
- *
- * @param plugin the plugin
- */
-static void
-namestore_sqlite_expire_blocks (struct Plugin *plugin)
-{
-  struct GNUNET_TIME_Absolute now;
-  int n;
-
-  now = GNUNET_TIME_absolute_get ();
-  if (SQLITE_OK != sqlite3_bind_int64 (plugin->expire_blocks,
-                                      1, now.abs_value_us))
-  {
-    LOG_SQLITE (plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
-                "sqlite3_bind_XXXX");
-    if (SQLITE_OK != sqlite3_reset (plugin->expire_blocks))
-      LOG_SQLITE (plugin,
-                  GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
-                  "sqlite3_reset");
-    return;
-  }
-  n = sqlite3_step (plugin->expire_blocks);
-  if (SQLITE_OK != sqlite3_reset (plugin->expire_blocks))
-    LOG_SQLITE (plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
-                "sqlite3_reset");
-  switch (n)
-  {
-  case SQLITE_DONE:
-    GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "sqlite", "Records expired\n");
-    return;
-  case SQLITE_BUSY:
-    LOG_SQLITE (plugin, GNUNET_ERROR_TYPE_WARNING | GNUNET_ERROR_TYPE_BULK,
-                "sqlite3_step");
-    return;
-  default:
-    LOG_SQLITE (plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
-                "sqlite3_step");
-    return;
-  }
-}
-
-
-/**
- * Cache a block in the datastore.
- *
- * @param cls closure (internal context for the plugin)
- * @param block block to cache
- * @return #GNUNET_OK on success, else #GNUNET_SYSERR
- */
-static int
-namestore_sqlite_cache_block (void *cls,
-                             const struct GNUNET_GNSRECORD_Block *block)
-{
-  struct Plugin *plugin = cls;
-  struct GNUNET_HashCode query;
-  struct GNUNET_TIME_Absolute expiration;
-  int64_t dval;
-  size_t block_size;
-  int n;
-
-  namestore_sqlite_expire_blocks (plugin);
-  GNUNET_CRYPTO_hash (&block->derived_key,
-                     sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey),
-                     &query);
-  expiration = GNUNET_TIME_absolute_ntoh (block->expiration_time);
-  dval = (int64_t) expiration.abs_value_us;
-  if (dval < 0)
-    dval = INT64_MAX;
-  block_size = ntohl (block->purpose.size) +
-    sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey) +
-    sizeof (struct GNUNET_CRYPTO_EcdsaSignature);
-  if (block_size > 64 * 65536)
-  {
-    GNUNET_break (0);
-    return GNUNET_SYSERR;
-  }
-
-  /* delete old version of the block */
-  if ( (SQLITE_OK !=
-        sqlite3_bind_blob (plugin->delete_block, 1,
-                           &query, sizeof (struct GNUNET_HashCode),
-                           SQLITE_STATIC)) ||
-       (SQLITE_OK !=
-        sqlite3_bind_int64 (plugin->delete_block,
-                            2, dval)) )
-  {
-    LOG_SQLITE (plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
-                "sqlite3_bind_XXXX");
-    if (SQLITE_OK != sqlite3_reset (plugin->delete_block))
-      LOG_SQLITE (plugin,
-                  GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
-                  "sqlite3_reset");
-    return GNUNET_SYSERR;
-  }
-  n = sqlite3_step (plugin->delete_block);
-  switch (n)
-  {
-  case SQLITE_DONE:
-    GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "sqlite", "Old block deleted\n");
-    break;
-  case SQLITE_BUSY:
-    LOG_SQLITE (plugin, GNUNET_ERROR_TYPE_WARNING | GNUNET_ERROR_TYPE_BULK,
-                "sqlite3_step");
-    break;
-  default:
-    LOG_SQLITE (plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
-                "sqlite3_step");
-    break;
-  }
-  if (SQLITE_OK != sqlite3_reset (plugin->delete_block))
-    LOG_SQLITE (plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
-               "sqlite3_reset");
-
-  /* insert new version of the block */
-  if ((SQLITE_OK !=
-       sqlite3_bind_blob (plugin->cache_block, 1,
-                         &query, sizeof (struct GNUNET_HashCode),
-                         SQLITE_STATIC)) ||
-      (SQLITE_OK !=
-       sqlite3_bind_blob (plugin->cache_block, 2,
-                         block, block_size,
-                         SQLITE_STATIC)) ||
-      (SQLITE_OK !=
-       sqlite3_bind_int64 (plugin->cache_block, 3,
-                          dval)))
-  {
-    LOG_SQLITE (plugin,
-               GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
-               "sqlite3_bind_XXXX");
-    if (SQLITE_OK != sqlite3_reset (plugin->cache_block))
-      LOG_SQLITE (plugin,
-                 GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
-                 "sqlite3_reset");
-    return GNUNET_SYSERR;
-
-  }
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-             "Caching block under derived key `%s'\n",
-             GNUNET_h2s_full (&query));
-  n = sqlite3_step (plugin->cache_block);
-  if (SQLITE_OK != sqlite3_reset (plugin->cache_block))
-    LOG_SQLITE (plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
-               "sqlite3_reset");
-  switch (n)
-  {
-  case SQLITE_DONE:
-    LOG (GNUNET_ERROR_TYPE_DEBUG,
-        "Record stored\n");
-    return GNUNET_OK;
-  case SQLITE_BUSY:
-    LOG_SQLITE (plugin, GNUNET_ERROR_TYPE_WARNING | GNUNET_ERROR_TYPE_BULK,
-               "sqlite3_step");
-    return GNUNET_NO;
-  default:
-    LOG_SQLITE (plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
-               "sqlite3_step");
-    return GNUNET_SYSERR;
-  }
-}
-
-
-/**
- * Get the block for a particular zone and label in the
- * datastore.  Will return at most one result to the iterator.
- *
- * @param cls closure (internal context for the plugin)
- * @param query hash of public key derived from the zone and the label
- * @param iter function to call with the result
- * @param iter_cls closure for @a iter
- * @return #GNUNET_OK on success, #GNUNET_NO if there were no results, 
#GNUNET_SYSERR on error
- */
-static int
-namestore_sqlite_lookup_block (void *cls,
-                              const struct GNUNET_HashCode *query,
-                              GNUNET_GNSRECORD_BlockCallback iter, void 
*iter_cls)
-{
-  struct Plugin *plugin = cls;
-  int ret;
-  int sret;
-  size_t block_size;
-  const struct GNUNET_GNSRECORD_Block *block;
-
-  if (SQLITE_OK != sqlite3_bind_blob (plugin->lookup_block, 1,
-                                     query, sizeof (struct GNUNET_HashCode),
-                                     SQLITE_STATIC))
-  {
-    LOG_SQLITE (plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
-               "sqlite3_bind_XXXX");
-    if (SQLITE_OK != sqlite3_reset (plugin->lookup_block))
-      LOG_SQLITE (plugin,
-                 GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
-                 "sqlite3_reset");
-    return GNUNET_SYSERR;
-  }
-  ret = GNUNET_NO;
-  if (SQLITE_ROW == (sret = sqlite3_step (plugin->lookup_block)))
-  {
-    block = sqlite3_column_blob (plugin->lookup_block, 0);
-    block_size = sqlite3_column_bytes (plugin->lookup_block, 0);
-    if ( (block_size < sizeof (struct GNUNET_GNSRECORD_Block)) ||
-        (ntohl (block->purpose.size) +
-         sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey) +
-         sizeof (struct GNUNET_CRYPTO_EcdsaSignature) != block_size) )
-    {
-      GNUNET_break (0);
-      ret = GNUNET_SYSERR;
-    }
-    else
-    {
-      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                 "Found block under derived key `%s'\n",
-                 GNUNET_h2s_full (query));
-      iter (iter_cls, block);
-      ret = GNUNET_YES;
-    }
-  }
-  else
-  {
-    if (SQLITE_DONE != sret)
-    {
-      LOG_SQLITE (plugin, GNUNET_ERROR_TYPE_ERROR, "sqlite_step");
-      ret = GNUNET_SYSERR;
-    }
-    else
-    {
-      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                 "No block found under derived key `%s'\n",
-                 GNUNET_h2s_full (query));
-    }
-  }
-  if (SQLITE_OK != sqlite3_reset (plugin->lookup_block))
-    LOG_SQLITE (plugin,
-               GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
-               "sqlite3_reset");
-  return ret;
-}
-
-
-/**
  * Store a record in the datastore.  Removes any existing record in the
  * same zone with the same name.
  *
@@ -965,8 +655,6 @@
   }
   api = GNUNET_new (struct GNUNET_NAMESTORE_PluginFunctions);
   api->cls = &plugin;
-  api->cache_block = &namestore_sqlite_cache_block;
-  api->lookup_block = &namestore_sqlite_lookup_block;
   api->store_records = &namestore_sqlite_store_records;
   api->iterate_records = &namestore_sqlite_iterate_records;
   api->zone_to_name = &namestore_sqlite_zone_to_name;

Modified: gnunet/src/namestore/test_namestore_api.conf
===================================================================
--- gnunet/src/namestore/test_namestore_api.conf        2013-10-16 21:03:53 UTC 
(rev 30236)
+++ gnunet/src/namestore/test_namestore_api.conf        2013-10-16 21:52:04 UTC 
(rev 30237)
@@ -3,7 +3,7 @@
 
 [arm]
 PORT = 12000
-DEFAULTSERVICES = namestore
+DEFAULTSERVICES = namecache namestore
 
 [namestore]
 #PREFIX = valgrind

Deleted: gnunet/src/namestore/test_namestore_api_cache_block.c
===================================================================
--- gnunet/src/namestore/test_namestore_api_cache_block.c       2013-10-16 
21:03:53 UTC (rev 30236)
+++ gnunet/src/namestore/test_namestore_api_cache_block.c       2013-10-16 
21:52:04 UTC (rev 30237)
@@ -1,239 +0,0 @@
-/*
-     This file is part of GNUnet.
-     (C) 2012 Christian Grothoff (and other contributing authors)
-
-     GNUnet is free software; you can redistribute it and/or modify
-     it under the terms of the GNU General Public License as published
-     by the Free Software Foundation; either version 3, or (at your
-     option) any later version.
-
-     GNUnet is distributed in the hope that it will be useful, but
-     WITHOUT ANY WARRANTY; without even the implied warranty of
-     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-     General Public License for more details.
-
-     You should have received a copy of the GNU General Public License
-     along with GNUnet; see the file COPYING.  If not, write to the
-     Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-     Boston, MA 02111-1307, USA.
-*/
-/**
- * @file namestore/test_namestore_api.c
- * @brief testcase for namestore_api.c: store a record and perform a lookup
- */
-#include "platform.h"
-#include "gnunet_namestore_service.h"
-#include "gnunet_testing_lib.h"
-
-#define TEST_RECORD_TYPE 1234
-
-#define TEST_RECORD_DATALEN 123
-
-#define TEST_RECORD_DATA 'a'
-
-#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 100)
-
-
-static struct GNUNET_NAMESTORE_Handle *nsh;
-
-static GNUNET_SCHEDULER_TaskIdentifier endbadly_task;
-
-static struct GNUNET_CRYPTO_EcdsaPrivateKey *privkey;
-
-static struct GNUNET_CRYPTO_EcdsaPublicKey pubkey;
-
-static int res;
-
-static struct GNUNET_NAMESTORE_QueueEntry *nsqe;
-
-
-static void
-cleanup ()
-{
-  if (NULL != nsh)
-  {
-    GNUNET_NAMESTORE_disconnect (nsh);
-    nsh = NULL;
-  }
-  if (NULL != privkey)
-  {
-    GNUNET_free (privkey);
-    privkey = NULL;
-  }
-  GNUNET_SCHEDULER_shutdown ();
-}
-
-
-/**
- * Re-establish the connection to the service.
- *
- * @param cls handle to use to re-connect.
- * @param tc scheduler context
- */
-static void
-endbadly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
-{
-  if (NULL != nsqe)
-  {
-    GNUNET_NAMESTORE_cancel (nsqe);
-    nsqe = NULL;
-  }
-  cleanup ();
-  res = 1;
-}
-
-
-static void
-end (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
-{
-  cleanup ();
-  res = 0;
-}
-
-
-static void
-rd_decrypt_cb (void *cls,
-               unsigned int rd_count,
-               const struct GNUNET_GNSRECORD_Data *rd)
-{
-  char rd_cmp_data[TEST_RECORD_DATALEN];
-
-  GNUNET_assert (1 == rd_count);
-  GNUNET_assert (NULL != rd);
-
-  memset (rd_cmp_data, 'a', TEST_RECORD_DATALEN);
-
-  GNUNET_assert (TEST_RECORD_TYPE == rd[0].record_type);
-  GNUNET_assert (TEST_RECORD_DATALEN == rd[0].data_size);
-  GNUNET_assert (0 == memcmp (&rd_cmp_data, rd[0].data, TEST_RECORD_DATALEN));
-
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-             "Block was decrypted successfully \n");
-
-       GNUNET_SCHEDULER_add_now (&end, NULL);
-}
-
-static void
-name_lookup_proc (void *cls,
-                  const struct GNUNET_GNSRECORD_Block *block)
-{
-  const char *name = cls;
-  nsqe = NULL;
-
-  GNUNET_assert (NULL != cls);
-
-  if (endbadly_task != GNUNET_SCHEDULER_NO_TASK)
-  {
-    GNUNET_SCHEDULER_cancel (endbadly_task);
-    endbadly_task = GNUNET_SCHEDULER_NO_TASK;
-  }
-
-  if (NULL == block)
-  {
-    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-             _("Namestore returned no block\n"));
-    if (endbadly_task != GNUNET_SCHEDULER_NO_TASK)
-      GNUNET_SCHEDULER_cancel (endbadly_task);
-    endbadly_task =  GNUNET_SCHEDULER_add_now (&endbadly, NULL);
-    return;
-  }
-
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-             "Namestore returned block, decrypting \n");
-  GNUNET_assert (GNUNET_OK == GNUNET_GNSRECORD_block_decrypt(block,
-               &pubkey, name, &rd_decrypt_cb, (void *) name));
-}
-
-static void
-cache_cont (void *cls, int32_t success, const char *emsg)
-{
-  const char *name = cls;
-  struct GNUNET_HashCode derived_hash;
-
-  GNUNET_assert (NULL != cls);
-
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-             "Name store cached record for `%s': %s\n",
-             name,
-             (success == GNUNET_OK) ? "SUCCESS" : "FAIL");
-
-  /* Create derived hash */
-  GNUNET_GNSRECORD_query_from_public_key (&pubkey, name, &derived_hash);
-
-  nsqe = GNUNET_NAMESTORE_lookup_block (nsh, &derived_hash,
-                                        &name_lookup_proc, (void *) name);
-}
-
-
-static void
-run (void *cls,
-     const struct GNUNET_CONFIGURATION_Handle *cfg,
-     struct GNUNET_TESTING_Peer *peer)
-{
-  struct GNUNET_GNSRECORD_Data rd;
-  struct GNUNET_GNSRECORD_Block *block;
-  char *hostkey_file;
-  const char * name = "dummy.dummy.gnunet";
-
-  endbadly_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT,
-                                               &endbadly, NULL);
-  GNUNET_asprintf (&hostkey_file,
-                  "zonefiles%s%s",
-                  DIR_SEPARATOR_STR,
-                  "N0UJMP015AFUNR2BTNM3FKPBLG38913BL8IDMCO2H0A1LIB81960.zkey");
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Using zonekey file `%s' \n", 
hostkey_file);
-  privkey = GNUNET_CRYPTO_ecdsa_key_create_from_file (hostkey_file);
-  GNUNET_free (hostkey_file);
-  GNUNET_assert (privkey != NULL);
-  GNUNET_CRYPTO_ecdsa_key_get_public (privkey, &pubkey);
-
-
-  rd.expiration_time = GNUNET_TIME_absolute_get().abs_value_us;
-  rd.record_type = TEST_RECORD_TYPE;
-  rd.data_size = TEST_RECORD_DATALEN;
-  rd.data = GNUNET_malloc (TEST_RECORD_DATALEN);
-  memset ((char *) rd.data, 'a', TEST_RECORD_DATALEN);
-  block = GNUNET_GNSRECORD_block_create (privkey,
-      GNUNET_TIME_UNIT_FOREVER_ABS, name, &rd, 1 );
-  if (NULL == block)
-  {
-    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-              _("Namestore cannot cache no block\n"));
-  }
-
-  nsh = GNUNET_NAMESTORE_connect (cfg);
-  if (NULL == nsh)
-  {
-    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-              _("Namestore cannot connect to namestore\n"));
-  }
-  GNUNET_break (NULL != nsh);
-
-  nsqe = GNUNET_NAMESTORE_block_cache (nsh, block , &cache_cont, (void *) 
name);
-  if (NULL == nsqe)
-  {
-    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-             _("Namestore cannot cache no block\n"));
-  }
-
-  GNUNET_free ((void *)rd.data);
-}
-
-
-int
-main (int argc, char *argv[])
-{
-  GNUNET_DISK_directory_remove ("/tmp/test-gnunet-namestore/");
-  res = 1;
-  if (0 !=
-      GNUNET_TESTING_service_run ("test-namestore-api",
-                                 "namestore",
-                                 "test_namestore_api.conf",
-                                 &run,
-                                 NULL))
-    return 1;
-  return res;
-}
-
-
-/* end of test_namestore_api_cache_block.c */

Modified: gnunet/src/namestore/test_namestore_api_lookup_public.c
===================================================================
--- gnunet/src/namestore/test_namestore_api_lookup_public.c     2013-10-16 
21:03:53 UTC (rev 30236)
+++ gnunet/src/namestore/test_namestore_api_lookup_public.c     2013-10-16 
21:52:04 UTC (rev 30237)
@@ -22,6 +22,7 @@
  * @brief testcase for namestore_api.c: store a record and perform a lookup
  */
 #include "platform.h"
+#include "gnunet_namecache_service.h"
 #include "gnunet_namestore_service.h"
 #include "gnunet_testing_lib.h"
 
@@ -36,6 +37,8 @@
 
 static struct GNUNET_NAMESTORE_Handle *nsh;
 
+static struct GNUNET_NAMECACHE_Handle *nch;
+
 static GNUNET_SCHEDULER_TaskIdentifier endbadly_task;
 
 static struct GNUNET_CRYPTO_EcdsaPrivateKey *privkey;
@@ -46,7 +49,9 @@
 
 static struct GNUNET_NAMESTORE_QueueEntry *nsqe;
 
+static struct GNUNET_NAMECACHE_QueueEntry *ncqe;
 
+
 static void
 cleanup ()
 {
@@ -55,6 +60,11 @@
     GNUNET_NAMESTORE_disconnect (nsh);
     nsh = NULL;
   }
+  if (NULL != nch)
+  {
+    GNUNET_NAMECACHE_disconnect (nch);
+    nch = NULL;
+  }
   if (NULL != privkey)
   {
     GNUNET_free (privkey);
@@ -78,6 +88,11 @@
     GNUNET_NAMESTORE_cancel (nsqe);
     nsqe = NULL;
   }
+  if (NULL != ncqe)
+  {
+    GNUNET_NAMECACHE_cancel (ncqe);
+    ncqe = NULL;
+  }
   cleanup ();
   res = 1;
 }
@@ -113,13 +128,14 @@
        GNUNET_SCHEDULER_add_now (&end, NULL);
 }
 
+
 static void
 name_lookup_proc (void *cls,
                   const struct GNUNET_GNSRECORD_Block *block)
 {
   const char *name = cls;
-  nsqe = NULL;
 
+  ncqe = NULL;
   GNUNET_assert (NULL != cls);
 
   if (endbadly_task != GNUNET_SCHEDULER_NO_TASK)
@@ -144,6 +160,7 @@
                &pubkey, name, &rd_decrypt_cb, (void *) name));
 }
 
+
 static void
 put_cont (void *cls, int32_t success, const char *emsg)
 {
@@ -151,8 +168,8 @@
   struct GNUNET_HashCode derived_hash;
   struct GNUNET_CRYPTO_EcdsaPublicKey pubkey;
 
+  nsqe = NULL;
   GNUNET_assert (NULL != cls);
-
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
              "Name store added record for `%s': %s\n",
              name,
@@ -162,8 +179,8 @@
   GNUNET_CRYPTO_ecdsa_key_get_public (privkey, &pubkey);
   GNUNET_GNSRECORD_query_from_public_key (&pubkey, name, &derived_hash);
 
-  nsqe = GNUNET_NAMESTORE_lookup_block (nsh, &derived_hash,
-                                        &name_lookup_proc, (void *) name);
+  ncqe = GNUNET_NAMECACHE_lookup_block (nch, &derived_hash,
+                                        &name_lookup_proc, (void *) name);
 }
 
 
@@ -196,7 +213,9 @@
   memset ((char *) rd.data, 'a', TEST_RECORD_DATALEN);
 
   nsh = GNUNET_NAMESTORE_connect (cfg);
+  nch = GNUNET_NAMECACHE_connect (cfg);
   GNUNET_break (NULL != nsh);
+  GNUNET_break (NULL != nch);
   nsqe = GNUNET_NAMESTORE_records_store (nsh, privkey, name,
                                      1, &rd, &put_cont, (void *) name);
   if (NULL == nsqe)

Modified: gnunet/src/namestore/test_namestore_api_remove.c
===================================================================
--- gnunet/src/namestore/test_namestore_api_remove.c    2013-10-16 21:03:53 UTC 
(rev 30236)
+++ gnunet/src/namestore/test_namestore_api_remove.c    2013-10-16 21:52:04 UTC 
(rev 30237)
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet.
-     (C) 2009 Christian Grothoff (and other contributing authors)
+     (C) 2013 Christian Grothoff (and other contributing authors)
 
      GNUnet is free software; you can redistribute it and/or modify
      it under the terms of the GNU General Public License as published
@@ -42,8 +42,6 @@
 
 static struct GNUNET_CRYPTO_EcdsaPublicKey pubkey;
 
-static struct GNUNET_HashCode derived_hash;
-
 static int res;
 
 static int removed;
@@ -119,72 +117,6 @@
 
 
 static void
-rd_decrypt_cb (void *cls,
-              unsigned int rd_count,
-              const struct GNUNET_GNSRECORD_Data *rd)
-{
-  const char *name = cls;
-  char rd_cmp_data[TEST_RECORD_DATALEN];
-
-  GNUNET_assert (GNUNET_NO == removed);
-  GNUNET_assert (1 == rd_count);
-  GNUNET_assert (NULL != rd);
-  memset (rd_cmp_data, 'a', TEST_RECORD_DATALEN);
-
-  GNUNET_assert (TEST_RECORD_TYPE == rd[0].record_type);
-  GNUNET_assert (TEST_RECORD_DATALEN == rd[0].data_size);
-  GNUNET_assert (0 == memcmp (&rd_cmp_data, rd[0].data, TEST_RECORD_DATALEN));
-
-  GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-             "Block was decrypted successfully, removing records \n");
-
-  nsqe = GNUNET_NAMESTORE_records_store (nsh, privkey, name,
-                                        0, NULL, &remove_cont, (void *) name);
-}
-
-
-static void
-name_lookup_proc (void *cls,
-                 const struct GNUNET_GNSRECORD_Block *block)
-{
-  const char *name = cls;
-  nsqe = NULL;
-
-  if (removed && (NULL == block))
-  {
-    if (endbadly_task != GNUNET_SCHEDULER_NO_TASK)
-    {
-      GNUNET_SCHEDULER_cancel (endbadly_task);
-      endbadly_task = GNUNET_SCHEDULER_NO_TASK;
-    }
-    GNUNET_SCHEDULER_add_now (&end, NULL);
-    return;
-  }
-  GNUNET_assert (NULL != cls);
-  if (endbadly_task != GNUNET_SCHEDULER_NO_TASK)
-  {
-    GNUNET_SCHEDULER_cancel (endbadly_task);
-    endbadly_task = GNUNET_SCHEDULER_NO_TASK;
-  }
-
-  if (NULL == block)
-  {
-    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-             _("Namestore returned no block\n"));
-    if (endbadly_task != GNUNET_SCHEDULER_NO_TASK)
-      GNUNET_SCHEDULER_cancel (endbadly_task);
-    endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly, NULL);
-    return;
-  }
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-             "Namestore returned block, decrypting \n");
-  GNUNET_assert (GNUNET_OK ==
-                GNUNET_GNSRECORD_block_decrypt (block,
-                                                &pubkey, name, &rd_decrypt_cb, 
(void *) name));
-}
-
-
-static void
 put_cont (void *cls, int32_t success,
          const char *emsg)
 {
@@ -207,24 +139,8 @@
              "Name store added record for `%s': %s\n",
              name,
              (success == GNUNET_OK) ? "SUCCESS" : "FAIL");
-
-  /* Create derived hash */
-  GNUNET_GNSRECORD_query_from_private_key (privkey,
-                                          name,
-                                          &derived_hash);
-
-  nsqe = GNUNET_NAMESTORE_lookup_block (nsh, &derived_hash,
-                                       &name_lookup_proc, (void *) name);
-  if (NULL == nsqe)
-  {
-    GNUNET_break (0);
-    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-             _("Namestore cannot perform lookup\n"));
-    if (endbadly_task != GNUNET_SCHEDULER_NO_TASK)
-      GNUNET_SCHEDULER_cancel (endbadly_task);
-    endbadly_task =  GNUNET_SCHEDULER_add_now (&endbadly, NULL);
-    return;
-  }
+  nsqe = GNUNET_NAMESTORE_records_store (nsh, privkey, name,
+                                        0, NULL, &remove_cont, (void *) name);
 }
 
 

Modified: gnunet/src/namestore/test_namestore_api_store.c
===================================================================
--- gnunet/src/namestore/test_namestore_api_store.c     2013-10-16 21:03:53 UTC 
(rev 30236)
+++ gnunet/src/namestore/test_namestore_api_store.c     2013-10-16 21:52:04 UTC 
(rev 30237)
@@ -18,8 +18,8 @@
      Boston, MA 02111-1307, USA.
 */
 /**
- * @file namestore/test_namestore_api.c
- * @brief testcase for namestore_api.c: store a record and perform a lookup
+ * @file namestore/test_namestore_api_store.c
+ * @brief testcase for namestore_api.c: store a record
  */
 #include "platform.h"
 #include "gnunet_namestore_service.h"
@@ -92,76 +92,17 @@
 
 
 static void
-rd_decrypt_cb (void *cls,
-               unsigned int rd_count,
-               const struct GNUNET_GNSRECORD_Data *rd)
-{
-  char rd_cmp_data[TEST_RECORD_DATALEN];
-
-  GNUNET_assert (1 == rd_count);
-  GNUNET_assert (NULL != rd);
-
-  memset (rd_cmp_data, 'a', TEST_RECORD_DATALEN);
-
-  GNUNET_assert (TEST_RECORD_TYPE == rd[0].record_type);
-  GNUNET_assert (TEST_RECORD_DATALEN == rd[0].data_size);
-  GNUNET_assert (0 == memcmp (&rd_cmp_data, rd[0].data, TEST_RECORD_DATALEN));
-
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-             "Block was decrypted successfully \n");
-
-       GNUNET_SCHEDULER_add_now (&end, NULL);
-}
-
-static void
-name_lookup_proc (void *cls,
-                  const struct GNUNET_GNSRECORD_Block *block)
-{
-  const char *name = cls;
-  nsqe = NULL;
-
-  GNUNET_assert (NULL != cls);
-
-  if (endbadly_task != GNUNET_SCHEDULER_NO_TASK)
-  {
-    GNUNET_SCHEDULER_cancel (endbadly_task);
-    endbadly_task = GNUNET_SCHEDULER_NO_TASK;
-  }
-
-  if (NULL == block)
-  {
-    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-             _("Namestore returned no block\n"));
-    if (endbadly_task != GNUNET_SCHEDULER_NO_TASK)
-      GNUNET_SCHEDULER_cancel (endbadly_task);
-    endbadly_task =  GNUNET_SCHEDULER_add_now (&endbadly, NULL);
-    return;
-  }
-
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-             "Namestore returned block, decrypting \n");
-  GNUNET_assert (GNUNET_OK == GNUNET_GNSRECORD_block_decrypt(block,
-               &pubkey, name, &rd_decrypt_cb, (void *) name));
-}
-
-static void
 put_cont (void *cls, int32_t success, const char *emsg)
 {
   const char *name = cls;
-  struct GNUNET_HashCode derived_hash;
 
+  nsqe = NULL;
   GNUNET_assert (NULL != cls);
-
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
              "Name store added record for `%s': %s\n",
              name,
              (success == GNUNET_OK) ? "SUCCESS" : "FAIL");
-
-  /* Create derived hash */
-  GNUNET_GNSRECORD_query_from_private_key (privkey, name, &derived_hash);
-
-  nsqe = GNUNET_NAMESTORE_lookup_block (nsh, &derived_hash,
-                                        &name_lookup_proc, (void *) name);
+  GNUNET_SCHEDULER_add_now (&end, NULL);
 }
 
 
@@ -222,4 +163,4 @@
 }
 
 
-/* end of test_namestore_api.c */
+/* end of test_namestore_api_store.c */

Modified: gnunet/src/namestore/test_namestore_api_store_update.c
===================================================================
--- gnunet/src/namestore/test_namestore_api_store_update.c      2013-10-16 
21:03:53 UTC (rev 30236)
+++ gnunet/src/namestore/test_namestore_api_store_update.c      2013-10-16 
21:52:04 UTC (rev 30237)
@@ -23,6 +23,7 @@
  * @author Matthias Wachs
  */
 #include "platform.h"
+#include "gnunet_namecache_service.h"
 #include "gnunet_namestore_service.h"
 #include "gnunet_testing_lib.h"
 
@@ -44,6 +45,8 @@
 
 static struct GNUNET_NAMESTORE_Handle *nsh;
 
+static struct GNUNET_NAMECACHE_Handle *nch;
+
 static GNUNET_SCHEDULER_TaskIdentifier endbadly_task;
 
 static struct GNUNET_CRYPTO_EcdsaPrivateKey *privkey;
@@ -56,6 +59,8 @@
 
 static struct GNUNET_NAMESTORE_QueueEntry *nsqe;
 
+static struct GNUNET_NAMECACHE_QueueEntry *ncqe;
+
 static const char * name = "dummy.dummy.gnunet";
 
 
@@ -67,6 +72,11 @@
     GNUNET_NAMESTORE_disconnect (nsh);
     nsh = NULL;
   }
+  if (NULL != nch)
+  {
+    GNUNET_NAMECACHE_disconnect (nch);
+    nch = NULL;
+  }
   if (NULL != privkey)
   {
     GNUNET_free (privkey);
@@ -91,6 +101,11 @@
     GNUNET_NAMESTORE_cancel (nsqe);
     nsqe = NULL;
   }
+  if (NULL != ncqe)
+  {
+    GNUNET_NAMECACHE_cancel (ncqe);
+    ncqe = NULL;
+  }
   cleanup ();
   res = 1;
 }
@@ -161,10 +176,9 @@
                   const struct GNUNET_GNSRECORD_Block *block)
 {
   const char *name = cls;
-  nsqe = NULL;
 
+  ncqe = NULL;
   GNUNET_assert (NULL != cls);
-
   if (endbadly_task != GNUNET_SCHEDULER_NO_TASK)
   {
     GNUNET_SCHEDULER_cancel (endbadly_task);
@@ -194,18 +208,16 @@
   const char *name = cls;
   struct GNUNET_HashCode derived_hash;
 
+  nsqe = NULL;
   GNUNET_assert (NULL != cls);
-
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
              "Name store added record for `%s': %s\n",
              name,
              (success == GNUNET_OK) ? "SUCCESS" : "FAIL");
-
   /* Create derived hash */
   GNUNET_GNSRECORD_query_from_private_key (privkey, name, &derived_hash);
-
-  nsqe = GNUNET_NAMESTORE_lookup_block (nsh, &derived_hash,
-                                        &name_lookup_proc, (void *) name);
+  ncqe = GNUNET_NAMECACHE_lookup_block (nch, &derived_hash,
+                                        &name_lookup_proc, (void *) name);
 }
 
 
@@ -239,6 +251,8 @@
 
   nsh = GNUNET_NAMESTORE_connect (cfg);
   GNUNET_break (NULL != nsh);
+  nch = GNUNET_NAMECACHE_connect (cfg);
+  GNUNET_break (NULL != nch);
   nsqe = GNUNET_NAMESTORE_records_store (nsh, privkey, name,
                                      1, &rd, &put_cont, (void *) name);
   if (NULL == nsqe)

Modified: gnunet/src/namestore/test_namestore_api_zone_iteration.c
===================================================================
--- gnunet/src/namestore/test_namestore_api_zone_iteration.c    2013-10-16 
21:03:53 UTC (rev 30236)
+++ gnunet/src/namestore/test_namestore_api_zone_iteration.c    2013-10-16 
21:52:04 UTC (rev 30237)
@@ -66,16 +66,16 @@
 static void
 endbadly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
-       if (NULL != zi)
-       {
-               GNUNET_NAMESTORE_zone_iteration_stop (zi);
-               zi = NULL;
-       }
-
+  if (NULL != zi)
+  {
+    GNUNET_NAMESTORE_zone_iteration_stop (zi);
+    zi = NULL;
+  }
   if (nsh != NULL)
+  {
     GNUNET_NAMESTORE_disconnect (nsh);
-  nsh = NULL;
-
+    nsh = NULL;
+  }
   GNUNET_free_non_null(s_name_1);
   GNUNET_free_non_null(s_name_2);
   GNUNET_free_non_null(s_name_3);
@@ -110,12 +110,11 @@
 static void
 end (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
-       if (NULL != zi)
-       {
-               GNUNET_NAMESTORE_zone_iteration_stop (zi);
-               zi = NULL;
-       }
-
+  if (NULL != zi)
+  {
+    GNUNET_NAMESTORE_zone_iteration_stop (zi);
+    zi = NULL;
+  }
   if (endbadly_task != GNUNET_SCHEDULER_NO_TASK)
   {
     GNUNET_SCHEDULER_cancel (endbadly_task);
@@ -156,12 +155,13 @@
 
 static void
 zone_proc (void *cls,
-                                        const struct 
GNUNET_CRYPTO_EcdsaPrivateKey *zone,
-                                        const char *label,
-                                        unsigned int rd_count,
-                                        const struct GNUNET_GNSRECORD_Data *rd)
+           const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone,
+           const char *label,
+           unsigned int rd_count,
+           const struct GNUNET_GNSRECORD_Data *rd)
 {
   int failed = GNUNET_NO;
+
   if ((zone == NULL) && (label == NULL))
   {
     GNUNET_break (3 == returned_records);
@@ -175,91 +175,89 @@
 
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                "Received last result, iteration done after receing %u 
results\n",
-               returned_records );
+               returned_records);
     GNUNET_SCHEDULER_add_now (&end, NULL);
     return;
   }
-  else
+  if (0 == memcmp (zone, privkey, sizeof (struct 
GNUNET_CRYPTO_EcdsaPrivateKey)))
   {
-       if (0 == memcmp (zone, privkey, sizeof (struct 
GNUNET_CRYPTO_EcdsaPrivateKey)))
-       {
-      if (0 == strcmp (label, s_name_1))
+    if (0 == strcmp (label, s_name_1))
+    {
+      if (rd_count == 1)
       {
-        if (rd_count == 1)
+        if (GNUNET_YES != GNUNET_GNSRECORD_records_cmp(rd, s_rd_1))
         {
-          if (GNUNET_YES != GNUNET_GNSRECORD_records_cmp(rd, s_rd_1))
-          {
-            failed = GNUNET_YES;
-            GNUNET_break (0);
-          }
-        }
-        else
-        {
           failed = GNUNET_YES;
           GNUNET_break (0);
         }
       }
-      else if (0 == strcmp (label, s_name_2))
+      else
       {
-        if (rd_count == 1)
+        failed = GNUNET_YES;
+        GNUNET_break (0);
+      }
+    }
+    else if (0 == strcmp (label, s_name_2))
+    {
+      if (rd_count == 1)
+      {
+        if (GNUNET_YES != GNUNET_GNSRECORD_records_cmp(rd, s_rd_2))
         {
-          if (GNUNET_YES != GNUNET_GNSRECORD_records_cmp(rd, s_rd_2))
-          {
-            failed = GNUNET_YES;
-            GNUNET_break (0);
-          }
-        }
-        else
-        {
-          GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                       "Received invalid record count\n");
           failed = GNUNET_YES;
           GNUNET_break (0);
         }
       }
       else
       {
-        GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                       "Comparing result failed: got name `%s' for first 
zone\n", label);
+        GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                    "Received invalid record count\n");
         failed = GNUNET_YES;
         GNUNET_break (0);
       }
-       }
-       else if (0 == memcmp (zone, privkey2, sizeof (struct 
GNUNET_CRYPTO_EcdsaPrivateKey)))
-       {
-      if (0 == strcmp (label, s_name_3))
+    }
+    else
+    {
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                  "Comparing result failed: got name `%s' for first zone\n", 
label);
+      failed = GNUNET_YES;
+      GNUNET_break (0);
+    }
+  }
+  else if (0 == memcmp (zone, privkey2, sizeof (struct 
GNUNET_CRYPTO_EcdsaPrivateKey)))
+  {
+    if (0 == strcmp (label, s_name_3))
+    {
+      if (rd_count == 1)
       {
-        if (rd_count == 1)
+        if (GNUNET_YES != GNUNET_GNSRECORD_records_cmp(rd, s_rd_3))
         {
-          if (GNUNET_YES != GNUNET_GNSRECORD_records_cmp(rd, s_rd_3))
-          {
-            failed = GNUNET_YES;
-            GNUNET_break (0);
-          }
-        }
-        else
-        {
-          GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                       "Received invalid record count\n");
           failed = GNUNET_YES;
           GNUNET_break (0);
         }
       }
       else
       {
-        GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                       "Comparing result failed: got name `%s' for first 
zone\n", label);
+        GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                    "Received invalid record count\n");
         failed = GNUNET_YES;
         GNUNET_break (0);
       }
-       }
-       else
-       {
-      GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Received invalid zone\n");
+    }
+    else
+    {
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                  "Comparing result failed: got name `%s' for first zone\n", 
label);
       failed = GNUNET_YES;
       GNUNET_break (0);
-       }
+    }
   }
+  else
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                "Received invalid zone\n");
+    failed = GNUNET_YES;
+    GNUNET_break (0);
+  }
 
   if (failed == GNUNET_NO)
   {
@@ -302,10 +300,10 @@
     res = 1;
     returned_records = 0;
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "All records created, starting 
iteration over all zones \n");
-    zi = GNUNET_NAMESTORE_zone_iteration_start(nsh,
-                                              NULL,
-                                              &zone_proc,
-                                              NULL);
+    zi = GNUNET_NAMESTORE_zone_iteration_start (nsh,
+                                                NULL,
+                                                &zone_proc,
+                                                NULL);
     if (zi == NULL)
     {
       GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to create zone iterator\n");
@@ -394,22 +392,26 @@
 
   GNUNET_asprintf(&s_name_1, "dummy1");
   s_rd_1 = create_record(1);
-  GNUNET_NAMESTORE_records_store(nsh, privkey, s_name_1,
-               1, s_rd_1, &put_cont, NULL);
+  GNUNET_NAMESTORE_records_store (nsh, privkey, s_name_1,
+                                  1, s_rd_1,
+                                  &put_cont, NULL);
 
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created record 2 \n");
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "Created record 2 \n");
   GNUNET_asprintf(&s_name_2, "dummy2");
   s_rd_2 = create_record(1);
-  GNUNET_NAMESTORE_records_store(nsh, privkey, s_name_2,
-               1, s_rd_2, &put_cont, NULL);
+  GNUNET_NAMESTORE_records_store (nsh, privkey, s_name_2,
+                                  1, s_rd_2, &put_cont, NULL);
 
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created record 3\n");
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "Created record 3\n");
 
   /* name in different zone */
   GNUNET_asprintf(&s_name_3, "dummy3");
   s_rd_3 = create_record(1);
-  GNUNET_NAMESTORE_records_store(nsh, privkey2, s_name_3,
-               1, s_rd_3, &put_cont, NULL);
+  GNUNET_NAMESTORE_records_store (nsh, privkey2, s_name_3,
+                                  1, s_rd_3,
+                                  &put_cont, NULL);
 }
 
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]