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 145 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 155 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.

74  {
79 
85 };
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 417 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().

418 {
419  struct GNUNET_PEERSTORE_Handle *h;
420 
422  h->cfg = cfg;
424  reconnect(h);
425  if (NULL == h->mq)
426  {
427  GNUNET_free(h);
428  return NULL;
429  }
430  return h;
431 }
#define GNUNET_NO
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
const struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition: peerstore_api.c:44
int disconnecting
Are we in the process of disconnecting but need to sync first?
Definition: peerstore_api.c:89
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:49
#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 443 of file peerstore_api.c.

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

444 {
447 
448  LOG(GNUNET_ERROR_TYPE_DEBUG, "Disconnecting.\n");
449  if (NULL != h->watches)
450  {
453  h->watches = NULL;
454  }
455  while (NULL != (ic = h->iterate_head))
456  {
457  GNUNET_break(0);
459  }
460  if (NULL != h->store_head)
461  {
462  if (GNUNET_YES == sync_first)
463  {
465  "Delaying disconnection due to pending store requests.\n");
467  return;
468  }
469  while (NULL != (sc = h->store_head))
471  }
472  final_disconnect(h);
473 }
struct GNUNET_PEERSTORE_IterateContext * iterate_head
Head of active ITERATE requests.
Definition: peerstore_api.c:64
#define LOG(kind,...)
Definition: peerstore_api.c:31
#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:95
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:89
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:77
struct GNUNET_PEERSTORE_StoreContext * store_head
Head of active STORE requests.
Definition: peerstore_api.c:54
int GNUNET_CONTAINER_multihashmap_iterate(struct GNUNET_CONTAINER_MultiHashMap *map, GNUNET_CONTAINER_MulitHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map.
struct GNUNET_CONTAINER_MultiHashMap * watches
Hashmap of watch requests.
Definition: peerstore_api.c:74
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 518 of file peerstore_api.c.

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

528 {
529  struct GNUNET_MQ_Envelope *ev;
531 
533  "Storing value (size: %lu) for subsytem `%s', peer `%s', key `%s'\n",
534  size,
535  sub_system,
536  GNUNET_i2s(peer),
537  key);
538  ev =
540  peer,
541  key,
542  value,
543  size,
544  expiry,
545  options,
548 
550  sc->peer = *peer;
551  sc->key = GNUNET_strdup(key);
552  sc->value = GNUNET_memdup(value, size);
553  sc->size = size;
554  sc->expiry = expiry;
555  sc->options = options;
556  sc->cont = cont;
557  sc->cont_cls = cont_cls;
558  sc->h = h;
559 
562  GNUNET_MQ_send(h->mq, ev);
563  return sc;
564 }
#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:772
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:95
struct GNUNET_PEERSTORE_StoreContext * store_tail
Tail of active STORE requests.
Definition: peerstore_api.c:59
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:66
struct GNUNET_MQ_Handle * mq
Message queue.
Definition: peerstore_api.c:49
#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:351
struct GNUNET_PEERSTORE_StoreContext * store_head
Head of active STORE requests.
Definition: peerstore_api.c:54
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 487 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().

488 {
489  struct GNUNET_PEERSTORE_Handle *h = sc->h;
490 
492  GNUNET_free(sc->sub_system);
493  GNUNET_free(sc->value);
494  GNUNET_free(sc->key);
495  GNUNET_free(sc);
496  if ((GNUNET_YES == h->disconnecting) && (NULL == h->store_head))
497  final_disconnect(h);
498 }
#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:59
void * value
Contains size bytes.
int disconnecting
Are we in the process of disconnecting but need to sync first?
Definition: peerstore_api.c:89
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:77
struct GNUNET_PEERSTORE_StoreContext * store_head
Head of active STORE requests.
Definition: peerstore_api.c:54
#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 695 of file peerstore_api.c.

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

701 {
702  struct GNUNET_MQ_Envelope *ev;
704 
705  ev =
707  peer,
708  key,
709  NULL,
710  0,
712  0,
715  ic->callback = callback;
717  ic->h = h;
719  if (NULL != peer)
720  ic->peer = *peer;
721  if (NULL != key)
722  ic->key = GNUNET_strdup(key);
725  "Sending an iterate request for sub system `%s'\n",
726  sub_system);
727  GNUNET_MQ_send(h->mq, ev);
728  return ic;
729 }
struct GNUNET_PEERSTORE_IterateContext * iterate_head
Head of active ITERATE requests.
Definition: peerstore_api.c:64
struct GNUNET_PEERSTORE_IterateContext * iterate_tail
Tail of active ITERATE requests.
Definition: peerstore_api.c:69
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:49
#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:351
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 669 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().

670 {
671  if (GNUNET_NO == ic->iterating)
672  {
674  GNUNET_free(ic->sub_system);
676  GNUNET_free(ic);
677  }
678  else
679  ic->callback = NULL;
680 }
#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:64
struct GNUNET_PEERSTORE_IterateContext * iterate_tail
Tail of active ITERATE requests.
Definition: peerstore_api.c:69
struct GNUNET_PEERSTORE_Handle * h
Handle to the PEERSTORE service.
#define GNUNET_NO
Definition: gnunet_common.h:78
#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 895 of file peerstore_api.c.

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

901 {
902  struct GNUNET_MQ_Envelope *ev;
903  struct StoreKeyHashMessage *hm;
905 
907  PEERSTORE_hash_key(sub_system, peer, key, &hm->keyhash);
909  wc->callback = callback;
911  wc->h = h;
912  wc->keyhash = hm->keyhash;
913  if (NULL == h->watches)
916  h->watches,
917  &wc->keyhash,
918  wc,
921  "Sending a watch request for subsystem `%s', peer `%s', key `%s'.\n",
922  sub_system,
923  GNUNET_i2s(peer),
924  key);
925  GNUNET_MQ_send(h->mq, ev);
926  return wc;
927 }
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:78
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
#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:102
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:49
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:88
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:351
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:74
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 865 of file peerstore_api.c.

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

866 {
867  struct GNUNET_PEERSTORE_Handle *h = wc->h;
868  struct GNUNET_MQ_Envelope *ev;
869  struct StoreKeyHashMessage *hm;
870 
871  LOG(GNUNET_ERROR_TYPE_DEBUG, "Canceling watch.\n");
873  hm->keyhash = wc->keyhash;
874  GNUNET_MQ_send(h->mq, ev);
876  GNUNET_YES ==
878  GNUNET_free(wc);
879 }
#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:102
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:49
Message carrying record key hash.
Definition: peerstore.h:88
#define GNUNET_YES
Definition: gnunet_common.h:77
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition: mq.c:351
struct GNUNET_CONTAINER_MultiHashMap * watches
Hashmap of watch requests.
Definition: peerstore_api.c:74
#define GNUNET_free(ptr)
Wrapper around free.
Here is the caller graph for this function: