+ * Add a host to the persistent list. This method operates in
+ * semi-reliable mode: if the transmission is not completed by
+ * the time 'GNUNET_PEERINFO_disconnect' is called, it will be
+ * aborted. Furthermore, if a second HELLO is added for the
+ * same peer before the first one was transmitted, PEERINFO may
+ * merge the two HELLOs prior to transmission to the service.
+ *
+ * @param h handle to the peerinfo service
+ * @param hello the verified (!) HELLO message
+ * @param cont continuation to call when done, NULL is allowed
+ * @param cont_cls closure for 'cont'
+ * @return handle to cancel add operation; all pending
+ * 'add' operations will be cancelled automatically
+ * on disconnect, so it is not necessary to keep this
+ * handle (unless 'cont' is NULL and at some point
+ * calling 'cont' must be prevented)
+ */
+struct GNUNET_PEERINFO_AddContext *
+GNUNET_PEERINFO_add_peer (struct GNUNET_PEERINFO_Handle *h,
+ const struct GNUNET_HELLO_Message *hello,
+ GNUNET_PEERINFO_Continuation cont,
+ void *cont_cls)
+{
+ uint16_t hs = GNUNET_HELLO_size (hello);
+ struct GNUNET_PEERINFO_AddContext *ac;
+ struct GNUNET_PeerIdentity peer;
+
+ GNUNET_assert (GNUNET_OK == GNUNET_HELLO_get_id (hello, &peer));
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Adding peer `%s' to PEERINFO database (%u bytes of `%s')\n",
+ GNUNET_i2s (&peer), hs, "HELLO");
+ ac = GNUNET_malloc (sizeof (struct GNUNET_PEERINFO_AddContext) + hs);
+ ac->h = h;
+ ac->size = hs;
+ ac->cont = cont;
+ ac->cont_cls = cont_cls;
+ memcpy (&ac[1], hello, hs);
+ GNUNET_CONTAINER_DLL_insert_tail (h->ac_head, h->ac_tail, ac);
+ trigger_transmit (h);
+ return ac;
+}
+
+
+/**
+ * Cancel pending 'add' operation. Must only be called before
+ * either 'cont' or 'GNUNET_PEERINFO_disconnect' are invoked.
+ *
+ * @param ac handle for the add operation to cancel
+ */
+void
+GNUNET_PEERINFO_add_peer_cancel (struct GNUNET_PEERINFO_AddContext *ac)
+{
+ struct GNUNET_PEERINFO_Handle *h = ac->h;
+
+ GNUNET_CONTAINER_DLL_remove (h->ac_head, h->ac_tail, ac);
+ GNUNET_free (ac);
+}
+
+
+/**
+ * Type of a function to call when we receive a message from the
+ * service. Call the iterator with the result and (if applicable)
+ * continue to receive more messages or trigger processing the next
+ * event (if applicable).