2 This file is part of GNUnet.
3 (C) 2013-2014 Christian Grothoff (and other contributing authors)
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version.
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
21 * @file peerstore/peerstore_api.c
22 * @brief API for peerstore
23 * @author Omar Tarabai
24 * @author Christian Grothoff
27 #include "gnunet_util_lib.h"
28 #include "peerstore.h"
29 #include "peerstore_common.h"
31 #define LOG(kind,...) GNUNET_log_from (kind, "peerstore-api",__VA_ARGS__)
33 /******************************************************************************/
34 /************************ DATA STRUCTURES ****************************/
35 /******************************************************************************/
38 * Handle to the PEERSTORE service.
40 struct GNUNET_PEERSTORE_Handle
46 const struct GNUNET_CONFIGURATION_Handle *cfg;
49 * Connection to the service.
51 struct GNUNET_CLIENT_Connection *client;
56 struct GNUNET_MQ_Handle *mq;
59 * Head of active STORE requests.
61 struct GNUNET_PEERSTORE_StoreContext *store_head;
64 * Tail of active STORE requests.
66 struct GNUNET_PEERSTORE_StoreContext *store_tail;
69 * Head of active ITERATE requests.
71 struct GNUNET_PEERSTORE_IterateContext *iterate_head;
74 * Tail of active ITERATE requests.
76 struct GNUNET_PEERSTORE_IterateContext *iterate_tail;
79 * Hashmap of watch requests
81 struct GNUNET_CONTAINER_MultiHashMap *watches;
84 * Are we in the process of disconnecting but need to sync first?
91 * Context for a store request
93 struct GNUNET_PEERSTORE_StoreContext
98 struct GNUNET_PEERSTORE_StoreContext *next;
103 struct GNUNET_PEERSTORE_StoreContext *prev;
106 * Handle to the PEERSTORE service.
108 struct GNUNET_PEERSTORE_Handle *h;
111 * Continuation called with service response
113 GNUNET_PEERSTORE_Continuation cont;
116 * Closure for @e cont
121 * Which subsystem does the store?
126 * Key for the store operation.
131 * Contains @e size bytes.
136 * MQ Envelope with store request message
138 struct GNUNET_MQ_Envelope *ev;
141 * Peer the store is for.
143 struct GNUNET_PeerIdentity peer;
146 * Number of bytes in @e value.
151 * When does the value expire?
153 struct GNUNET_TIME_Absolute expiry;
156 * Options for the store operation.
158 enum GNUNET_PEERSTORE_StoreOption options;
163 * Context for a iterate request
165 struct GNUNET_PEERSTORE_IterateContext
170 struct GNUNET_PEERSTORE_IterateContext *next;
175 struct GNUNET_PEERSTORE_IterateContext *prev;
178 * Handle to the PEERSTORE service.
180 struct GNUNET_PEERSTORE_Handle *h;
183 * MQ Envelope with iterate request message
185 struct GNUNET_MQ_Envelope *ev;
188 * Callback with each matching record
190 GNUNET_PEERSTORE_Processor callback;
193 * Closure for @e callback
198 * #GNUNET_YES / #GNUNET_NO
199 * Iterate request has been sent and we are still expecting records
204 * Task identifier for the function called
205 * on iterate request timeout
207 GNUNET_SCHEDULER_TaskIdentifier timeout_task;
212 * Context for a watch request
214 struct GNUNET_PEERSTORE_WatchContext
219 struct GNUNET_PEERSTORE_WatchContext *next;
224 struct GNUNET_PEERSTORE_WatchContext *prev;
227 * Handle to the PEERSTORE service.
229 struct GNUNET_PEERSTORE_Handle *h;
232 * MQ Envelope with watch request message
234 struct GNUNET_MQ_Envelope *ev;
237 * Callback with each record received
239 GNUNET_PEERSTORE_Processor callback;
242 * Closure for @e callback
247 * Hash of the combined key
249 struct GNUNET_HashCode keyhash;
252 * #GNUNET_YES / #GNUNET_NO
253 * if sent, cannot be canceled
259 /******************************************************************************/
260 /******************* DECLARATIONS *********************/
261 /******************************************************************************/
264 * When a response for iterate request is received
266 * @param cls a 'struct GNUNET_PEERSTORE_Handle *'
267 * @param msg message received, NULL on timeout or fatal error
270 handle_iterate_result (void *cls, const struct GNUNET_MessageHeader *msg);
273 * When a watch record is received
275 * @param cls a 'struct GNUNET_PEERSTORE_Handle *'
276 * @param msg message received, NULL on timeout or fatal error
279 handle_watch_result (void *cls, const struct GNUNET_MessageHeader *msg);
282 * Close the existing connection to PEERSTORE and reconnect.
284 * @param h handle to the service
287 reconnect (struct GNUNET_PEERSTORE_Handle *h);
290 * Callback after MQ envelope is sent
292 * @param cls a 'struct GNUNET_PEERSTORE_WatchContext *'
295 watch_request_sent (void *cls)
297 struct GNUNET_PEERSTORE_WatchContext *wc = cls;
299 wc->request_sent = GNUNET_YES;
305 * Callback after MQ envelope is sent
307 * @param cls a `struct GNUNET_PEERSTORE_IterateContext *`
310 iterate_request_sent (void *cls)
312 struct GNUNET_PEERSTORE_IterateContext *ic = cls;
314 LOG (GNUNET_ERROR_TYPE_DEBUG,
315 "Iterate request sent to service.\n");
316 ic->iterating = GNUNET_YES;
322 * Callback after MQ envelope is sent
324 * @param cls a `struct GNUNET_PEERSTORE_StoreContext *`
327 store_request_sent (void *cls)
329 struct GNUNET_PEERSTORE_StoreContext *sc = cls;
330 GNUNET_PEERSTORE_Continuation cont;
335 cont_cls = sc->cont_cls;
336 GNUNET_PEERSTORE_store_cancel (sc);
338 cont (cont_cls, GNUNET_OK);
343 * MQ message handlers
345 static const struct GNUNET_MQ_MessageHandler mq_handlers[] = {
346 {&handle_iterate_result, GNUNET_MESSAGE_TYPE_PEERSTORE_ITERATE_RECORD, 0},
347 {&handle_iterate_result, GNUNET_MESSAGE_TYPE_PEERSTORE_ITERATE_END,
348 sizeof (struct GNUNET_MessageHeader)},
349 {&handle_watch_result, GNUNET_MESSAGE_TYPE_PEERSTORE_WATCH_RECORD, 0},
350 GNUNET_MQ_HANDLERS_END
353 /******************************************************************************/
354 /******************* CONNECTION FUNCTIONS *********************/
355 /******************************************************************************/
358 handle_client_error (void *cls, enum GNUNET_MQ_Error error)
360 struct GNUNET_PEERSTORE_Handle *h = cls;
362 LOG (GNUNET_ERROR_TYPE_ERROR,
363 _("Received an error notification from MQ of type: %d\n"), error);
369 * Iterator over previous watches to resend them
372 rewatch_it (void *cls,
373 const struct GNUNET_HashCode *key,
376 struct GNUNET_PEERSTORE_Handle *h = cls;
377 struct GNUNET_PEERSTORE_WatchContext *wc = value;
378 struct StoreKeyHashMessage *hm;
380 if (GNUNET_YES == wc->request_sent)
381 { /* Envelope gone, create new one. */
382 wc->ev = GNUNET_MQ_msg (hm, GNUNET_MESSAGE_TYPE_PEERSTORE_WATCH);
383 hm->keyhash = wc->keyhash;
384 wc->request_sent = GNUNET_NO;
386 GNUNET_MQ_notify_sent (wc->ev, &watch_request_sent, wc);
387 GNUNET_MQ_send (h->mq, wc->ev);
393 * Close the existing connection to PEERSTORE and reconnect.
395 * @param h handle to the service
398 reconnect (struct GNUNET_PEERSTORE_Handle *h)
400 struct GNUNET_PEERSTORE_IterateContext *ic;
401 GNUNET_PEERSTORE_Processor icb;
403 struct GNUNET_PEERSTORE_StoreContext *sc;
405 LOG (GNUNET_ERROR_TYPE_DEBUG,
406 "Reconnecting...\n");
407 for (sc = h->store_head; NULL != sc; sc = sc->next)
411 GNUNET_MQ_send_cancel (sc->ev);
417 GNUNET_MQ_destroy (h->mq);
420 if (NULL != h->client)
422 GNUNET_CLIENT_disconnect (h->client);
425 h->client = GNUNET_CLIENT_connect ("peerstore", h->cfg);
426 GNUNET_assert (NULL != h->client);
428 GNUNET_MQ_queue_for_connection_client (h->client, mq_handlers,
429 &handle_client_error, h);
430 LOG (GNUNET_ERROR_TYPE_DEBUG,
431 "Resending pending requests after reconnect.\n");
432 if (NULL != h->watches)
433 GNUNET_CONTAINER_multihashmap_iterate (h->watches,
436 for (ic = h->iterate_head; NULL != ic; ic = ic->next)
438 if (GNUNET_YES == ic->iterating)
441 icb_cls = ic->callback_cls;
442 GNUNET_PEERSTORE_iterate_cancel (ic);
446 _("Iteration canceled due to reconnection."));
450 GNUNET_MQ_notify_sent (ic->ev,
451 &iterate_request_sent,
453 GNUNET_MQ_send (h->mq, ic->ev);
456 for (sc = h->store_head; NULL != sc; sc = sc->next)
458 sc->ev = PEERSTORE_create_record_mq_envelope (sc->sub_system,
465 GNUNET_MESSAGE_TYPE_PEERSTORE_STORE);
466 GNUNET_MQ_notify_sent (sc->ev,
469 GNUNET_MQ_send (h->mq, sc->ev);
475 * Iterator over watch requests to cancel them.
478 * @param key key to the watch request
479 * @param value watch context
480 * @return #GNUNET_YES to continue iteration
483 destroy_watch (void *cls,
484 const struct GNUNET_HashCode *key,
487 struct GNUNET_PEERSTORE_WatchContext *wc = value;
489 GNUNET_PEERSTORE_watch_cancel (wc);
495 * Kill the connection to the service. This can be delayed in case of pending
496 * STORE requests and the user explicitly asked to sync first. Otherwise it is
497 * performed instantly.
499 * @param h Handle to the service.
502 do_disconnect (struct GNUNET_PEERSTORE_Handle *h)
506 GNUNET_MQ_destroy (h->mq);
509 if (NULL != h->client)
511 GNUNET_CLIENT_disconnect (h->client);
519 * Connect to the PEERSTORE service.
521 * @param cfg configuration to use
522 * @return NULL on error
524 struct GNUNET_PEERSTORE_Handle *
525 GNUNET_PEERSTORE_connect (const struct GNUNET_CONFIGURATION_Handle *cfg)
527 struct GNUNET_PEERSTORE_Handle *h;
529 h = GNUNET_new (struct GNUNET_PEERSTORE_Handle);
531 h->client = GNUNET_CLIENT_connect ("peerstore", cfg);
532 if (NULL == h->client)
538 h->disconnecting = GNUNET_NO;
540 GNUNET_MQ_queue_for_connection_client (h->client, mq_handlers,
541 &handle_client_error, h);
544 GNUNET_CLIENT_disconnect (h->client);
548 LOG (GNUNET_ERROR_TYPE_DEBUG,
549 "New connection created\n");
555 * Disconnect from the PEERSTORE service. Any pending ITERATE and WATCH requests
557 * Any pending STORE requests will depend on @e snyc_first flag.
559 * @param h handle to disconnect
560 * @param sync_first send any pending STORE requests before disconnecting
563 GNUNET_PEERSTORE_disconnect (struct GNUNET_PEERSTORE_Handle *h, int sync_first)
565 struct GNUNET_PEERSTORE_IterateContext *ic;
566 struct GNUNET_PEERSTORE_IterateContext *ic_iter;
567 struct GNUNET_PEERSTORE_StoreContext *sc;
568 struct GNUNET_PEERSTORE_StoreContext *sc_iter;
570 LOG (GNUNET_ERROR_TYPE_DEBUG,
572 if (NULL != h->watches)
574 GNUNET_CONTAINER_multihashmap_iterate (h->watches,
577 GNUNET_CONTAINER_multihashmap_destroy (h->watches);
580 ic_iter = h->iterate_head;
581 while (NULL != ic_iter)
585 ic_iter = ic_iter->next;
586 GNUNET_PEERSTORE_iterate_cancel (ic);
588 if (NULL != h->store_head)
590 if (GNUNET_YES == sync_first)
592 LOG (GNUNET_ERROR_TYPE_DEBUG,
593 "Delaying disconnection due to pending store requests.\n");
594 h->disconnecting = GNUNET_YES;
597 sc_iter = h->store_head;
598 while (NULL != sc_iter)
601 sc_iter = sc_iter->next;
602 GNUNET_PEERSTORE_store_cancel (sc);
609 /******************************************************************************/
610 /******************* STORE FUNCTIONS *********************/
611 /******************************************************************************/
615 * Cancel a store request
617 * @param sc Store request context
620 GNUNET_PEERSTORE_store_cancel (struct GNUNET_PEERSTORE_StoreContext *sc)
622 struct GNUNET_PEERSTORE_Handle *h = sc->h;
626 GNUNET_MQ_send_cancel (sc->ev);
629 GNUNET_CONTAINER_DLL_remove (sc->h->store_head,
632 GNUNET_free (sc->sub_system);
633 GNUNET_free (sc->value);
634 GNUNET_free (sc->key);
636 if ( (GNUNET_YES == h->disconnecting) &&
637 (NULL == h->store_head) )
643 * Store a new entry in the PEERSTORE.
644 * Note that stored entries can be lost in some cases
645 * such as power failure.
647 * @param h Handle to the PEERSTORE service
648 * @param sub_system name of the sub system
649 * @param peer Peer Identity
650 * @param key entry key
651 * @param value entry value BLOB
652 * @param size size of @e value
653 * @param expiry absolute time after which the entry is (possibly) deleted
654 * @param options options specific to the storage operation
655 * @param cont Continuation function after the store request is sent
656 * @param cont_cls Closure for @a cont
658 struct GNUNET_PEERSTORE_StoreContext *
659 GNUNET_PEERSTORE_store (struct GNUNET_PEERSTORE_Handle *h,
660 const char *sub_system,
661 const struct GNUNET_PeerIdentity *peer,
665 struct GNUNET_TIME_Absolute expiry,
666 enum GNUNET_PEERSTORE_StoreOption options,
667 GNUNET_PEERSTORE_Continuation cont,
670 struct GNUNET_MQ_Envelope *ev;
671 struct GNUNET_PEERSTORE_StoreContext *sc;
673 LOG (GNUNET_ERROR_TYPE_DEBUG,
674 "Storing value (size: %lu) for subsytem `%s', peer `%s', key `%s'\n",
675 size, sub_system, GNUNET_i2s (peer), key);
676 ev = PEERSTORE_create_record_mq_envelope (sub_system,
683 GNUNET_MESSAGE_TYPE_PEERSTORE_STORE);
684 sc = GNUNET_new (struct GNUNET_PEERSTORE_StoreContext);
685 sc->sub_system = GNUNET_strdup (sub_system);
687 sc->key = GNUNET_strdup (key);
688 sc->value = GNUNET_memdup (value, size);
691 sc->options = options;
693 sc->cont_cls = cont_cls;
696 GNUNET_CONTAINER_DLL_insert_tail (h->store_head,
699 GNUNET_MQ_notify_sent (ev,
702 GNUNET_MQ_send (h->mq, ev);
708 /******************************************************************************/
709 /******************* ITERATE FUNCTIONS *********************/
710 /******************************************************************************/
713 * When a response for iterate request is received
715 * @param cls a `struct GNUNET_PEERSTORE_Handle *`
716 * @param msg message received, NULL on timeout or fatal error
719 handle_iterate_result (void *cls,
720 const struct GNUNET_MessageHeader *msg)
722 struct GNUNET_PEERSTORE_Handle *h = cls;
723 struct GNUNET_PEERSTORE_IterateContext *ic;
724 GNUNET_PEERSTORE_Processor callback;
727 struct GNUNET_PEERSTORE_Record *record;
730 ic = h->iterate_head;
733 LOG (GNUNET_ERROR_TYPE_ERROR,
734 _("Unexpected iteration response, this should not happen.\n"));
738 callback = ic->callback;
739 callback_cls = ic->callback_cls;
740 if (NULL == msg) /* Connection error */
742 if (NULL != callback)
743 callback (callback_cls, NULL,
744 _("Error communicating with `PEERSTORE' service."));
748 msg_type = ntohs (msg->type);
749 if (GNUNET_MESSAGE_TYPE_PEERSTORE_ITERATE_END == msg_type)
751 ic->iterating = GNUNET_NO;
752 GNUNET_PEERSTORE_iterate_cancel (ic);
753 if (NULL != callback)
754 callback (callback_cls, NULL, NULL);
757 if (NULL != callback)
759 record = PEERSTORE_parse_record_message (msg);
762 callback (callback_cls, NULL,
763 _("Received a malformed response from service."));
766 continue_iter = callback (callback_cls, record, NULL);
767 PEERSTORE_destroy_record (record);
769 if (GNUNET_NO == continue_iter)
776 * Called when the iterate request is timedout
778 * @param cls a `struct GNUNET_PEERSTORE_IterateContext *`
779 * @param tc Scheduler task context (unused)
782 iterate_timeout (void *cls,
783 const struct GNUNET_SCHEDULER_TaskContext *tc)
785 struct GNUNET_PEERSTORE_IterateContext *ic = cls;
786 GNUNET_PEERSTORE_Processor callback;
789 ic->timeout_task = GNUNET_SCHEDULER_NO_TASK;
790 callback = ic->callback;
791 callback_cls = ic->callback_cls;
792 GNUNET_PEERSTORE_iterate_cancel (ic);
793 if (NULL != callback)
794 callback (callback_cls,
801 * Cancel an iterate request
802 * Please do not call after the iterate request is done
804 * @param ic Iterate request context as returned by GNUNET_PEERSTORE_iterate()
807 GNUNET_PEERSTORE_iterate_cancel (struct GNUNET_PEERSTORE_IterateContext *ic)
809 if (GNUNET_SCHEDULER_NO_TASK != ic->timeout_task)
811 GNUNET_SCHEDULER_cancel (ic->timeout_task);
812 ic->timeout_task = GNUNET_SCHEDULER_NO_TASK;
814 if (GNUNET_NO == ic->iterating)
818 GNUNET_MQ_send_cancel (ic->ev);
821 GNUNET_CONTAINER_DLL_remove (ic->h->iterate_head,
832 * Iterate over records matching supplied key information
834 * @param h handle to the PEERSTORE service
835 * @param sub_system name of sub system
836 * @param peer Peer identity (can be NULL)
837 * @param key entry key string (can be NULL)
838 * @param timeout time after which the iterate request is canceled
839 * @param callback function called with each matching record, all NULL's on end
840 * @param callback_cls closure for @a callback
841 * @return Handle to iteration request
843 struct GNUNET_PEERSTORE_IterateContext *
844 GNUNET_PEERSTORE_iterate (struct GNUNET_PEERSTORE_Handle *h,
845 const char *sub_system,
846 const struct GNUNET_PeerIdentity *peer,
848 struct GNUNET_TIME_Relative timeout,
849 GNUNET_PEERSTORE_Processor callback,
852 struct GNUNET_MQ_Envelope *ev;
853 struct GNUNET_PEERSTORE_IterateContext *ic;
855 ev = PEERSTORE_create_record_mq_envelope (sub_system, peer, key, NULL, 0,
857 GNUNET_MESSAGE_TYPE_PEERSTORE_ITERATE);
858 ic = GNUNET_new (struct GNUNET_PEERSTORE_IterateContext);
860 ic->callback = callback;
861 ic->callback_cls = callback_cls;
864 ic->iterating = GNUNET_NO;
865 GNUNET_CONTAINER_DLL_insert_tail (h->iterate_head,
868 LOG (GNUNET_ERROR_TYPE_DEBUG,
869 "Sending an iterate request for sub system `%s'\n", sub_system);
870 GNUNET_MQ_notify_sent (ev, &iterate_request_sent, ic);
871 GNUNET_MQ_send (h->mq, ev);
873 GNUNET_SCHEDULER_add_delayed (timeout, &iterate_timeout, ic);
878 /******************************************************************************/
879 /******************* WATCH FUNCTIONS *********************/
880 /******************************************************************************/
883 * When a watch record is received
885 * @param cls a `struct GNUNET_PEERSTORE_Handle *`
886 * @param msg message received, NULL on timeout or fatal error
889 handle_watch_result (void *cls, const struct GNUNET_MessageHeader *msg)
891 struct GNUNET_PEERSTORE_Handle *h = cls;
892 struct GNUNET_PEERSTORE_Record *record;
893 struct GNUNET_HashCode keyhash;
894 struct GNUNET_PEERSTORE_WatchContext *wc;
898 LOG (GNUNET_ERROR_TYPE_ERROR,
899 _("Problem receiving a watch response, no way to determine which request.\n"));
903 LOG (GNUNET_ERROR_TYPE_DEBUG,
904 "Received a watch record from service.\n");
905 record = PEERSTORE_parse_record_message (msg);
906 PEERSTORE_hash_key (record->sub_system, record->peer, record->key, &keyhash);
907 wc = GNUNET_CONTAINER_multihashmap_get (h->watches, &keyhash);
910 LOG (GNUNET_ERROR_TYPE_ERROR,
911 _("Received a watch result for a non existing watch.\n"));
912 PEERSTORE_destroy_record (record);
916 if (NULL != wc->callback)
917 wc->callback (wc->callback_cls, record, NULL);
918 PEERSTORE_destroy_record (record);
923 * Cancel a watch request
925 * @param wc handle to the watch request
928 GNUNET_PEERSTORE_watch_cancel (struct GNUNET_PEERSTORE_WatchContext *wc)
930 struct GNUNET_PEERSTORE_Handle *h = wc->h;
931 struct GNUNET_MQ_Envelope *ev;
932 struct StoreKeyHashMessage *hm;
934 LOG (GNUNET_ERROR_TYPE_DEBUG, "Canceling watch.\n");
935 if (GNUNET_YES == wc->request_sent) /* If request already sent to service, send a cancel request. */
937 ev = GNUNET_MQ_msg (hm, GNUNET_MESSAGE_TYPE_PEERSTORE_WATCH_CANCEL);
938 hm->keyhash = wc->keyhash;
939 GNUNET_MQ_send (h->mq, ev);
941 wc->callback_cls = NULL;
945 GNUNET_MQ_send_cancel (wc->ev);
948 GNUNET_CONTAINER_multihashmap_remove (h->watches, &wc->keyhash, wc);
955 * Request watching a given key
956 * User will be notified with any new values added to key
958 * @param h handle to the PEERSTORE service
959 * @param sub_system name of sub system
960 * @param peer Peer identity
961 * @param key entry key string
962 * @param callback function called with each new value
963 * @param callback_cls closure for @a callback
964 * @return Handle to watch request
966 struct GNUNET_PEERSTORE_WatchContext *
967 GNUNET_PEERSTORE_watch (struct GNUNET_PEERSTORE_Handle *h,
968 const char *sub_system,
969 const struct GNUNET_PeerIdentity *peer, const char *key,
970 GNUNET_PEERSTORE_Processor callback, void *callback_cls)
972 struct GNUNET_MQ_Envelope *ev;
973 struct StoreKeyHashMessage *hm;
974 struct GNUNET_PEERSTORE_WatchContext *wc;
976 GNUNET_assert (NULL != sub_system);
977 GNUNET_assert (NULL != peer);
978 GNUNET_assert (NULL != key);
979 ev = GNUNET_MQ_msg (hm, GNUNET_MESSAGE_TYPE_PEERSTORE_WATCH);
980 PEERSTORE_hash_key (sub_system, peer, key, &hm->keyhash);
981 wc = GNUNET_new (struct GNUNET_PEERSTORE_WatchContext);
983 wc->callback = callback;
984 wc->callback_cls = callback_cls;
987 wc->request_sent = GNUNET_NO;
988 wc->keyhash = hm->keyhash;
989 if (NULL == h->watches)
990 h->watches = GNUNET_CONTAINER_multihashmap_create (5, GNUNET_NO);
991 GNUNET_CONTAINER_multihashmap_put (h->watches, &wc->keyhash, wc,
992 GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE);
993 LOG (GNUNET_ERROR_TYPE_DEBUG,
994 "Sending a watch request for ss `%s', peer `%s', key `%s'.\n",
995 sub_system, GNUNET_i2s (peer), key);
996 GNUNET_MQ_notify_sent (ev, &watch_request_sent, wc);
997 GNUNET_MQ_send (h->mq, ev);
1001 /* end of peerstore_api.c */