+ GNUNET_assert (NULL != h->client);
+ h->mq =
+ GNUNET_MQ_queue_for_connection_client (h->client, mq_handlers,
+ &handle_client_error, h);
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Resending pending requests after reconnect.\n");
+ if (NULL != h->watches)
+ GNUNET_CONTAINER_multihashmap_iterate (h->watches, &rewatch_it, h);
+ for (ic = h->iterate_head; NULL != ic; ic = ic->next)
+ {
+ ev =
+ PEERSTORE_create_record_mq_envelope (ic->sub_system, &ic->peer, ic->key,
+ NULL, 0, NULL, 0,
+ GNUNET_MESSAGE_TYPE_PEERSTORE_ITERATE);
+ GNUNET_MQ_send (h->mq, ev);
+ ic->timeout_task =
+ GNUNET_SCHEDULER_add_delayed (ic->timeout, &iterate_timeout, ic);
+ }
+ for (sc = h->store_head; NULL != sc; sc = sc->next)
+ {
+ ev =
+ PEERSTORE_create_record_mq_envelope (sc->sub_system, &sc->peer, sc->key,
+ sc->value, sc->size, &sc->expiry,
+ sc->options,
+ GNUNET_MESSAGE_TYPE_PEERSTORE_STORE);
+ GNUNET_MQ_notify_sent (ev, &store_request_sent, sc);
+ GNUNET_MQ_send (h->mq, ev);
+ }
+}
+
+
+/**
+ * Iterator over watch requests to cancel them.
+ *
+ * @param cls unsused
+ * @param key key to the watch request
+ * @param value watch context
+ * @return #GNUNET_YES to continue iteration
+ */
+static int
+destroy_watch (void *cls, const struct GNUNET_HashCode *key, void *value)
+{
+ struct GNUNET_PEERSTORE_WatchContext *wc = value;