GNUnet  0.19.4
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 
141  struct GNUNET_PeerIdentity peer;
142 
146  size_t size;
147 
152 
157 };
158 
163 {
168 
173 
178 
182  char *sub_system;
183 
187  struct GNUNET_PeerIdentity peer;
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  {
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 =
309  GNUNET_SCHEDULER_add_delayed (h->reconnect_delay, &reconnect, h);
310  h->reconnect_delay = GNUNET_TIME_STD_BACKOFF (h->reconnect_delay);
311 }
312 
313 
319 static void
321 {
322  struct GNUNET_PEERSTORE_StoreContext *sc = cls;
324  void *cont_cls;
325 
326  if (NULL != sc)
327  {
328  cont = sc->cont;
329  cont_cls = sc->cont_cls;
331  if (NULL != cont)
333  }
334 }
335 
336 
337 /******************************************************************************/
338 /******************* CONNECTION FUNCTIONS *********************/
339 /******************************************************************************/
340 
341 
345 static void
346 handle_client_error (void *cls, enum GNUNET_MQ_Error error)
347 {
348  struct GNUNET_PEERSTORE_Handle *h = cls;
349 
351  "Received an error notification from MQ of type: %d\n",
352  error);
354 }
355 
356 
365 static int
366 rewatch_it (void *cls, const struct GNUNET_HashCode *key, void *value)
367 {
368  struct GNUNET_PEERSTORE_Handle *h = cls;
370  struct StoreKeyHashMessage *hm;
371  struct GNUNET_MQ_Envelope *ev;
372 
374  hm->keyhash = wc->keyhash;
375  GNUNET_MQ_send (h->mq, ev);
376  return GNUNET_YES;
377 }
378 
379 
388 static int
389 destroy_watch (void *cls, const struct GNUNET_HashCode *key, void *value)
390 {
392 
394  return GNUNET_YES;
395 }
396 
397 
405 static void
407 {
408  if (NULL != h->mq)
409  {
411  h->mq = NULL;
412  }
413  GNUNET_free (h);
414 }
415 
416 
425 {
426  struct GNUNET_PEERSTORE_Handle *h;
427 
429  h->cfg = cfg;
430  h->disconnecting = GNUNET_NO;
431  reconnect (h);
432  if (NULL == h->mq)
433  {
434  GNUNET_free (h);
435  return NULL;
436  }
437  return h;
438 }
439 
440 
449 void
451 {
454 
455  LOG (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting.\n");
456  if (NULL != h->watches)
457  {
460  h->watches = NULL;
461  }
462  while (NULL != (ic = h->iterate_head))
463  {
464  GNUNET_break (0);
466  }
467  if (NULL != h->store_head)
468  {
469  if (GNUNET_YES == sync_first)
470  {
472  "Delaying disconnection due to pending store requests.\n");
473  h->disconnecting = GNUNET_YES;
474  return;
475  }
476  while (NULL != (sc = h->store_head))
478  }
480 }
481 
482 
483 /******************************************************************************/
484 /******************* STORE FUNCTIONS *********************/
485 /******************************************************************************/
486 
487 
493 void
495 {
496  struct GNUNET_PEERSTORE_Handle *h = sc->h;
497 
499  "store cancel with sc %p \n",
500  sc);
501  GNUNET_CONTAINER_DLL_remove (sc->h->store_head, sc->h->store_tail, sc);
502  GNUNET_free (sc->sub_system);
503  GNUNET_free (sc->value);
504  GNUNET_free (sc->key);
505  GNUNET_free (sc);
507  "store cancel with sc %p is null\n",
508  sc);
509  if ((GNUNET_YES == h->disconnecting) && (NULL == h->store_head))
511 }
512 
513 
532  const char *sub_system,
533  const struct GNUNET_PeerIdentity *peer,
534  const char *key,
535  const void *value,
536  size_t size,
540  void *cont_cls)
541 {
542  struct GNUNET_MQ_Envelope *ev;
544 
546  "Storing value (size: %lu) for subsystem `%s', peer `%s', key `%s'\n",
547  size,
548  sub_system,
549  GNUNET_i2s (peer),
550  key);
551  ev =
553  peer,
554  key,
555  value,
556  size,
557  expiry,
558  options,
561 
562  sc->sub_system = GNUNET_strdup (sub_system);
563  sc->peer = *peer;
564  sc->key = GNUNET_strdup (key);
565  sc->value = GNUNET_memdup (value, size);
566  sc->size = size;
567  sc->expiry = expiry;
568  sc->options = options;
569  sc->cont = cont;
570  sc->cont_cls = cont_cls;
571  sc->h = h;
572 
573  GNUNET_CONTAINER_DLL_insert_tail (h->store_head, h->store_tail, sc);
575  GNUNET_MQ_send (h->mq, ev);
576  return sc;
577 }
578 
579 
580 /******************************************************************************/
581 /******************* ITERATE FUNCTIONS *********************/
582 /******************************************************************************/
583 
584 
591 static void
592 handle_iterate_end (void *cls, const struct GNUNET_MessageHeader *msg)
593 {
594  struct GNUNET_PEERSTORE_Handle *h = cls;
597  void *callback_cls;
598 
599  ic = h->iterate_head;
600  if (NULL == ic)
601  {
603  _ ("Unexpected iteration response, this should not happen.\n"));
605  return;
606  }
607  callback = ic->callback;
609  ic->iterating = GNUNET_NO;
611  /* NOTE: set this here and not after callback because callback may free h */
612  h->reconnect_delay = GNUNET_TIME_UNIT_ZERO;
613  if (NULL != callback)
614  callback (callback_cls, NULL, NULL);
615 }
616 
617 
625 static int
626 check_iterate_result (void *cls, const struct StoreRecordMessage *msg)
627 {
628  /* we defer validation to #handle_iterate_result */
629  return GNUNET_OK;
630 }
631 
632 
639 static void
640 handle_iterate_result (void *cls, const struct StoreRecordMessage *msg)
641 {
642  struct GNUNET_PEERSTORE_Handle *h = cls;
645  void *callback_cls;
647 
648  ic = h->iterate_head;
649  if (NULL == ic)
650  {
652  _ ("Unexpected iteration response, this should not happen.\n"));
654  return;
655  }
656  ic->iterating = GNUNET_YES;
657  callback = ic->callback;
658  callback_cls = ic->callback_cls;
659  if (NULL == callback)
660  return;
662  if (NULL == record)
663  {
664  callback (callback_cls,
665  NULL,
666  _ ("Received a malformed response from service."));
667  }
668  else
669  {
670  callback (callback_cls, record, NULL);
672  }
673 }
674 
675 
682 void
684 {
685  if (GNUNET_NO == ic->iterating)
686  {
688  GNUNET_free (ic->sub_system);
689  GNUNET_free (ic->key);
690  GNUNET_free (ic);
691  }
692  else
693  ic->callback = NULL;
694 }
695 
696 
699  const char *sub_system,
700  const struct GNUNET_PeerIdentity *peer,
701  const char *key,
703  void *callback_cls)
704 {
705  struct GNUNET_MQ_Envelope *ev;
707 
708  ev =
710  peer,
711  key,
712  NULL,
713  0,
715  0,
718  ic->callback = callback;
720  ic->h = h;
722  if (NULL != peer)
723  ic->peer = *peer;
724  if (NULL != key)
725  ic->key = GNUNET_strdup (key);
726  GNUNET_CONTAINER_DLL_insert_tail (h->iterate_head, h->iterate_tail, ic);
728  "Sending an iterate request for sub system `%s'\n",
729  sub_system);
730  GNUNET_MQ_send (h->mq, ev);
731  return ic;
732 }
733 
734 
735 /******************************************************************************/
736 /******************* WATCH FUNCTIONS *********************/
737 /******************************************************************************/
738 
745 static int
746 check_watch_record (void *cls, const struct StoreRecordMessage *msg)
747 {
748  /* we defer validation to #handle_watch_result */
749  return GNUNET_OK;
750 }
751 
752 
759 static void
760 handle_watch_record (void *cls, const struct StoreRecordMessage *msg)
761 {
762  struct GNUNET_PEERSTORE_Handle *h = cls;
764  struct GNUNET_HashCode keyhash;
766 
767  LOG (GNUNET_ERROR_TYPE_DEBUG, "Received a watch record from service.\n");
769  if (NULL == record)
770  {
772  return;
773  }
774  PEERSTORE_hash_key (record->sub_system, &record->peer, record->key, &keyhash);
775  // FIXME: what if there are multiple watches for the same key?
776  wc = GNUNET_CONTAINER_multihashmap_get (h->watches, &keyhash);
777  if (NULL == wc)
778  {
780  _ ("Received a watch result for a non existing watch.\n"));
783  return;
784  }
785  h->reconnect_delay = GNUNET_TIME_UNIT_ZERO;
786  if (NULL != wc->callback)
787  wc->callback (wc->callback_cls, record, NULL);
789 }
790 
791 
797 static void
798 reconnect (void *cls)
799 {
800  struct GNUNET_PEERSTORE_Handle *h = cls;
801  struct GNUNET_MQ_MessageHandler mq_handlers[] =
802  { GNUNET_MQ_hd_fixed_size (iterate_end,
804  struct GNUNET_MessageHeader,
805  h),
806  GNUNET_MQ_hd_var_size (iterate_result,
808  struct StoreRecordMessage,
809  h),
810  GNUNET_MQ_hd_var_size (watch_record,
812  struct StoreRecordMessage,
813  h),
815  struct GNUNET_MQ_Envelope *ev;
816 
817  h->reconnect_task = NULL;
818  LOG (GNUNET_ERROR_TYPE_DEBUG, "Reconnecting...\n");
820  "peerstore",
821  mq_handlers,
823  h);
824  if (NULL == h->mq)
825  {
826  h->reconnect_task =
827  GNUNET_SCHEDULER_add_delayed (h->reconnect_delay, &reconnect, h);
828  h->reconnect_delay = GNUNET_TIME_STD_BACKOFF (h->reconnect_delay);
829  return;
830  }
832  "Resending pending requests after reconnect.\n");
833  if (NULL != h->watches)
835  for (struct GNUNET_PEERSTORE_IterateContext *ic = h->iterate_head; NULL != ic;
836  ic = ic->next)
837  {
838  ev =
839  PEERSTORE_create_record_mq_envelope (ic->sub_system,
840  &ic->peer,
841  ic->key,
842  NULL,
843  0,
845  0,
847  GNUNET_MQ_send (h->mq, ev);
848  }
849  for (struct GNUNET_PEERSTORE_StoreContext *sc = h->store_head; NULL != sc;
850  sc = sc->next)
851  {
852  ev =
854  &sc->peer,
855  sc->key,
856  sc->value,
857  sc->size,
858  sc->expiry,
859  sc->options,
862  GNUNET_MQ_send (h->mq, ev);
863  }
864 }
865 
866 
872 void
874 {
875  struct GNUNET_PEERSTORE_Handle *h = wc->h;
876  struct GNUNET_MQ_Envelope *ev;
877  struct StoreKeyHashMessage *hm;
878 
879  LOG (GNUNET_ERROR_TYPE_DEBUG, "Canceling watch.\n");
881  hm->keyhash = wc->keyhash;
882  GNUNET_MQ_send (h->mq, ev);
883  GNUNET_assert (
884  GNUNET_YES ==
885  GNUNET_CONTAINER_multihashmap_remove (h->watches, &wc->keyhash, wc));
886  GNUNET_free (wc);
887 }
888 
889 
904  const char *sub_system,
905  const struct GNUNET_PeerIdentity *peer,
906  const char *key,
908  void *callback_cls)
909 {
910  struct GNUNET_MQ_Envelope *ev;
911  struct StoreKeyHashMessage *hm;
913 
915  PEERSTORE_hash_key (sub_system, peer, key, &hm->keyhash);
917  wc->callback = callback;
919  wc->h = h;
920  wc->keyhash = hm->keyhash;
921  if (NULL == h->watches)
924  h->watches,
925  &wc->keyhash,
926  wc,
929  "Sending a watch request for subsystem `%s', peer `%s', key `%s'.\n",
930  sub_system,
931  GNUNET_i2s (peer),
932  key);
933  GNUNET_MQ_send (h->mq, ev);
934  return wc;
935 }
936 
937 
938 /* end of peerstore_api.c */
struct GNUNET_GETOPT_CommandLineOption options[]
Definition: 002.c:5
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
Definition: gnunet-abd.c:36
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:99
static void record(void *cls, size_t data_size, const void *data)
Process recorded audio data.
struct GNUNET_HashCode key
The key used in the DHT.
static char * value
Value of the record to add/remove.
static struct GNUNET_FS_SearchContext * sc
Definition: gnunet-search.c:87
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
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
int GNUNET_CONTAINER_multihashmap_iterate(struct GNUNET_CONTAINER_MultiHashMap *map, GNUNET_CONTAINER_MultiHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map.
enum GNUNET_GenericReturnValue 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.
enum GNUNET_GenericReturnValue 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.
struct GNUNET_CONTAINER_MultiHashMap * GNUNET_CONTAINER_multihashmap_create(unsigned int len, int do_not_copy_keys)
Create a multi hash map.
void GNUNET_CONTAINER_multihashmap_destroy(struct GNUNET_CONTAINER_MultiHashMap *map)
Destroy a hash map.
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.
@ GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE
Allow multiple values with the same key.
#define GNUNET_log(kind,...)
@ GNUNET_OK
@ GNUNET_YES
@ GNUNET_NO
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
@ GNUNET_ERROR_TYPE_ERROR
@ GNUNET_ERROR_TYPE_DEBUG
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_free(ptr)
Wrapper around free.
#define GNUNET_memdup(buf, size)
Allocate and initialize a block of memory.
GNUNET_MQ_Error
Error codes for the queue.
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:304
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:77
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
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:638
#define GNUNET_MQ_hd_fixed_size(name, code, str, ctx)
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:683
struct GNUNET_PEERSTORE_Handle * GNUNET_PEERSTORE_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the PEERSTORE service.
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_PEERSTORE_store_cancel(struct GNUNET_PEERSTORE_StoreContext *sc)
Cancel a store request.
void GNUNET_PEERSTORE_iterate_cancel(struct GNUNET_PEERSTORE_IterateContext *ic)
Cancel an iterate request Please do not call after the iterate request is done.
GNUNET_PEERSTORE_StoreOption
Options for storing values in PEERSTORE.
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.
void GNUNET_PEERSTORE_disconnect(struct GNUNET_PEERSTORE_Handle *h, int sync_first)
Disconnect from the PEERSTORE service.
void GNUNET_PEERSTORE_watch_cancel(struct GNUNET_PEERSTORE_WatchContext *wc)
Cancel a watch request.
void(* GNUNET_PEERSTORE_Continuation)(void *cls, int success)
Continuation called with a status result.
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.
#define GNUNET_MESSAGE_TYPE_PEERSTORE_STORE
Store request message.
#define GNUNET_MESSAGE_TYPE_PEERSTORE_WATCH_CANCEL
Watch cancel request.
#define GNUNET_MESSAGE_TYPE_PEERSTORE_WATCH
Watch request.
#define GNUNET_MESSAGE_TYPE_PEERSTORE_ITERATE_RECORD
Iteration record message.
#define GNUNET_MESSAGE_TYPE_PEERSTORE_ITERATE
Iteration request.
#define GNUNET_MESSAGE_TYPE_PEERSTORE_WATCH_RECORD
Watch response.
#define GNUNET_MESSAGE_TYPE_PEERSTORE_ITERATE_END
Iteration end message.
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:1272
#define GNUNET_TIME_UNIT_ZERO
Relative time zero.
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:569
#define GNUNET_TIME_UNIT_FOREVER_ABS
Constant used to specify "forever".
#define GNUNET_TIME_STD_BACKOFF(r)
Perform our standard exponential back-off calculation, starting at 1 ms and then going by a factor of...
static unsigned int size
Size of the "table".
Definition: peer.c:68
IPC messages.
static int check_watch_record(void *cls, const struct StoreRecordMessage *msg)
When a watch record is received, validate it is well-formed.
static int destroy_watch(void *cls, const struct GNUNET_HashCode *key, void *value)
Iterator over watch requests to cancel them.
static void handle_client_error(void *cls, enum GNUNET_MQ_Error error)
Function called when we had trouble talking to the service.
static void handle_iterate_result(void *cls, const struct StoreRecordMessage *msg)
When a response for iterate request is received.
static void handle_iterate_end(void *cls, const struct GNUNET_MessageHeader *msg)
When a response for iterate request is received.
static void reconnect(void *cls)
Close the existing connection to PEERSTORE and reconnect.
static int rewatch_it(void *cls, const struct GNUNET_HashCode *key, void *value)
Iterator over previous watches to resend them.
static void store_request_sent(void *cls)
Callback after MQ envelope is sent.
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.
static void disconnect(struct GNUNET_PEERSTORE_Handle *h)
Disconnect from the peerstore service.
static void final_disconnect(struct GNUNET_PEERSTORE_Handle *h)
Kill the connection to the service.
static void handle_watch_record(void *cls, const struct StoreRecordMessage *msg)
When a watch record is received, process it.
#define LOG(kind,...)
Definition: peerstore_api.c:31
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.
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.
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.
struct GNUNET_PEERSTORE_Record * PEERSTORE_parse_record_message(const struct StoreRecordMessage *srm)
Parses a message carrying a record.
void PEERSTORE_destroy_record(struct GNUNET_PEERSTORE_Record *record)
Free any memory allocated for this record.
Helper peerstore functions.
#define _(String)
GNU gettext support macro.
Definition: platform.h:177
struct GNUNET_MQ_Handle * mq
Our connection to the ARM service.
Definition: arm_api.c:107
const struct GNUNET_CONFIGURATION_Handle * cfg
The configuration that we are using.
Definition: arm_api.c:112
struct GNUNET_SCHEDULER_Task * reconnect_task
ID of the reconnect task (if any).
Definition: arm_api.c:147
Internal representation of the hash map.
enum GNUNET_FS_SearchOptions options
Options for the search.
Definition: fs_api.h:1598
struct GNUNET_FS_Handle * h
Handle to the global FS context.
Definition: fs_api.h:1515
A 512-bit hashcode.
Handle to a message queue.
Definition: mq.c:87
Message handler for a specific message type.
Header for all communications.
Handle to the PEERSTORE service.
Definition: peerstore_api.c:41
struct GNUNET_PEERSTORE_IterateContext * iterate_tail
Tail of active ITERATE requests.
Definition: peerstore_api.c:70
struct GNUNET_MQ_Handle * mq
Message queue.
Definition: peerstore_api.c:50
int disconnecting
Are we in the process of disconnecting but need to sync first?
Definition: peerstore_api.c:90
struct GNUNET_TIME_Relative reconnect_delay
Delay until we try to reconnect.
Definition: peerstore_api.c:85
struct GNUNET_PEERSTORE_StoreContext * store_tail
Tail of active STORE requests.
Definition: peerstore_api.c:60
struct GNUNET_PEERSTORE_StoreContext * store_head
Head of active STORE requests.
Definition: peerstore_api.c:55
struct GNUNET_PEERSTORE_IterateContext * iterate_head
Head of active ITERATE requests.
Definition: peerstore_api.c:65
const struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition: peerstore_api.c:45
struct GNUNET_SCHEDULER_Task * reconnect_task
ID of the task trying to reconnect to the service.
Definition: peerstore_api.c:80
struct GNUNET_CONTAINER_MultiHashMap * watches
Hashmap of watch requests.
Definition: peerstore_api.c:75
Context for a iterate request.
char * sub_system
Which subsystem does the store?
void * callback_cls
Closure for callback.
int iterating
GNUNET_YES if we are currently processing records.
char * key
Key for the store operation.
GNUNET_PEERSTORE_Processor callback
Callback with each matching record.
struct GNUNET_PEERSTORE_IterateContext * prev
Kept in a DLL.
struct GNUNET_PEERSTORE_Handle * h
Handle to the PEERSTORE service.
struct GNUNET_PEERSTORE_IterateContext * next
Kept in a DLL.
struct GNUNET_PeerIdentity peer
Peer the store is for.
Single PEERSTORE record.
Context for a store request.
Definition: peerstore_api.c:97
char * sub_system
Which subsystem does the store?
enum GNUNET_PEERSTORE_StoreOption options
Options for the store operation.
void * value
Contains size bytes.
struct GNUNET_TIME_Absolute expiry
When does the value expire?
struct GNUNET_PEERSTORE_StoreContext * prev
Kept in a DLL.
void * cont_cls
Closure for cont.
struct GNUNET_PEERSTORE_StoreContext * next
Kept in a DLL.
size_t size
Number of bytes in value.
struct GNUNET_PEERSTORE_Handle * h
Handle to the PEERSTORE service.
GNUNET_PEERSTORE_Continuation cont
Continuation called with service response.
struct GNUNET_PeerIdentity peer
Peer the store is for.
char * key
Key for the store operation.
Context for a watch request.
struct GNUNET_PEERSTORE_WatchContext * next
Kept in a DLL.
void * callback_cls
Closure for callback.
struct GNUNET_HashCode keyhash
Hash of the combined key.
struct GNUNET_PEERSTORE_WatchContext * prev
Kept in a DLL.
GNUNET_PEERSTORE_Processor callback
Callback with each record received.
struct GNUNET_PEERSTORE_Handle * h
Handle to the PEERSTORE service.
The identity of the host (wraps the signing key of the peer).
Entry in list of pending tasks.
Definition: scheduler.c:136
Time for absolute times used by GNUnet, in microseconds.
Time for relative time used by GNUnet, in microseconds.
Message carrying record key hash.
Definition: peerstore.h:90
struct GNUNET_HashCode keyhash
Hash of a record key.
Definition: peerstore.h:104
Message carrying a PEERSTORE record message.
Definition: peerstore.h:37
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.