GNUnet  0.11.x
Data Structures | Macros | Typedefs | Enumerations | Functions
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 49 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 54 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 60 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 67 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 73 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 79 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 85 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 165 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 175 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 92 of file gnunet_peerstore_service.h.

93 {
98 
104 };
@ 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 421 of file peerstore_api.c.

422 {
423  struct GNUNET_PEERSTORE_Handle *h;
424 
426  h->cfg = cfg;
427  h->disconnecting = GNUNET_NO;
428  reconnect (h);
429  if (NULL == h->mq)
430  {
431  GNUNET_free (h);
432  return NULL;
433  }
434  return h;
435 }
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
Definition: gnunet_common.h:94
#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 447 of file peerstore_api.c.

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");
470  h->disconnecting = GNUNET_YES;
471  return;
472  }
473  while (NULL != (sc = h->store_head))
475  }
477 }
static struct GNUNET_FS_SearchContext * sc
Definition: gnunet-search.c:37
@ GNUNET_YES
Definition: gnunet_common.h:97
int GNUNET_CONTAINER_multihashmap_iterate(struct GNUNET_CONTAINER_MultiHashMap *map, GNUNET_CONTAINER_MulitHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map.
void GNUNET_CONTAINER_multihashmap_destroy(struct GNUNET_CONTAINER_MultiHashMap *map)
Destroy a hash map.
#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 522 of file peerstore_api.c.

532 {
533  struct GNUNET_MQ_Envelope *ev;
535 
537  "Storing value (size: %lu) for subsystem `%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 
564  GNUNET_CONTAINER_DLL_insert_tail (h->store_head, h->store_tail, sc);
566  GNUNET_MQ_send (h->mq, ev);
567  return sc;
568 }
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:355
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:787
#define GNUNET_MESSAGE_TYPE_PEERSTORE_STORE
Store request message.
static unsigned int size
Size of the "table".
Definition: peer.c:67
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:1597
struct GNUNET_FS_Handle * h
Handle to the global FS context.
Definition: fs_api.h:1514
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 491 of file peerstore_api.c.

492 {
493  struct GNUNET_PEERSTORE_Handle *h = sc->h;
494 
495  GNUNET_CONTAINER_DLL_remove (sc->h->store_head, sc->h->store_tail, sc);
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))
502 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.

References final_disconnect(), GNUNET_CONTAINER_DLL_remove, GNUNET_free, 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(), queue_destroy(), and update_backtalker_monotime().

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
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 699 of file peerstore_api.c.

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;
723  if (NULL != peer)
724  ic->peer = *peer;
725  if (NULL != key)
726  ic->key = GNUNET_strdup (key);
727  GNUNET_CONTAINER_DLL_insert_tail (h->iterate_head, h->iterate_tail, ic);
729  "Sending an iterate request for sub system `%s'\n",
730  sub_system);
731  GNUNET_MQ_send (h->mq, ev);
732  return ic;
733 }
#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 673 of file peerstore_api.c.

674 {
675  if (GNUNET_NO == ic->iterating)
676  {
678  GNUNET_free (ic->sub_system);
679  GNUNET_free (ic->key);
680  GNUNET_free (ic);
681  }
682  else
683  ic->callback = NULL;
684 }
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 904 of file peerstore_api.c.

910 {
911  struct GNUNET_MQ_Envelope *ev;
912  struct StoreKeyHashMessage *hm;
914 
916  PEERSTORE_hash_key (sub_system, peer, key, &hm->keyhash);
918  wc->callback = callback;
920  wc->h = h;
921  wc->keyhash = hm->keyhash;
922  if (NULL == h->watches)
925  h->watches,
926  &wc->keyhash,
927  wc,
930  "Sending a watch request for subsystem `%s', peer `%s', key `%s'.\n",
931  sub_system,
932  GNUNET_i2s (peer),
933  key);
934  GNUNET_MQ_send (h->mq, ev);
935  return wc;
936 }
@ GNUNET_OK
Definition: gnunet_common.h:95
struct GNUNET_CONTAINER_MultiHashMap * GNUNET_CONTAINER_multihashmap_create(unsigned int len, int do_not_copy_keys)
Create a multi hash map.
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.
@ GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE
Allow multiple values with the same key.
#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:67
#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 874 of file peerstore_api.c.

875 {
876  struct GNUNET_PEERSTORE_Handle *h = wc->h;
877  struct GNUNET_MQ_Envelope *ev;
878  struct StoreKeyHashMessage *hm;
879 
880  LOG (GNUNET_ERROR_TYPE_DEBUG, "Canceling watch.\n");
882  hm->keyhash = wc->keyhash;
883  GNUNET_MQ_send (h->mq, ev);
884  GNUNET_assert (
885  GNUNET_YES ==
886  GNUNET_CONTAINER_multihashmap_remove (h->watches, &wc->keyhash, wc));
887  GNUNET_free (wc);
888 }
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.
#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: