2 This file is part of GNUnet.
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.
22 * @file peerstore/peerstore_api.c
23 * @brief API for peerstore
24 * @author Omar Tarabai
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);
298 * Callback after MQ envelope is sent
300 * @param cls a 'struct GNUNET_PEERSTORE_IterateContext *'
303 iterate_request_sent (void *cls);
307 * Callback after MQ envelope is sent
309 * @param cls a `struct GNUNET_PEERSTORE_StoreContext *`
312 store_request_sent (void *cls)
314 struct GNUNET_PEERSTORE_StoreContext *sc = cls;
315 GNUNET_PEERSTORE_Continuation cont;
320 cont_cls = sc->cont_cls;
321 GNUNET_PEERSTORE_store_cancel (sc);
323 cont (cont_cls, GNUNET_OK);
328 * MQ message handlers
330 static const struct GNUNET_MQ_MessageHandler mq_handlers[] = {
331 {&handle_iterate_result, GNUNET_MESSAGE_TYPE_PEERSTORE_ITERATE_RECORD, 0},
332 {&handle_iterate_result, GNUNET_MESSAGE_TYPE_PEERSTORE_ITERATE_END,
333 sizeof (struct GNUNET_MessageHeader)},
334 {&handle_watch_result, GNUNET_MESSAGE_TYPE_PEERSTORE_WATCH_RECORD, 0},
335 GNUNET_MQ_HANDLERS_END
338 /******************************************************************************/
339 /******************* CONNECTION FUNCTIONS *********************/
340 /******************************************************************************/
343 handle_client_error (void *cls, enum GNUNET_MQ_Error error)
345 struct GNUNET_PEERSTORE_Handle *h = cls;
347 LOG (GNUNET_ERROR_TYPE_ERROR,
348 _("Received an error notification from MQ of type: %d\n"), error);
354 * Iterator over previous watches to resend them
357 rewatch_it (void *cls,
358 const struct GNUNET_HashCode *key,
361 struct GNUNET_PEERSTORE_Handle *h = cls;
362 struct GNUNET_PEERSTORE_WatchContext *wc = value;
363 struct StoreKeyHashMessage *hm;
365 if (GNUNET_YES == wc->request_sent)
366 { /* Envelope gone, create new one. */
367 wc->ev = GNUNET_MQ_msg (hm, GNUNET_MESSAGE_TYPE_PEERSTORE_WATCH);
368 hm->keyhash = wc->keyhash;
369 wc->request_sent = GNUNET_NO;
371 GNUNET_MQ_notify_sent (wc->ev, &watch_request_sent, wc);
372 GNUNET_MQ_send (h->mq, wc->ev);
378 * Close the existing connection to PEERSTORE and reconnect.
380 * @param h handle to the service
383 reconnect (struct GNUNET_PEERSTORE_Handle *h)
385 struct GNUNET_PEERSTORE_IterateContext *ic;
386 GNUNET_PEERSTORE_Processor icb;
388 struct GNUNET_PEERSTORE_StoreContext *sc;
390 LOG (GNUNET_ERROR_TYPE_DEBUG,
391 "Reconnecting...\n");
392 for (sc = h->store_head; NULL != sc; sc = sc->next)
396 GNUNET_MQ_send_cancel (sc->ev);
402 GNUNET_MQ_destroy (h->mq);
405 if (NULL != h->client)
407 GNUNET_CLIENT_disconnect (h->client);
410 h->client = GNUNET_CLIENT_connect ("peerstore", h->cfg);
411 GNUNET_assert (NULL != h->client);
413 GNUNET_MQ_queue_for_connection_client (h->client, mq_handlers,
414 &handle_client_error, h);
415 LOG (GNUNET_ERROR_TYPE_DEBUG,
416 "Resending pending requests after reconnect.\n");
417 if (NULL != h->watches)
418 GNUNET_CONTAINER_multihashmap_iterate (h->watches,
421 for (ic = h->iterate_head; NULL != ic; ic = ic->next)
423 if (GNUNET_YES == ic->iterating)
426 icb_cls = ic->callback_cls;
427 GNUNET_PEERSTORE_iterate_cancel (ic);
431 _("Iteration canceled due to reconnection."));
435 GNUNET_MQ_notify_sent (ic->ev,
436 &iterate_request_sent,
438 GNUNET_MQ_send (h->mq, ic->ev);
441 for (sc = h->store_head; NULL != sc; sc = sc->next)
443 sc->ev = PEERSTORE_create_record_mq_envelope (sc->sub_system,
450 GNUNET_MESSAGE_TYPE_PEERSTORE_STORE);
451 GNUNET_MQ_notify_sent (sc->ev,
454 GNUNET_MQ_send (h->mq, sc->ev);
460 * Iterator over watch requests to cancel them.
463 * @param key key to the watch request
464 * @param value watch context
465 * @return #GNUNET_YES to continue iteration
468 destroy_watch (void *cls,
469 const struct GNUNET_HashCode *key,
472 struct GNUNET_PEERSTORE_WatchContext *wc = value;
474 GNUNET_PEERSTORE_watch_cancel (wc);
480 * Kill the connection to the service. This can be delayed in case of pending
481 * STORE requests and the user explicitly asked to sync first. Otherwise it is
482 * performed instantly.
484 * @param h Handle to the service.
487 do_disconnect (struct GNUNET_PEERSTORE_Handle *h)
491 GNUNET_MQ_destroy (h->mq);
494 if (NULL != h->client)
496 GNUNET_CLIENT_disconnect (h->client);
504 * Connect to the PEERSTORE service.
506 * @param cfg configuration to use
507 * @return NULL on error
509 struct GNUNET_PEERSTORE_Handle *
510 GNUNET_PEERSTORE_connect (const struct GNUNET_CONFIGURATION_Handle *cfg)
512 struct GNUNET_PEERSTORE_Handle *h;
514 h = GNUNET_new (struct GNUNET_PEERSTORE_Handle);
516 h->client = GNUNET_CLIENT_connect ("peerstore", cfg);
517 if (NULL == h->client)
523 h->disconnecting = GNUNET_NO;
525 GNUNET_MQ_queue_for_connection_client (h->client, mq_handlers,
526 &handle_client_error, h);
529 GNUNET_CLIENT_disconnect (h->client);
533 LOG (GNUNET_ERROR_TYPE_DEBUG,
534 "New connection created\n");
540 * Disconnect from the PEERSTORE service. Any pending ITERATE and WATCH requests
542 * Any pending STORE requests will depend on @e snyc_first flag.
544 * @param h handle to disconnect
545 * @param sync_first send any pending STORE requests before disconnecting
548 GNUNET_PEERSTORE_disconnect (struct GNUNET_PEERSTORE_Handle *h, int sync_first)
550 struct GNUNET_PEERSTORE_IterateContext *ic;
551 struct GNUNET_PEERSTORE_IterateContext *ic_iter;
552 struct GNUNET_PEERSTORE_StoreContext *sc;
553 struct GNUNET_PEERSTORE_StoreContext *sc_iter;
555 LOG (GNUNET_ERROR_TYPE_DEBUG,
557 if (NULL != h->watches)
559 GNUNET_CONTAINER_multihashmap_iterate (h->watches,
562 GNUNET_CONTAINER_multihashmap_destroy (h->watches);
565 ic_iter = h->iterate_head;
566 while (NULL != ic_iter)
570 ic_iter = ic_iter->next;
571 GNUNET_PEERSTORE_iterate_cancel (ic);
573 if (NULL != h->store_head)
575 if (GNUNET_YES == sync_first)
577 LOG (GNUNET_ERROR_TYPE_DEBUG,
578 "Delaying disconnection due to pending store requests.\n");
579 h->disconnecting = GNUNET_YES;
582 sc_iter = h->store_head;
583 while (NULL != sc_iter)
586 sc_iter = sc_iter->next;
587 GNUNET_PEERSTORE_store_cancel (sc);
594 /******************************************************************************/
595 /******************* STORE FUNCTIONS *********************/
596 /******************************************************************************/
600 * Cancel a store request
602 * @param sc Store request context
605 GNUNET_PEERSTORE_store_cancel (struct GNUNET_PEERSTORE_StoreContext *sc)
607 struct GNUNET_PEERSTORE_Handle *h = sc->h;
611 GNUNET_MQ_send_cancel (sc->ev);
614 GNUNET_CONTAINER_DLL_remove (sc->h->store_head,
617 GNUNET_free (sc->sub_system);
618 GNUNET_free (sc->value);
619 GNUNET_free (sc->key);
621 if ( (GNUNET_YES == h->disconnecting) &&
622 (NULL == h->store_head) )
628 * Store a new entry in the PEERSTORE.
629 * Note that stored entries can be lost in some cases
630 * such as power failure.
632 * @param h Handle to the PEERSTORE service
633 * @param sub_system name of the sub system
634 * @param peer Peer Identity
635 * @param key entry key
636 * @param value entry value BLOB
637 * @param size size of @e value
638 * @param expiry absolute time after which the entry is (possibly) deleted
639 * @param options options specific to the storage operation
640 * @param cont Continuation function after the store request is sent
641 * @param cont_cls Closure for @a cont
643 struct GNUNET_PEERSTORE_StoreContext *
644 GNUNET_PEERSTORE_store (struct GNUNET_PEERSTORE_Handle *h,
645 const char *sub_system,
646 const struct GNUNET_PeerIdentity *peer,
650 struct GNUNET_TIME_Absolute expiry,
651 enum GNUNET_PEERSTORE_StoreOption options,
652 GNUNET_PEERSTORE_Continuation cont,
655 struct GNUNET_MQ_Envelope *ev;
656 struct GNUNET_PEERSTORE_StoreContext *sc;
658 LOG (GNUNET_ERROR_TYPE_DEBUG,
659 "Storing value (size: %lu) for subsytem `%s', peer `%s', key `%s'\n",
660 size, sub_system, GNUNET_i2s (peer), key);
661 ev = PEERSTORE_create_record_mq_envelope (sub_system,
668 GNUNET_MESSAGE_TYPE_PEERSTORE_STORE);
669 sc = GNUNET_new (struct GNUNET_PEERSTORE_StoreContext);
670 sc->sub_system = GNUNET_strdup (sub_system);
672 sc->key = GNUNET_strdup (key);
673 sc->value = GNUNET_memdup (value, size);
676 sc->options = options;
678 sc->cont_cls = cont_cls;
681 GNUNET_CONTAINER_DLL_insert_tail (h->store_head,
684 GNUNET_MQ_notify_sent (ev,
687 GNUNET_MQ_send (h->mq, ev);
693 /******************************************************************************/
694 /******************* ITERATE FUNCTIONS *********************/
695 /******************************************************************************/
698 * When a response for iterate request is received
700 * @param cls a `struct GNUNET_PEERSTORE_Handle *`
701 * @param msg message received, NULL on timeout or fatal error
704 handle_iterate_result (void *cls,
705 const struct GNUNET_MessageHeader *msg)
707 struct GNUNET_PEERSTORE_Handle *h = cls;
708 struct GNUNET_PEERSTORE_IterateContext *ic;
709 GNUNET_PEERSTORE_Processor callback;
712 struct GNUNET_PEERSTORE_Record *record;
715 ic = h->iterate_head;
718 LOG (GNUNET_ERROR_TYPE_ERROR,
719 _("Unexpected iteration response, this should not happen.\n"));
723 callback = ic->callback;
724 callback_cls = ic->callback_cls;
725 if (NULL == msg) /* Connection error */
728 if (NULL != callback)
729 callback (callback_cls, NULL,
730 _("Error communicating with `PEERSTORE' service."));
734 msg_type = ntohs (msg->type);
735 if (GNUNET_MESSAGE_TYPE_PEERSTORE_ITERATE_END == msg_type)
737 ic->iterating = GNUNET_NO;
738 GNUNET_PEERSTORE_iterate_cancel (ic);
739 if (NULL != callback)
740 callback (callback_cls, NULL, NULL);
743 if (NULL != callback)
745 record = PEERSTORE_parse_record_message (msg);
748 callback (callback_cls, NULL,
749 _("Received a malformed response from service."));
752 continue_iter = callback (callback_cls, record, NULL);
753 PEERSTORE_destroy_record (record);
755 if (GNUNET_NO == continue_iter)
762 * Callback after MQ envelope is sent
764 * @param cls a `struct GNUNET_PEERSTORE_IterateContext *`
767 iterate_request_sent (void *cls)
769 struct GNUNET_PEERSTORE_IterateContext *ic = cls;
771 LOG (GNUNET_ERROR_TYPE_DEBUG,
772 "Iterate request sent to service.\n");
773 ic->iterating = GNUNET_YES;
779 * Called when the iterate request is timedout
781 * @param cls a `struct GNUNET_PEERSTORE_IterateContext *`
782 * @param tc Scheduler task context (unused)
785 iterate_timeout (void *cls,
786 const struct GNUNET_SCHEDULER_TaskContext *tc)
788 struct GNUNET_PEERSTORE_IterateContext *ic = cls;
789 GNUNET_PEERSTORE_Processor callback;
792 ic->timeout_task = GNUNET_SCHEDULER_NO_TASK;
793 callback = ic->callback;
794 callback_cls = ic->callback_cls;
795 GNUNET_PEERSTORE_iterate_cancel (ic);
796 if (NULL != callback)
797 callback (callback_cls,
804 * Cancel an iterate request
805 * Please do not call after the iterate request is done
807 * @param ic Iterate request context as returned by GNUNET_PEERSTORE_iterate()
810 GNUNET_PEERSTORE_iterate_cancel (struct GNUNET_PEERSTORE_IterateContext *ic)
812 if (GNUNET_SCHEDULER_NO_TASK != ic->timeout_task)
814 GNUNET_SCHEDULER_cancel (ic->timeout_task);
815 ic->timeout_task = GNUNET_SCHEDULER_NO_TASK;
817 if (GNUNET_NO == ic->iterating)
821 GNUNET_MQ_send_cancel (ic->ev);
824 GNUNET_CONTAINER_DLL_remove (ic->h->iterate_head,
835 * Iterate over records matching supplied key information
837 * @param h handle to the PEERSTORE service
838 * @param sub_system name of sub system
839 * @param peer Peer identity (can be NULL)
840 * @param key entry key string (can be NULL)
841 * @param timeout time after which the iterate request is canceled
842 * @param callback function called with each matching record, all NULL's on end
843 * @param callback_cls closure for @a callback
844 * @return Handle to iteration request
846 struct GNUNET_PEERSTORE_IterateContext *
847 GNUNET_PEERSTORE_iterate (struct GNUNET_PEERSTORE_Handle *h,
848 const char *sub_system,
849 const struct GNUNET_PeerIdentity *peer,
851 struct GNUNET_TIME_Relative timeout,
852 GNUNET_PEERSTORE_Processor callback,
855 struct GNUNET_MQ_Envelope *ev;
856 struct GNUNET_PEERSTORE_IterateContext *ic;
858 ev = PEERSTORE_create_record_mq_envelope (sub_system, peer, key, NULL, 0,
860 GNUNET_MESSAGE_TYPE_PEERSTORE_ITERATE);
861 ic = GNUNET_new (struct GNUNET_PEERSTORE_IterateContext);
863 ic->callback = callback;
864 ic->callback_cls = callback_cls;
867 ic->iterating = GNUNET_NO;
868 GNUNET_CONTAINER_DLL_insert_tail (h->iterate_head,
871 LOG (GNUNET_ERROR_TYPE_DEBUG,
872 "Sending an iterate request for sub system `%s'\n", sub_system);
873 GNUNET_MQ_notify_sent (ev, &iterate_request_sent, ic);
874 GNUNET_MQ_send (h->mq, ev);
876 GNUNET_SCHEDULER_add_delayed (timeout, &iterate_timeout, ic);
881 /******************************************************************************/
882 /******************* WATCH FUNCTIONS *********************/
883 /******************************************************************************/
886 * When a watch record is received
888 * @param cls a `struct GNUNET_PEERSTORE_Handle *`
889 * @param msg message received, NULL on timeout or fatal error
892 handle_watch_result (void *cls, const struct GNUNET_MessageHeader *msg)
894 struct GNUNET_PEERSTORE_Handle *h = cls;
895 struct GNUNET_PEERSTORE_Record *record;
896 struct GNUNET_HashCode keyhash;
897 struct GNUNET_PEERSTORE_WatchContext *wc;
901 LOG (GNUNET_ERROR_TYPE_ERROR,
902 _("Problem receiving a watch response, no way to determine which request.\n"));
906 LOG (GNUNET_ERROR_TYPE_DEBUG,
907 "Received a watch record from service.\n");
908 record = PEERSTORE_parse_record_message (msg);
909 PEERSTORE_hash_key (record->sub_system, record->peer, record->key, &keyhash);
910 wc = GNUNET_CONTAINER_multihashmap_get (h->watches, &keyhash);
913 LOG (GNUNET_ERROR_TYPE_ERROR,
914 _("Received a watch result for a non existing watch.\n"));
915 PEERSTORE_destroy_record (record);
919 if (NULL != wc->callback)
920 wc->callback (wc->callback_cls, record, NULL);
921 PEERSTORE_destroy_record (record);
926 * Callback after MQ envelope is sent
928 * @param cls a `struct GNUNET_PEERSTORE_WatchContext *`
931 watch_request_sent (void *cls)
933 struct GNUNET_PEERSTORE_WatchContext *wc = cls;
935 wc->request_sent = GNUNET_YES;
941 * Cancel a watch request
943 * @param wc handle to the watch request
946 GNUNET_PEERSTORE_watch_cancel (struct GNUNET_PEERSTORE_WatchContext *wc)
948 struct GNUNET_PEERSTORE_Handle *h = wc->h;
949 struct GNUNET_MQ_Envelope *ev;
950 struct StoreKeyHashMessage *hm;
952 LOG (GNUNET_ERROR_TYPE_DEBUG, "Canceling watch.\n");
953 if (GNUNET_YES == wc->request_sent) /* If request already sent to service, send a cancel request. */
955 ev = GNUNET_MQ_msg (hm, GNUNET_MESSAGE_TYPE_PEERSTORE_WATCH_CANCEL);
956 hm->keyhash = wc->keyhash;
957 GNUNET_MQ_send (h->mq, ev);
959 wc->callback_cls = NULL;
963 GNUNET_MQ_send_cancel (wc->ev);
966 GNUNET_CONTAINER_multihashmap_remove (h->watches, &wc->keyhash, wc);
973 * Request watching a given key
974 * User will be notified with any new values added to key
976 * @param h handle to the PEERSTORE service
977 * @param sub_system name of sub system
978 * @param peer Peer identity
979 * @param key entry key string
980 * @param callback function called with each new value
981 * @param callback_cls closure for @a callback
982 * @return Handle to watch request
984 struct GNUNET_PEERSTORE_WatchContext *
985 GNUNET_PEERSTORE_watch (struct GNUNET_PEERSTORE_Handle *h,
986 const char *sub_system,
987 const struct GNUNET_PeerIdentity *peer, const char *key,
988 GNUNET_PEERSTORE_Processor callback, void *callback_cls)
990 struct GNUNET_MQ_Envelope *ev;
991 struct StoreKeyHashMessage *hm;
992 struct GNUNET_PEERSTORE_WatchContext *wc;
994 GNUNET_assert (NULL != sub_system);
995 GNUNET_assert (NULL != peer);
996 GNUNET_assert (NULL != key);
997 ev = GNUNET_MQ_msg (hm, GNUNET_MESSAGE_TYPE_PEERSTORE_WATCH);
998 PEERSTORE_hash_key (sub_system, peer, key, &hm->keyhash);
999 wc = GNUNET_new (struct GNUNET_PEERSTORE_WatchContext);
1001 wc->callback = callback;
1002 wc->callback_cls = callback_cls;
1005 wc->request_sent = GNUNET_NO;
1006 wc->keyhash = hm->keyhash;
1007 if (NULL == h->watches)
1008 h->watches = GNUNET_CONTAINER_multihashmap_create (5, GNUNET_NO);
1009 GNUNET_CONTAINER_multihashmap_put (h->watches, &wc->keyhash, wc,
1010 GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE);
1011 LOG (GNUNET_ERROR_TYPE_DEBUG,
1012 "Sending a watch request for ss `%s', peer `%s', key `%s'.\n",
1013 sub_system, GNUNET_i2s (peer), key);
1014 GNUNET_MQ_notify_sent (ev, &watch_request_sent, wc);
1015 GNUNET_MQ_send (h->mq, ev);
1019 /* end of peerstore_api.c */