+/**
+ * Iterator over hash map entries.
+ * Called from #generate_view_array and writes every peer id into #view_array.
+ *
+ * @param cls closure - the pointer to the counter
+ * @param key current public key
+ * @param value value in the hash map
+ * @return #GNUNET_YES if we should continue to
+ * iterate,
+ * #GNUNET_NO if not.
+ */
+static int
+dump_id_to_view_array (void *cls,
+ const struct GNUNET_PeerIdentity *key,
+ void *value)
+{
+ unsigned int *i = (unsigned int *) cls;
+
+ view_array[(*i)++] = *key;
+ return GNUNET_YES;
+}
+
+
+/**
+ * Makes sure the view_array is filled with the peer ids currently in #view.
+ * Called from within #do_round before sending pushes and pulls and from
+ * #handle_peer_pull_request when a reply is sent.
+ */
+static void
+generate_view_array (unsigned int view_size)
+{
+ unsigned int *i;
+ int ret;
+
+ if (NULL == view_array)
+ {
+ view_array = GNUNET_new_array (view_size,
+ struct GNUNET_PeerIdentity);
+ i = GNUNET_new (unsigned int);
+ *i = 0;
+
+ ret = GNUNET_CONTAINER_multipeermap_iterate (view,
+ dump_id_to_view_array,
+ i);
+ GNUNET_assert (view_size == ret);
+ GNUNET_assert (view_size == *i);
+
+ GNUNET_free (i);
+ }
+}
+
+