GNUnet  0.11.x
peerstore_api.c
Go to the documentation of this file.
1 /*
2  This file is part of GNUnet.
3  Copyright (C) 2013-2016, 2019 GNUnet e.V.
4 
5  GNUnet is free software: you can redistribute it and/or modify it
6  under the terms of the GNU Affero General Public License as published
7  by the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
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  Affero General Public License for more details.
14 
15  You should have received a copy of the GNU Affero General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17 
18  SPDX-License-Identifier: AGPL3.0-or-later
19  */
26 #include "platform.h"
27 #include "gnunet_util_lib.h"
28 #include "peerstore.h"
29 #include "peerstore_common.h"
30 
31 #define LOG(kind, ...) GNUNET_log_from (kind, "peerstore-api", __VA_ARGS__)
32 
33 /******************************************************************************/
34 /************************ DATA STRUCTURES ****************************/
35 /******************************************************************************/
36 
41 {
46 
51 
56 
61 
66 
71 
76 
81 
86 
91 };
92 
97 {
102 
107 
112 
117 
121  void *cont_cls;
122 
126  char *sub_system;
127 
131  char *key;
132 
136  void *value;
137 
142 
146  size_t size;
147 
151  struct GNUNET_TIME_Absolute expiry;
152 
157 };
158 
163 {
168 
173 
178 
182  char *sub_system;
183 
188 
192  char *key;
193 
198 
203 
208 };
209 
214 {
219 
224 
229 
234 
239 
243  struct GNUNET_HashCode keyhash;
244 };
245 
246 /******************************************************************************/
247 /******************* DECLARATIONS *********************/
248 /******************************************************************************/
249 
255 static void
256 reconnect (void *cls);
257 
258 
264 static void
266 {
268 
269  for (struct GNUNET_PEERSTORE_IterateContext *ic = h->iterate_head; NULL != ic;
270  ic = next)
271  {
272  next = ic->next;
273  if (GNUNET_YES == ic->iterating)
274  {
276  void *icb_cls;
277 
278  icb = ic->callback;
279  icb_cls = ic->callback_cls;
281  if (NULL != icb)
282  icb (icb_cls, NULL, "Iteration canceled due to reconnection");
283  }
284  }
285 
286  if (NULL != h->mq)
287  {
288  GNUNET_MQ_destroy (h->mq);
289  h->mq = NULL;
290  }
291 }
292 
293 
300 static void
302 {
303  GNUNET_assert (NULL == h->reconnect_task);
304  disconnect (h);
306  "Scheduling task to reconnect to PEERSTORE service in %s.\n",
308  h->reconnect_task =
311 }
312 
313 
319 static void
321 {
322  struct GNUNET_PEERSTORE_StoreContext *sc = cls;
324  void *cont_cls;
325 
326  cont = sc->cont;
327  cont_cls = sc->cont_cls;
329  if (NULL != cont)
330  cont (cont_cls, GNUNET_OK);
331 }
332 
333 
334 /******************************************************************************/
335 /******************* CONNECTION FUNCTIONS *********************/
336 /******************************************************************************/
337 
338 
342 static void
343 handle_client_error (void *cls, enum GNUNET_MQ_Error error)
344 {
345  struct GNUNET_PEERSTORE_Handle *h = cls;
346 
348  "Received an error notification from MQ of type: %d\n",
349  error);
351 }
352 
353 
362 static int
363 rewatch_it (void *cls, const struct GNUNET_HashCode *key, void *value)
364 {
365  struct GNUNET_PEERSTORE_Handle *h = cls;
367  struct StoreKeyHashMessage *hm;
368  struct GNUNET_MQ_Envelope *ev;
369 
371  hm->keyhash = wc->keyhash;
372  GNUNET_MQ_send (h->mq, ev);
373  return GNUNET_YES;
374 }
375 
376 
385 static int
386 destroy_watch (void *cls, const struct GNUNET_HashCode *key, void *value)
387 {
389 
391  return GNUNET_YES;
392 }
393 
394 
402 static void
404 {
405  if (NULL != h->mq)
406  {
407  GNUNET_MQ_destroy (h->mq);
408  h->mq = NULL;
409  }
410  GNUNET_free (h);
411 }
412 
413 
422 {
423  struct GNUNET_PEERSTORE_Handle *h;
424 
425  h = GNUNET_new (struct GNUNET_PEERSTORE_Handle);
426  h->cfg = cfg;
428  reconnect (h);
429  if (NULL == h->mq)
430  {
431  GNUNET_free (h);
432  return NULL;
433  }
434  return h;
435 }
436 
437 
446 void
448 {
451 
452  LOG (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting.\n");
453  if (NULL != h->watches)
454  {
457  h->watches = NULL;
458  }
459  while (NULL != (ic = h->iterate_head))
460  {
461  GNUNET_break (0);
463  }
464  if (NULL != h->store_head)
465  {
466  if (GNUNET_YES == sync_first)
467  {
469  "Delaying disconnection due to pending store requests.\n");
471  return;
472  }
473  while (NULL != (sc = h->store_head))
475  }
476  final_disconnect (h);
477 }
478 
479 
480 /******************************************************************************/
481 /******************* STORE FUNCTIONS *********************/
482 /******************************************************************************/
483 
484 
490 void
492 {
493  struct GNUNET_PEERSTORE_Handle *h = sc->h;
494 
496  GNUNET_free (sc->sub_system);
497  GNUNET_free (sc->value);
498  GNUNET_free (sc->key);
499  GNUNET_free (sc);
500  if ((GNUNET_YES == h->disconnecting) && (NULL == h->store_head))
501  final_disconnect (h);
502 }
503 
504 
523  const char *sub_system,
524  const struct GNUNET_PeerIdentity *peer,
525  const char *key,
526  const void *value,
527  size_t size,
531  void *cont_cls)
532 {
533  struct GNUNET_MQ_Envelope *ev;
535 
537  "Storing value (size: %lu) for subsytem `%s', peer `%s', key `%s'\n",
538  size,
539  sub_system,
540  GNUNET_i2s (peer),
541  key);
542  ev =
544  peer,
545  key,
546  value,
547  size,
548  expiry,
549  options,
552 
553  sc->sub_system = GNUNET_strdup (sub_system);
554  sc->peer = *peer;
555  sc->key = GNUNET_strdup (key);
556  sc->value = GNUNET_memdup (value, size);
557  sc->size = size;
558  sc->expiry = expiry;
559  sc->options = options;
560  sc->cont = cont;
561  sc->cont_cls = cont_cls;
562  sc->h = h;
563 
566  GNUNET_MQ_send (h->mq, ev);
567  return sc;
568 }
569 
570 
571 /******************************************************************************/
572 /******************* ITERATE FUNCTIONS *********************/
573 /******************************************************************************/
574 
575 
582 static void
583 handle_iterate_end (void *cls, const struct GNUNET_MessageHeader *msg)
584 {
585  struct GNUNET_PEERSTORE_Handle *h = cls;
588  void *callback_cls;
589 
590  ic = h->iterate_head;
591  if (NULL == ic)
592  {
594  _ ("Unexpected iteration response, this should not happen.\n"));
596  return;
597  }
598  callback = ic->callback;
599  callback_cls = ic->callback_cls;
600  ic->iterating = GNUNET_NO;
602  if (NULL != callback)
603  callback (callback_cls, NULL, NULL);
605 }
606 
607 
615 static int
616 check_iterate_result (void *cls, const struct StoreRecordMessage *msg)
617 {
618  /* we defer validation to #handle_iterate_result */
619  return GNUNET_OK;
620 }
621 
622 
629 static void
630 handle_iterate_result (void *cls, const struct StoreRecordMessage *msg)
631 {
632  struct GNUNET_PEERSTORE_Handle *h = cls;
635  void *callback_cls;
637 
638  ic = h->iterate_head;
639  if (NULL == ic)
640  {
642  _ ("Unexpected iteration response, this should not happen.\n"));
644  return;
645  }
646  ic->iterating = GNUNET_YES;
647  callback = ic->callback;
648  callback_cls = ic->callback_cls;
649  if (NULL == callback)
650  return;
651  record = PEERSTORE_parse_record_message (msg);
652  if (NULL == record)
653  {
654  callback (callback_cls,
655  NULL,
656  _ ("Received a malformed response from service."));
657  }
658  else
659  {
660  callback (callback_cls, record, NULL);
661  PEERSTORE_destroy_record (record);
662  }
663 }
664 
665 
672 void
674 {
675  if (GNUNET_NO == ic->iterating)
676  {
678  GNUNET_free (ic->sub_system);
680  GNUNET_free (ic);
681  }
682  else
683  ic->callback = NULL;
684 }
685 
686 
700  const char *sub_system,
701  const struct GNUNET_PeerIdentity *peer,
702  const char *key,
704  void *callback_cls)
705 {
706  struct GNUNET_MQ_Envelope *ev;
708 
709  ev =
711  peer,
712  key,
713  NULL,
714  0,
716  0,
719  ic->callback = callback;
721  ic->h = h;
722  ic->sub_system = GNUNET_strdup (sub_system);
723  if (NULL != peer)
724  ic->peer = *peer;
725  if (NULL != key)
726  ic->key = GNUNET_strdup (key);
729  "Sending an iterate request for sub system `%s'\n",
730  sub_system);
731  GNUNET_MQ_send (h->mq, ev);
732  return ic;
733 }
734 
735 
736 /******************************************************************************/
737 /******************* WATCH FUNCTIONS *********************/
738 /******************************************************************************/
739 
746 static int
747 check_watch_record (void *cls, const struct StoreRecordMessage *msg)
748 {
749  /* we defer validation to #handle_watch_result */
750  return GNUNET_OK;
751 }
752 
753 
760 static void
761 handle_watch_record (void *cls, const struct StoreRecordMessage *msg)
762 {
763  struct GNUNET_PEERSTORE_Handle *h = cls;
765  struct GNUNET_HashCode keyhash;
767 
768  LOG (GNUNET_ERROR_TYPE_DEBUG, "Received a watch record from service.\n");
769  record = PEERSTORE_parse_record_message (msg);
770  if (NULL == record)
771  {
773  return;
774  }
775  PEERSTORE_hash_key (record->sub_system, &record->peer, record->key, &keyhash);
776  // FIXME: what if there are multiple watches for the same key?
777  wc = GNUNET_CONTAINER_multihashmap_get (h->watches, &keyhash);
778  if (NULL == wc)
779  {
781  _ ("Received a watch result for a non existing watch.\n"));
782  PEERSTORE_destroy_record (record);
784  return;
785  }
786  if (NULL != wc->callback)
787  wc->callback (wc->callback_cls, record, NULL);
789  PEERSTORE_destroy_record (record);
790 }
791 
792 
798 static void
799 reconnect (void *cls)
800 {
801  struct GNUNET_PEERSTORE_Handle *h = cls;
802  struct GNUNET_MQ_MessageHandler mq_handlers[] =
803  { GNUNET_MQ_hd_fixed_size (iterate_end,
805  struct GNUNET_MessageHeader,
806  h),
807  GNUNET_MQ_hd_var_size (iterate_result,
809  struct StoreRecordMessage,
810  h),
811  GNUNET_MQ_hd_var_size (watch_record,
813  struct StoreRecordMessage,
814  h),
816  struct GNUNET_MQ_Envelope *ev;
817 
818  h->reconnect_task = NULL;
819  LOG (GNUNET_ERROR_TYPE_DEBUG, "Reconnecting...\n");
820  h->mq = GNUNET_CLIENT_connect (h->cfg,
821  "peerstore",
822  mq_handlers,
824  h);
825  if (NULL == h->mq)
826  return;
828  "Resending pending requests after reconnect.\n");
829  if (NULL != h->watches)
831  for (struct GNUNET_PEERSTORE_IterateContext *ic = h->iterate_head; NULL != ic;
832  ic = ic->next)
833  {
834  ev =
835  PEERSTORE_create_record_mq_envelope (ic->sub_system,
836  &ic->peer,
837  ic->key,
838  NULL,
839  0,
841  0,
843  GNUNET_MQ_send (h->mq, ev);
844  }
845  for (struct GNUNET_PEERSTORE_StoreContext *sc = h->store_head; NULL != sc;
846  sc = sc->next)
847  {
848  ev =
850  &sc->peer,
851  sc->key,
852  sc->value,
853  sc->size,
854  sc->expiry,
855  sc->options,
858  GNUNET_MQ_send (h->mq, ev);
859  }
860 }
861 
862 
868 void
870 {
871  struct GNUNET_PEERSTORE_Handle *h = wc->h;
872  struct GNUNET_MQ_Envelope *ev;
873  struct StoreKeyHashMessage *hm;
874 
875  LOG (GNUNET_ERROR_TYPE_DEBUG, "Canceling watch.\n");
877  hm->keyhash = wc->keyhash;
878  GNUNET_MQ_send (h->mq, ev);
879  GNUNET_assert (
880  GNUNET_YES ==
882  GNUNET_free (wc);
883 }
884 
885 
900  const char *sub_system,
901  const struct GNUNET_PeerIdentity *peer,
902  const char *key,
904  void *callback_cls)
905 {
906  struct GNUNET_MQ_Envelope *ev;
907  struct StoreKeyHashMessage *hm;
909 
911  PEERSTORE_hash_key (sub_system, peer, key, &hm->keyhash);
913  wc->callback = callback;
915  wc->h = h;
916  wc->keyhash = hm->keyhash;
917  if (NULL == h->watches)
920  h->watches,
921  &wc->keyhash,
922  wc,
925  "Sending a watch request for subsystem `%s', peer `%s', key `%s'.\n",
926  sub_system,
927  GNUNET_i2s (peer),
928  key);
929  GNUNET_MQ_send (h->mq, ev);
930  return wc;
931 }
932 
933 
934 /* end of peerstore_api.c */
struct GNUNET_PEERSTORE_WatchContext * prev
Kept in a DLL.
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
struct GNUNET_PEERSTORE_IterateContext * iterate_head
Head of active ITERATE requests.
Definition: peerstore_api.c:65
#define GNUNET_MESSAGE_TYPE_PEERSTORE_STORE
Store request message.
Helper peerstore functions.
static void handle_client_error(void *cls, enum GNUNET_MQ_Error error)
Function called when we had trouble talking to the service.
GNUNET_PEERSTORE_Processor callback
Callback with each record received.
void GNUNET_PEERSTORE_watch_cancel(struct GNUNET_PEERSTORE_WatchContext *wc)
Cancel a watch request.
void(* GNUNET_PEERSTORE_Processor)(void *cls, const struct GNUNET_PEERSTORE_Record *record, const char *emsg)
Function called by PEERSTORE for each matching record.
struct GNUNET_PEERSTORE_WatchContext * GNUNET_PEERSTORE_watch(struct GNUNET_PEERSTORE_Handle *h, const char *sub_system, const struct GNUNET_PeerIdentity *peer, const char *key, GNUNET_PEERSTORE_Processor callback, void *callback_cls)
Request watching a given key User will be notified with any new values added to key.
struct GNUNET_PEERSTORE_Record * PEERSTORE_parse_record_message(const struct StoreRecordMessage *srm)
Parses a message carrying a record.
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
struct GNUNET_PEERSTORE_StoreContext * next
Kept in a DLL.
static void handle_watch_record(void *cls, const struct StoreRecordMessage *msg)
When a watch record is received, process it.
struct GNUNET_PeerIdentity peer
Peer Identity.
struct GNUNET_GETOPT_CommandLineOption options[]
Definition: 002.c:5
void PEERSTORE_destroy_record(struct GNUNET_PEERSTORE_Record *record)
Free any memory allocated for this record.
struct GNUNET_MQ_Handle * GNUNET_CLIENT_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *service_name, const struct GNUNET_MQ_MessageHandler *handlers, GNUNET_MQ_ErrorHandler error_handler, void *error_handler_cls)
Create a message queue to connect to a GNUnet service.
Definition: client.c:1057
struct GNUNET_PEERSTORE_IterateContext * iterate_tail
Tail of active ITERATE requests.
Definition: peerstore_api.c:70
GNUNET_MQ_Error
Error codes for the queue.
struct GNUNET_PEERSTORE_IterateContext * GNUNET_PEERSTORE_iterate(struct GNUNET_PEERSTORE_Handle *h, const char *sub_system, const struct GNUNET_PeerIdentity *peer, const char *key, GNUNET_PEERSTORE_Processor callback, void *callback_cls)
Iterate over records matching supplied key information.
enum GNUNET_FS_SearchOptions options
Options for the search.
Definition: fs_api.h:1597
#define GNUNET_MESSAGE_TYPE_PEERSTORE_WATCH_CANCEL
Watch cancel request.
struct GNUNET_PEERSTORE_Handle * h
Handle to the PEERSTORE service.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
void * callback_cls
Closure for callback.
static void handle_iterate_end(void *cls, const struct GNUNET_MessageHeader *msg)
When a response for iterate request is received.
#define LOG(kind,...)
Definition: peerstore_api.c:31
static void store_request_sent(void *cls)
Callback after MQ envelope is sent.
#define GNUNET_MQ_hd_fixed_size(name, code, str, ctx)
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
struct GNUNET_PEERSTORE_IterateContext * prev
Kept in a DLL.
struct GNUNET_PeerIdentity peer
Peer the store is for.
#define GNUNET_NO
Definition: gnunet_common.h:78
#define GNUNET_memdup(buf, size)
Allocate and initialize a block of memory.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
char * sub_system
Which subsystem does the store?
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_MESSAGE_TYPE_PEERSTORE_ITERATE
Iteration request.
static int check_iterate_result(void *cls, const struct StoreRecordMessage *msg)
When a response for iterate request is received, check the message is well-formed.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
Internal representation of the hash map.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:99
#define GNUNET_MESSAGE_TYPE_PEERSTORE_WATCH_RECORD
Watch response.
#define GNUNET_TIME_UNIT_FOREVER_ABS
Constant used to specify "forever".
void * GNUNET_CONTAINER_multihashmap_get(const struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key)
Given a key find a value in the map matching the key.
#define _(String)
GNU gettext support macro.
Definition: platform.h:181
IPC messages.
#define GNUNET_MESSAGE_TYPE_PEERSTORE_ITERATE_RECORD
Iteration record message.
const struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition: peerstore_api.c:45
char * key
Record key string.
struct GNUNET_PEERSTORE_IterateContext * next
Kept in a DLL.
GNUNET_PEERSTORE_Processor callback
Callback with each matching record.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_delayed(struct GNUNET_TIME_Relative delay, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay.
Definition: scheduler.c:1253
struct GNUNET_HashCode keyhash
Hash of the combined key.
void GNUNET_MQ_notify_sent(struct GNUNET_MQ_Envelope *ev, GNUNET_SCHEDULER_TaskCallback cb, void *cb_cls)
Call a callback once the envelope has been sent, that is, sending it can not be canceled anymore...
Definition: mq.c:774
static char * value
Value of the record to add/remove.
struct GNUNET_PEERSTORE_Handle * h
Handle to the PEERSTORE service.
void * callback_cls
Closure for callback.
static int rewatch_it(void *cls, const struct GNUNET_HashCode *key, void *value)
Iterator over previous watches to resend them.
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
void GNUNET_PEERSTORE_disconnect(struct GNUNET_PEERSTORE_Handle *h, int sync_first)
Disconnect from the PEERSTORE service.
Context for a store request.
Definition: peerstore_api.c:96
struct GNUNET_PEERSTORE_StoreContext * GNUNET_PEERSTORE_store(struct GNUNET_PEERSTORE_Handle *h, const char *sub_system, const struct GNUNET_PeerIdentity *peer, const char *key, const void *value, size_t size, struct GNUNET_TIME_Absolute expiry, enum GNUNET_PEERSTORE_StoreOption options, GNUNET_PEERSTORE_Continuation cont, void *cont_cls)
Store a new entry in the PEERSTORE.
void GNUNET_CONTAINER_multihashmap_destroy(struct GNUNET_CONTAINER_MultiHashMap *map)
Destroy a hash map.
struct GNUNET_PEERSTORE_StoreContext * store_tail
Tail of active STORE requests.
Definition: peerstore_api.c:60
const char * GNUNET_STRINGS_relative_time_to_string(struct GNUNET_TIME_Relative delta, int do_round)
Give relative time in human-readable fancy format.
Definition: strings.c:687
void * cont_cls
Closure for cont.
static void disconnect(struct GNUNET_PEERSTORE_Handle *h)
Disconnect from the peerstore service.
int GNUNET_CONTAINER_multihashmap_remove(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, const void *value)
Remove the given key-value pair from the map.
struct GNUNET_HashCode keyhash
Hash of a record key.
Definition: peerstore.h:104
GNUNET_PEERSTORE_StoreOption
Options for storing values in PEERSTORE.
void GNUNET_PEERSTORE_store_cancel(struct GNUNET_PEERSTORE_StoreContext *sc)
Cancel a store request.
void * value
Contains size bytes.
struct GNUNET_PEERSTORE_Handle * h
Handle to the PEERSTORE service.
Context for a watch request.
int disconnecting
Are we in the process of disconnecting but need to sync first?
Definition: peerstore_api.c:90
Handle to the PEERSTORE service.
Definition: peerstore_api.c:40
static void final_disconnect(struct GNUNET_PEERSTORE_Handle *h)
Kill the connection to the service.
char * key
Key for the store operation.
A 512-bit hashcode.
void PEERSTORE_hash_key(const char *sub_system, const struct GNUNET_PeerIdentity *peer, const char *key, struct GNUNET_HashCode *ret)
Creates a hash of the given key combination.
static void reconnect(void *cls)
Close the existing connection to PEERSTORE and reconnect.
#define GNUNET_MESSAGE_TYPE_PEERSTORE_WATCH
Watch request.
Message handler for a specific message type.
char * sub_system
Which subsystem does the store?
char * key
Key for the store operation.
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
struct GNUNET_HashCode key
The key used in the DHT.
struct GNUNET_MQ_Envelope * PEERSTORE_create_record_mq_envelope(const char *sub_system, const struct GNUNET_PeerIdentity *peer, const char *key, const void *value, size_t value_size, struct GNUNET_TIME_Absolute expiry, enum GNUNET_PEERSTORE_StoreOption options, uint16_t msg_type)
Creates a MQ envelope for a single record.
static unsigned int size
Size of the "table".
Definition: peer.c:67
void(* GNUNET_PEERSTORE_Continuation)(void *cls, int success)
Continuation called with a status result.
struct GNUNET_MQ_Handle * mq
Message queue.
Definition: peerstore_api.c:50
struct GNUNET_PEERSTORE_Handle * GNUNET_PEERSTORE_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the PEERSTORE service.
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
static struct GNUNET_FS_SearchContext * sc
Definition: gnunet-search.c:37
struct GNUNET_PEERSTORE_StoreContext * prev
Kept in a DLL.
#define GNUNET_TIME_STD_BACKOFF(r)
Perform our standard exponential back-off calculation, starting at 1 ms and then going by a factor of...
int GNUNET_CONTAINER_multihashmap_put(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
#define GNUNET_MESSAGE_TYPE_PEERSTORE_ITERATE_END
Iteration end message.
#define GNUNET_TIME_UNIT_ZERO
Relative time zero.
Allow multiple values with the same key.
Handle to a message queue.
Definition: mq.c:85
The identity of the host (wraps the signing key of the peer).
struct GNUNET_TIME_Absolute expiry
When does the value expire?
size_t size
Number of bytes in value.
static int destroy_watch(void *cls, const struct GNUNET_HashCode *key, void *value)
Iterator over watch requests to cancel them.
configuration data
Definition: configuration.c:85
char * sub_system
Responsible sub system string.
struct GNUNET_PeerIdentity peer
Peer the store is for.
Single PEERSTORE record.
Entry in list of pending tasks.
Definition: scheduler.c:134
GNUNET_PEERSTORE_Continuation cont
Continuation called with service response.
static int check_watch_record(void *cls, const struct StoreRecordMessage *msg)
When a watch record is received, validate it is well-formed.
Message carrying record key hash.
Definition: peerstore.h:89
void GNUNET_PEERSTORE_iterate_cancel(struct GNUNET_PEERSTORE_IterateContext *ic)
Cancel an iterate request Please do not call after the iterate request is done.
struct GNUNET_PEERSTORE_WatchContext * next
Kept in a DLL.
static void record(void *cls, size_t data_size, const void *data)
Process recorded audio data.
struct GNUNET_CONTAINER_MultiHashMap * GNUNET_CONTAINER_multihashmap_create(unsigned int len, int do_not_copy_keys)
Create a multi hash map.
Message carrying a PEERSTORE record message.
Definition: peerstore.h:36
enum GNUNET_PEERSTORE_StoreOption options
Options for the store operation.
Header for all communications.
Time for absolute times used by GNUnet, in microseconds.
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:824
#define GNUNET_YES
Definition: gnunet_common.h:77
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition: mq.c:353
int iterating
GNUNET_YES if we are currently processing records.
static void disconnect_and_schedule_reconnect(struct GNUNET_PEERSTORE_Handle *h)
Function that will schedule the job that will try to connect us again to the client.
struct GNUNET_PEERSTORE_StoreContext * store_head
Head of active STORE requests.
Definition: peerstore_api.c:55
int GNUNET_CONTAINER_multihashmap_iterate(struct GNUNET_CONTAINER_MultiHashMap *map, GNUNET_CONTAINER_MulitHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map.
static void handle_iterate_result(void *cls, const struct StoreRecordMessage *msg)
When a response for iterate request is received.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
struct GNUNET_TIME_Relative reconnect_delay
Delay until we try to reconnect.
Definition: peerstore_api.c:85
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
struct GNUNET_CONTAINER_MultiHashMap * watches
Hashmap of watch requests.
Definition: peerstore_api.c:75
Context for a iterate request.
struct GNUNET_SCHEDULER_Task * reconnect_task
ID of the task trying to reconnect to the service.
Definition: peerstore_api.c:80
#define GNUNET_free(ptr)
Wrapper around free.
Time for relative time used by GNUnet, in microseconds.