GNUnet  0.20.0
Peer Store service
Collaboration diagram for Peer Store service:

Data Structures

struct  GNUNET_PEERSTORE_Record
 Single PEERSTORE record. More...
 

Macros

#define GNUNET_PEERSTORE_TRANSPORT_URLADDRESS_KEY   "transport-communicator-url"
 Key used for storing addresses in URL format in the peerstore. More...
 
#define GNUNET_PEERSTORE_TRANSPORT_HELLO_KEY   "transport-peer-hello"
 Key used for storing HELLOs in the peerstore. More...
 
#define GNUNET_PEERSTORE_TRANSPORT_BACKCHANNEL_MONOTIME    "transport-backchannel-monotonic-time"
 Key used to store sender's monotonic time from backchannel messages. More...
 
#define GNUNET_PEERSTORE_TRANSPORT_DVLEARN_MONOTIME    "transport-dv-learn-monotonic-time"
 Key used to store sender's monotonic time from DV learn messages. More...
 
#define GNUNET_PEERSTORE_TRANSPORT_TCP_COMMUNICATOR_HANDSHAKE    "transport-tcp-communicator-handshake"
 Key used to store sender's monotonic time from handshake message. More...
 
#define GNUNET_PEERSTORE_TRANSPORT_TCP_COMMUNICATOR_HANDSHAKE_ACK    "transport-tcp-communicator-handshake-ack"
 Key used to store sender's monotonic time from handshake ack message. More...
 
#define GNUNET_PEERSTORE_TRANSPORT_TCP_COMMUNICATOR_REKEY    "transport-tcp-communicator-rekey"
 Key used to store sender's monotonic time from rekey message. More...
 

Typedefs

typedef void(* GNUNET_PEERSTORE_Continuation) (void *cls, int success)
 Continuation called with a status result. More...
 
typedef void(* GNUNET_PEERSTORE_Processor) (void *cls, const struct GNUNET_PEERSTORE_Record *record, const char *emsg)
 Function called by PEERSTORE for each matching record. More...
 

Enumerations

enum  GNUNET_PEERSTORE_StoreOption { GNUNET_PEERSTORE_STOREOPTION_MULTIPLE = 0 , GNUNET_PEERSTORE_STOREOPTION_REPLACE = 1 }
 Options for storing values in PEERSTORE. More...
 

Functions

struct GNUNET_PEERSTORE_HandleGNUNET_PEERSTORE_connect (const struct GNUNET_CONFIGURATION_Handle *cfg)
 Connect to the PEERSTORE service. More...
 
void GNUNET_PEERSTORE_disconnect (struct GNUNET_PEERSTORE_Handle *h, int sync_first)
 Disconnect from the PEERSTORE service. More...
 
struct GNUNET_PEERSTORE_StoreContextGNUNET_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. More...
 
void GNUNET_PEERSTORE_store_cancel (struct GNUNET_PEERSTORE_StoreContext *sc)
 Cancel a store request. More...
 
struct GNUNET_PEERSTORE_IterateContextGNUNET_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. More...
 
void GNUNET_PEERSTORE_iterate_cancel (struct GNUNET_PEERSTORE_IterateContext *ic)
 Cancel an iterate request Please do not call after the iterate request is done. More...
 
struct GNUNET_PEERSTORE_WatchContextGNUNET_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. More...
 
void GNUNET_PEERSTORE_watch_cancel (struct GNUNET_PEERSTORE_WatchContext *wc)
 Cancel a watch request. More...
 

Detailed Description

See also
Documentation

Macro Definition Documentation

◆ GNUNET_PEERSTORE_TRANSPORT_URLADDRESS_KEY

#define GNUNET_PEERSTORE_TRANSPORT_URLADDRESS_KEY   "transport-communicator-url"

Key used for storing addresses in URL format in the peerstore.

Definition at line 53 of file gnunet_peerstore_service.h.

◆ GNUNET_PEERSTORE_TRANSPORT_HELLO_KEY

#define GNUNET_PEERSTORE_TRANSPORT_HELLO_KEY   "transport-peer-hello"

Key used for storing HELLOs in the peerstore.

Definition at line 58 of file gnunet_peerstore_service.h.

◆ GNUNET_PEERSTORE_TRANSPORT_BACKCHANNEL_MONOTIME

#define GNUNET_PEERSTORE_TRANSPORT_BACKCHANNEL_MONOTIME    "transport-backchannel-monotonic-time"

Key used to store sender's monotonic time from backchannel messages.

Definition at line 64 of file gnunet_peerstore_service.h.

◆ GNUNET_PEERSTORE_TRANSPORT_DVLEARN_MONOTIME

#define GNUNET_PEERSTORE_TRANSPORT_DVLEARN_MONOTIME    "transport-dv-learn-monotonic-time"

Key used to store sender's monotonic time from DV learn messages.

Definition at line 71 of file gnunet_peerstore_service.h.

◆ GNUNET_PEERSTORE_TRANSPORT_TCP_COMMUNICATOR_HANDSHAKE

#define GNUNET_PEERSTORE_TRANSPORT_TCP_COMMUNICATOR_HANDSHAKE    "transport-tcp-communicator-handshake"

Key used to store sender's monotonic time from handshake message.

Definition at line 77 of file gnunet_peerstore_service.h.

◆ GNUNET_PEERSTORE_TRANSPORT_TCP_COMMUNICATOR_HANDSHAKE_ACK

#define GNUNET_PEERSTORE_TRANSPORT_TCP_COMMUNICATOR_HANDSHAKE_ACK    "transport-tcp-communicator-handshake-ack"

Key used to store sender's monotonic time from handshake ack message.

Definition at line 83 of file gnunet_peerstore_service.h.

◆ GNUNET_PEERSTORE_TRANSPORT_TCP_COMMUNICATOR_REKEY

#define GNUNET_PEERSTORE_TRANSPORT_TCP_COMMUNICATOR_REKEY    "transport-tcp-communicator-rekey"

Key used to store sender's monotonic time from rekey message.

Definition at line 89 of file gnunet_peerstore_service.h.

Typedef Documentation

◆ GNUNET_PEERSTORE_Continuation

typedef void(* GNUNET_PEERSTORE_Continuation) (void *cls, int success)

Continuation called with a status result.

Parameters
clsclosure
successGNUNET_OK or GNUNET_SYSERR

Definition at line 169 of file gnunet_peerstore_service.h.

◆ GNUNET_PEERSTORE_Processor

typedef void(* GNUNET_PEERSTORE_Processor) (void *cls, const struct GNUNET_PEERSTORE_Record *record, const char *emsg)

Function called by PEERSTORE for each matching record.

Parameters
clsclosure
recordpeerstore record information
emsgerror message, or NULL if no errors

Definition at line 179 of file gnunet_peerstore_service.h.

Enumeration Type Documentation

◆ GNUNET_PEERSTORE_StoreOption

Options for storing values in PEERSTORE.

Enumerator
GNUNET_PEERSTORE_STOREOPTION_MULTIPLE 

Possibly store multiple values under given key.

GNUNET_PEERSTORE_STOREOPTION_REPLACE 

Delete any previous values for the given key before storing the given value.

Definition at line 96 of file gnunet_peerstore_service.h.

97 {
102 
108 };
@ GNUNET_PEERSTORE_STOREOPTION_MULTIPLE
Possibly store multiple values under given key.
@ GNUNET_PEERSTORE_STOREOPTION_REPLACE
Delete any previous values for the given key before storing the given value.

Function Documentation

◆ GNUNET_PEERSTORE_connect()

struct GNUNET_PEERSTORE_Handle* GNUNET_PEERSTORE_connect ( const struct GNUNET_CONFIGURATION_Handle cfg)

Connect to the PEERSTORE service.

Returns
NULL on error
Parameters
cfgconfiguration to use
Returns
NULL on error

Definition at line 424 of file peerstore_api.c.

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 }
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
@ GNUNET_NO
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_free(ptr)
Wrapper around free.
static void reconnect(void *cls)
Close the existing connection to PEERSTORE and reconnect.
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
Handle to the PEERSTORE service.
Definition: peerstore_api.c:41

References cfg, GNUNET_ARM_Handle::cfg, GNUNET_free, GNUNET_new, GNUNET_NO, h, GNUNET_ARM_Handle::mq, and reconnect().

Referenced by GNUNET_TRANSPORT_TESTING_start_peer(), GSF_connected_peer_init_(), run(), and start_peer_run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_PEERSTORE_disconnect()

void GNUNET_PEERSTORE_disconnect ( struct GNUNET_PEERSTORE_Handle h,
int  sync_first 
)

Disconnect from the PEERSTORE service.

Any pending ITERATE and WATCH requests will be canceled. Any pending STORE requests will depend on snyc_first flag.

Parameters
hhandle to disconnect
sync_firstsend any pending STORE requests before disconnecting

Definition at line 450 of file peerstore_api.c.

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 }
static struct GNUNET_FS_SearchContext * sc
Definition: gnunet-search.c:87
void GNUNET_CONTAINER_multihashmap_destroy(struct GNUNET_CONTAINER_MultiHashMap *map)
Destroy a hash map.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multihashmap_iterate(struct GNUNET_CONTAINER_MultiHashMap *map, GNUNET_CONTAINER_MultiHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map.
@ GNUNET_YES
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
@ GNUNET_ERROR_TYPE_DEBUG
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.
static int destroy_watch(void *cls, const struct GNUNET_HashCode *key, void *value)
Iterator over watch requests to cancel them.
static void final_disconnect(struct GNUNET_PEERSTORE_Handle *h)
Kill the connection to the service.
#define LOG(kind,...)
Definition: peerstore_api.c:31
Context for a iterate request.
Context for a store request.
Definition: peerstore_api.c:97

References destroy_watch(), final_disconnect(), GNUNET_break, GNUNET_CONTAINER_multihashmap_destroy(), GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_PEERSTORE_iterate_cancel(), GNUNET_PEERSTORE_store_cancel(), GNUNET_YES, h, LOG, and sc.

Referenced by do_shutdown(), GNUNET_TRANSPORT_TESTING_stop_peer(), GSF_connected_peer_done_(), shutdown_task(), and stop_peer_run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_PEERSTORE_store()

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.

Note that stored entries can be lost in some cases such as power failure.

Parameters
hHandle to the PEERSTORE service
sub_systemname of the sub system
peerPeer Identity
keyentry key
valueentry value BLOB
sizesize of value
expiryabsolute time after which the entry is (possibly) deleted
optionsoptions specific to the storage operation
contContinuation function after the store request is sent
cont_clsClosure for cont

Definition at line 531 of file peerstore_api.c.

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 }
struct GNUNET_GETOPT_CommandLineOption options[]
Definition: 002.c:5
struct GNUNET_HashCode key
The key used in the DHT.
static char * value
Value of the record to add/remove.
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define GNUNET_memdup(buf, size)
Allocate and initialize a block of memory.
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
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_MESSAGE_TYPE_PEERSTORE_STORE
Store request message.
static unsigned int size
Size of the "table".
Definition: peer.c:68
static void store_request_sent(void *cls)
Callback after MQ envelope is sent.
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.
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
char * sub_system
Which subsystem does the store?
struct GNUNET_TIME_Absolute expiry
When does the value expire?
void * cont_cls
Closure for cont.
GNUNET_PEERSTORE_Continuation cont
Continuation called with service response.
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.

References GNUNET_PEERSTORE_StoreContext::cont, GNUNET_PEERSTORE_StoreContext::cont_cls, GNUNET_PEERSTORE_StoreContext::expiry, GNUNET_CONTAINER_DLL_insert_tail, GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_memdup, GNUNET_MESSAGE_TYPE_PEERSTORE_STORE, GNUNET_MQ_notify_sent(), GNUNET_MQ_send(), GNUNET_new, GNUNET_strdup, h, GNUNET_FS_SearchContext::h, key, LOG, GNUNET_ARM_Handle::mq, options, GNUNET_FS_SearchContext::options, peer, PEERSTORE_create_record_mq_envelope(), sc, size, store_request_sent(), GNUNET_PEERSTORE_StoreContext::sub_system, and value.

Referenced by flush_respect(), handle_dv_learn(), handle_validation_response(), handshake_ack_monotime_cb(), handshake_monotime_cb(), rekey_monotime_cb(), store_pi(), and update_backtalker_monotime().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_PEERSTORE_store_cancel()

void GNUNET_PEERSTORE_store_cancel ( struct GNUNET_PEERSTORE_StoreContext sc)

Cancel a store request.

Parameters
scStore request context

Definition at line 494 of file peerstore_api.c.

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 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
#define GNUNET_log(kind,...)

References final_disconnect(), GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, GNUNET_YES, h, GNUNET_FS_SearchContext::h, and sc.

Referenced by free_address_list_entry(), free_backtalker(), free_neighbour(), free_validation_state(), handle_dv_learn(), and queue_destroy().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_PEERSTORE_iterate()

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.

Parameters
hhandle to the PEERSTORE service
sub_systemname of sub system
peerPeer identity (can be NULL)
keyentry key string (can be NULL)
callbackfunction called with each matching record, all NULL's on end
callback_clsclosure for callback
Returns
Handle to iteration request

Definition at line 698 of file peerstore_api.c.

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 }
#define GNUNET_MESSAGE_TYPE_PEERSTORE_ITERATE
Iteration request.
#define GNUNET_TIME_UNIT_FOREVER_ABS
Constant used to specify "forever".
char * sub_system
Which subsystem does the store?
void * callback_cls
Closure for callback.
char * key
Key for the store operation.
GNUNET_PEERSTORE_Processor callback
Callback with each matching record.
struct GNUNET_PEERSTORE_Handle * h
Handle to the PEERSTORE service.
struct GNUNET_PeerIdentity peer
Peer the store is for.

References GNUNET_PEERSTORE_IterateContext::callback, GNUNET_PEERSTORE_IterateContext::callback_cls, GNUNET_CONTAINER_DLL_insert_tail, GNUNET_ERROR_TYPE_DEBUG, GNUNET_MESSAGE_TYPE_PEERSTORE_ITERATE, GNUNET_MQ_send(), GNUNET_new, GNUNET_strdup, GNUNET_TIME_UNIT_FOREVER_ABS, h, GNUNET_PEERSTORE_IterateContext::h, key, GNUNET_PEERSTORE_IterateContext::key, LOG, GNUNET_ARM_Handle::mq, GNUNET_PEERSTORE_IterateContext::peer, peer, PEERSTORE_create_record_mq_envelope(), and GNUNET_PEERSTORE_IterateContext::sub_system.

Referenced by decrypt_and_check_tc(), do_rekey(), GNUNET_TRANSPORT_TESTING_restart_peer(), GSF_peer_connect_handler(), handle_add_queue_message(), handle_dv_box(), retrieve_hello(), and try_handle_plaintext().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_PEERSTORE_iterate_cancel()

void GNUNET_PEERSTORE_iterate_cancel ( struct GNUNET_PEERSTORE_IterateContext ic)

Cancel an iterate request Please do not call after the iterate request is done.

Parameters
icIterate request context as returned by GNUNET_PEERSTORE_iterate()

Definition at line 683 of file peerstore_api.c.

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 }
struct GNUNET_PEERSTORE_IterateContext * iterate_tail
Tail of active ITERATE requests.
Definition: peerstore_api.c:70
struct GNUNET_PEERSTORE_IterateContext * iterate_head
Head of active ITERATE requests.
Definition: peerstore_api.c:65
int iterating
GNUNET_YES if we are currently processing records.

References GNUNET_PEERSTORE_IterateContext::callback, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_NO, GNUNET_PEERSTORE_IterateContext::h, GNUNET_PEERSTORE_Handle::iterate_head, GNUNET_PEERSTORE_Handle::iterate_tail, GNUNET_PEERSTORE_IterateContext::iterating, GNUNET_PEERSTORE_IterateContext::key, and GNUNET_PEERSTORE_IterateContext::sub_system.

Referenced by disconnect(), free_backtalker(), free_neighbour(), GNUNET_PEERSTORE_disconnect(), GNUNET_TRANSPORT_TESTING_restart_peer(), GNUNET_TRANSPORT_TESTING_stop_peer(), GSF_peer_disconnect_handler(), handle_iterate_end(), hello_iter_cb(), peer_respect_cb(), queue_destroy(), and stop_peer_run().

Here is the caller graph for this function:

◆ GNUNET_PEERSTORE_watch()

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.

Parameters
hhandle to the PEERSTORE service
sub_systemname of sub system
peerPeer identity
keyentry key string
callbackfunction called with each new value
callback_clsclosure for callback
Returns
Handle to watch request

Definition at line 903 of file peerstore_api.c.

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 }
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.
@ GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE
Allow multiple values with the same key.
@ GNUNET_OK
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:78
#define GNUNET_MESSAGE_TYPE_PEERSTORE_WATCH
Watch request.
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.
Context for a watch request.
void * callback_cls
Closure for callback.
struct GNUNET_HashCode keyhash
Hash of the combined key.
GNUNET_PEERSTORE_Processor callback
Callback with each record received.
struct GNUNET_PEERSTORE_Handle * h
Handle to the PEERSTORE service.
Message carrying record key hash.
Definition: peerstore.h:90
struct GNUNET_HashCode keyhash
Hash of a record key.
Definition: peerstore.h:104

References GNUNET_PEERSTORE_WatchContext::callback, GNUNET_PEERSTORE_WatchContext::callback_cls, GNUNET_assert, GNUNET_CONTAINER_multihashmap_create(), GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE, GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_MESSAGE_TYPE_PEERSTORE_WATCH, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_new, GNUNET_NO, GNUNET_OK, h, GNUNET_PEERSTORE_WatchContext::h, key, StoreKeyHashMessage::keyhash, GNUNET_PEERSTORE_WatchContext::keyhash, LOG, GNUNET_ARM_Handle::mq, peer, and PEERSTORE_hash_key().

Referenced by handle_suggest(), and handle_validation_challenge().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_PEERSTORE_watch_cancel()

void GNUNET_PEERSTORE_watch_cancel ( struct GNUNET_PEERSTORE_WatchContext wc)

Cancel a watch request.

Parameters
wchandle to the watch request

Definition at line 873 of file peerstore_api.c.

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 }
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.
#define GNUNET_MESSAGE_TYPE_PEERSTORE_WATCH_CANCEL
Watch cancel request.

References GNUNET_assert, GNUNET_CONTAINER_multihashmap_remove(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_MESSAGE_TYPE_PEERSTORE_WATCH_CANCEL, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_YES, h, GNUNET_PEERSTORE_WatchContext::h, StoreKeyHashMessage::keyhash, GNUNET_PEERSTORE_WatchContext::keyhash, LOG, and GNUNET_ARM_Handle::mq.

Referenced by free_incoming_request(), and stop_peer_request().

Here is the call graph for this function:
Here is the caller graph for this function: