GNUnet  0.10.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...
 

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.

Referenced by handle_suggest(), handle_validation_challenge(), handle_validation_response(), peer_add(), and watch_cb().

◆ 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.

Referenced by store_pi().

◆ 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.

Referenced by handle_dv_box(), and update_backtalker_monotime().

◆ 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.

Referenced by handle_add_queue_message(), and handle_dv_learn().

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 150 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 160 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 74 of file gnunet_peerstore_service.h.

75 {
76 
81 
87 
88 };
Delete any previous values for the given key before storing the given value.
Possibly store multiple values under given key.

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

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

Referenced by GSF_connected_peer_init_(), libgnunet_plugin_ats2_simple_init(), and run().

423 {
424  struct GNUNET_PEERSTORE_Handle *h;
425 
426  h = GNUNET_new (struct GNUNET_PEERSTORE_Handle);
427  h->cfg = cfg;
429  reconnect (h);
430  if (NULL == h->mq)
431  {
432  GNUNET_free (h);
433  return NULL;
434  }
435  return h;
436 }
#define GNUNET_NO
Definition: gnunet_common.h:81
#define GNUNET_new(type)
Allocate a struct or union of the given type.
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:94
const struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition: peerstore_api.c:46
int disconnecting
Are we in the process of disconnecting but need to sync first?
Definition: peerstore_api.c:91
Handle to the PEERSTORE service.
Definition: peerstore_api.c:40
static void reconnect(void *cls)
Close the existing connection to PEERSTORE and reconnect.
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition: gnunet-arm.c:104
struct GNUNET_MQ_Handle * mq
Message queue.
Definition: peerstore_api.c:51
#define GNUNET_free(ptr)
Wrapper around free.
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 448 of file peerstore_api.c.

Referenced by do_shutdown(), GSF_connected_peer_done_(), libgnunet_plugin_ats2_simple_done(), and shutdown_task().

449 {
452 
453  LOG (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting.\n");
454  if (NULL != h->watches)
455  {
458  h->watches = NULL;
459  }
460  while (NULL != (ic = h->iterate_head))
461  {
462  GNUNET_break (0);
464  }
465  if (NULL != h->store_head)
466  {
467  if (GNUNET_YES == sync_first)
468  {
470  "Delaying disconnection due to pending store requests.\n");
472  return;
473  }
474  while (NULL != (sc = h->store_head))
476  }
477  final_disconnect (h);
478 }
struct GNUNET_PEERSTORE_IterateContext * iterate_head
Head of active ITERATE requests.
Definition: peerstore_api.c:66
#define LOG(kind,...)
Definition: peerstore_api.c:31
int GNUNET_CONTAINER_multihashmap_iterate(struct GNUNET_CONTAINER_MultiHashMap *map, GNUNET_CONTAINER_HashMapIterator it, void *it_cls)
Iterate over all entries in the map.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
Context for a store request.
Definition: peerstore_api.c:97
void GNUNET_CONTAINER_multihashmap_destroy(struct GNUNET_CONTAINER_MultiHashMap *map)
Destroy a hash map.
void GNUNET_PEERSTORE_store_cancel(struct GNUNET_PEERSTORE_StoreContext *sc)
Cancel a store request.
int disconnecting
Are we in the process of disconnecting but need to sync first?
Definition: peerstore_api.c:91
static void final_disconnect(struct GNUNET_PEERSTORE_Handle *h)
Kill the connection to the service.
static struct GNUNET_FS_SearchContext * sc
Definition: gnunet-search.c:37
static int destroy_watch(void *cls, const struct GNUNET_HashCode *key, void *value)
Iterator over watch requests to cancel them.
void GNUNET_PEERSTORE_iterate_cancel(struct GNUNET_PEERSTORE_IterateContext *ic)
Cancel an iterate request Please do not call after the iterate request is done.
#define GNUNET_YES
Definition: gnunet_common.h:80
struct GNUNET_PEERSTORE_StoreContext * store_head
Head of active STORE requests.
Definition: peerstore_api.c:56
struct GNUNET_CONTAINER_MultiHashMap * watches
Hashmap of watch requests.
Definition: peerstore_api.c:76
Context for a iterate request.
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 523 of file peerstore_api.c.

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

533 {
534  struct GNUNET_MQ_Envelope *ev;
536 
538  "Storing value (size: %lu) for subsytem `%s', peer `%s', key `%s'\n",
539  size,
540  sub_system,
541  GNUNET_i2s (peer),
542  key);
543  ev =
545  peer,
546  key,
547  value,
548  size,
549  expiry,
550  options,
553 
555  sc->peer = *peer;
556  sc->key = GNUNET_strdup (key);
557  sc->value = GNUNET_memdup (value, size);
558  sc->size = size;
559  sc->expiry = expiry;
560  sc->options = options;
561  sc->cont = cont;
562  sc->cont_cls = cont_cls;
563  sc->h = h;
564 
567  GNUNET_MQ_send (h->mq, ev);
568  return sc;
569 }
#define GNUNET_MESSAGE_TYPE_PEERSTORE_STORE
Store request message.
struct GNUNET_GETOPT_CommandLineOption options[]
Definition: 002.c:5
#define LOG(kind,...)
Definition: peerstore_api.c:31
static void store_request_sent(void *cls)
Callback after MQ envelope is sent.
#define GNUNET_memdup(buf, size)
Allocate and initialize a block of memory.
char * sub_system
Which subsystem does the store?
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:94
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.
Context for a store request.
Definition: peerstore_api.c:97
struct GNUNET_PEERSTORE_StoreContext * store_tail
Tail of active STORE requests.
Definition: peerstore_api.c:61
void * cont_cls
Closure for cont.
void * value
Contains size bytes.
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
struct GNUNET_MQ_Handle * mq
Message queue.
Definition: peerstore_api.c:51
#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_TIME_Absolute expiry
When does the value expire?
size_t size
Number of bytes in value.
struct GNUNET_PeerIdentity peer
Peer the store is for.
GNUNET_PEERSTORE_Continuation cont
Continuation called with service response.
enum GNUNET_PEERSTORE_StoreOption options
Options for the store operation.
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
struct GNUNET_PEERSTORE_StoreContext * store_head
Head of active STORE requests.
Definition: peerstore_api.c:56
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
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 492 of file peerstore_api.c.

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

493 {
494  struct GNUNET_PEERSTORE_Handle *h = sc->h;
495 
497  GNUNET_free (sc->sub_system);
498  GNUNET_free (sc->value);
499  GNUNET_free (sc->key);
500  GNUNET_free (sc);
501  if ((GNUNET_YES == h->disconnecting) && (NULL == h->store_head))
502  final_disconnect (h);
503 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
char * sub_system
Which subsystem does the store?
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:94
struct GNUNET_PEERSTORE_Handle * h
Handle to the PEERSTORE service.
struct GNUNET_PEERSTORE_StoreContext * store_tail
Tail of active STORE requests.
Definition: peerstore_api.c:61
void * value
Contains size bytes.
int disconnecting
Are we in the process of disconnecting but need to sync first?
Definition: peerstore_api.c:91
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.
#define GNUNET_YES
Definition: gnunet_common.h:80
struct GNUNET_PEERSTORE_StoreContext * store_head
Head of active STORE requests.
Definition: peerstore_api.c:56
#define GNUNET_free(ptr)
Wrapper around free.
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 700 of file peerstore_api.c.

Referenced by GSF_peer_connect_handler(), handle_add_queue_message(), and handle_dv_box().

706 {
707  struct GNUNET_MQ_Envelope *ev;
709 
710  ev =
712  peer,
713  key,
714  NULL,
715  0,
717  0,
720  ic->callback = callback;
722  ic->h = h;
724  if (NULL != peer)
725  ic->peer = *peer;
726  if (NULL != key)
727  ic->key = GNUNET_strdup (key);
730  "Sending an iterate request for sub system `%s'\n",
731  sub_system);
732  GNUNET_MQ_send (h->mq, ev);
733  return ic;
734 }
struct GNUNET_PEERSTORE_IterateContext * iterate_head
Head of active ITERATE requests.
Definition: peerstore_api.c:66
struct GNUNET_PEERSTORE_IterateContext * iterate_tail
Tail of active ITERATE requests.
Definition: peerstore_api.c:71
struct GNUNET_PEERSTORE_Handle * h
Handle to the PEERSTORE service.
#define LOG(kind,...)
Definition: peerstore_api.c:31
struct GNUNET_PeerIdentity peer
Peer the store is for.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_MESSAGE_TYPE_PEERSTORE_ITERATE
Iteration request.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:94
#define GNUNET_TIME_UNIT_FOREVER_ABS
Constant used to specify "forever".
GNUNET_PEERSTORE_Processor callback
Callback with each matching record.
void * callback_cls
Closure for callback.
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.
struct GNUNET_MQ_Handle * mq
Message queue.
Definition: peerstore_api.c:51
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
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
Context for a iterate request.
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 674 of file peerstore_api.c.

References GNUNET_PEERSTORE_IterateContext::callback, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_free_non_null, 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(), GSF_peer_disconnect_handler(), handle_iterate_end(), and peer_respect_cb().

675 {
676  if (GNUNET_NO == ic->iterating)
677  {
679  GNUNET_free (ic->sub_system);
681  GNUNET_free (ic);
682  }
683  else
684  ic->callback = NULL;
685 }
#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:66
struct GNUNET_PEERSTORE_IterateContext * iterate_tail
Tail of active ITERATE requests.
Definition: peerstore_api.c:71
struct GNUNET_PEERSTORE_Handle * h
Handle to the PEERSTORE service.
#define GNUNET_NO
Definition: gnunet_common.h:81
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
GNUNET_PEERSTORE_Processor callback
Callback with each matching record.
char * sub_system
Which subsystem does the store?
char * key
Key for the store operation.
int iterating
GNUNET_YES if we are currently processing records.
#define GNUNET_free(ptr)
Wrapper around free.
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 900 of file peerstore_api.c.

Referenced by handle_suggest(), handle_validation_challenge(), and peer_add().

906 {
907  struct GNUNET_MQ_Envelope *ev;
908  struct StoreKeyHashMessage *hm;
910 
912  PEERSTORE_hash_key (sub_system, peer, key, &hm->keyhash);
914  wc->callback = callback;
916  wc->h = h;
917  wc->keyhash = hm->keyhash;
918  if (NULL == h->watches)
921  h->watches,
922  &wc->keyhash,
923  wc,
926  "Sending a watch request for subsystem `%s', peer `%s', key `%s'.\n",
927  sub_system,
928  GNUNET_i2s (peer),
929  key);
930  GNUNET_MQ_send (h->mq, ev);
931  return wc;
932 }
GNUNET_PEERSTORE_Processor callback
Callback with each record received.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
void * callback_cls
Closure for callback.
#define LOG(kind,...)
Definition: peerstore_api.c:31
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
#define GNUNET_NO
Definition: gnunet_common.h:81
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
#define GNUNET_new(type)
Allocate a struct or union of the given type.
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:94
struct GNUNET_HashCode keyhash
Hash of the combined key.
struct GNUNET_HashCode keyhash
Hash of a record key.
Definition: peerstore.h:107
struct GNUNET_PEERSTORE_Handle * h
Handle to the PEERSTORE service.
Context for a 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.
#define GNUNET_MESSAGE_TYPE_PEERSTORE_WATCH
Watch request.
struct GNUNET_HashCode key
The key used in the DHT.
struct GNUNET_MQ_Handle * mq
Message queue.
Definition: peerstore_api.c:51
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.
Allow multiple values with the same key.
Message carrying record key hash.
Definition: peerstore.h:91
struct GNUNET_CONTAINER_MultiHashMap * GNUNET_CONTAINER_multihashmap_create(unsigned int len, int do_not_copy_keys)
Create a multi hash map.
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
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
struct GNUNET_CONTAINER_MultiHashMap * watches
Hashmap of watch requests.
Definition: peerstore_api.c:76
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 870 of file peerstore_api.c.

Referenced by free_incoming_request(), peer_free(), and stop_peer_request().

871 {
872  struct GNUNET_PEERSTORE_Handle *h = wc->h;
873  struct GNUNET_MQ_Envelope *ev;
874  struct StoreKeyHashMessage *hm;
875 
876  LOG (GNUNET_ERROR_TYPE_DEBUG, "Canceling watch.\n");
878  hm->keyhash = wc->keyhash;
879  GNUNET_MQ_send (h->mq, ev);
880  GNUNET_assert (
881  GNUNET_YES ==
883  GNUNET_free (wc);
884 }
#define GNUNET_MESSAGE_TYPE_PEERSTORE_WATCH_CANCEL
Watch cancel request.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define LOG(kind,...)
Definition: peerstore_api.c:31
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:94
struct GNUNET_HashCode keyhash
Hash of the combined key.
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:107
struct GNUNET_PEERSTORE_Handle * h
Handle to the PEERSTORE service.
Handle to the PEERSTORE service.
Definition: peerstore_api.c:40
struct GNUNET_MQ_Handle * mq
Message queue.
Definition: peerstore_api.c:51
Message carrying record key hash.
Definition: peerstore.h:91
#define GNUNET_YES
Definition: gnunet_common.h:80
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
struct GNUNET_CONTAINER_MultiHashMap * watches
Hashmap of watch requests.
Definition: peerstore_api.c:76
#define GNUNET_free(ptr)
Wrapper around free.
Here is the caller graph for this function: