API for peerstore. More...
#include "platform.h"
#include "gnunet_util_lib.h"
#include "peerstore.h"
#include "peerstore_common.h"
Go to the source code of this file.
Data Structures | |
struct | GNUNET_PEERSTORE_Handle |
Handle to the PEERSTORE service. More... | |
struct | GNUNET_PEERSTORE_StoreContext |
Context for a store request. More... | |
struct | GNUNET_PEERSTORE_IterateContext |
Context for a iterate request. More... | |
struct | GNUNET_PEERSTORE_WatchContext |
Context for a watch request. More... | |
Macros | |
#define | LOG(kind, ...) GNUNET_log_from (kind, "peerstore-api", __VA_ARGS__) |
Functions | |
static void | reconnect (void *cls) |
Close the existing connection to PEERSTORE and reconnect. More... | |
static void | disconnect (struct GNUNET_PEERSTORE_Handle *h) |
Disconnect from the peerstore service. More... | |
static void | disconnect_and_schedule_reconnect (struct GNUNET_PEERSTORE_Handle *h) |
Function that will schedule the job that will try to connect us again to the client. More... | |
static void | store_request_sent (void *cls) |
Callback after MQ envelope is sent. More... | |
static void | handle_client_error (void *cls, enum GNUNET_MQ_Error error) |
Function called when we had trouble talking to the service. More... | |
static int | rewatch_it (void *cls, const struct GNUNET_HashCode *key, void *value) |
Iterator over previous watches to resend them. More... | |
static int | destroy_watch (void *cls, const struct GNUNET_HashCode *key, void *value) |
Iterator over watch requests to cancel them. More... | |
static void | final_disconnect (struct GNUNET_PEERSTORE_Handle *h) |
Kill the connection to the service. More... | |
struct GNUNET_PEERSTORE_Handle * | GNUNET_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... | |
void | GNUNET_PEERSTORE_store_cancel (struct GNUNET_PEERSTORE_StoreContext *sc) |
Cancel a store request. More... | |
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. More... | |
static void | handle_iterate_end (void *cls, const struct GNUNET_MessageHeader *msg) |
When a response for iterate request is received. More... | |
static int | check_iterate_result (void *cls, const struct StoreRecordMessage *msg) |
When a response for iterate request is received, check the message is well-formed. More... | |
static void | handle_iterate_result (void *cls, const struct StoreRecordMessage *msg) |
When a response for iterate request is received. 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_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. More... | |
static int | check_watch_record (void *cls, const struct StoreRecordMessage *msg) |
When a watch record is received, validate it is well-formed. More... | |
static void | handle_watch_record (void *cls, const struct StoreRecordMessage *msg) |
When a watch record is received, process it. More... | |
void | GNUNET_PEERSTORE_watch_cancel (struct GNUNET_PEERSTORE_WatchContext *wc) |
Cancel a watch request. More... | |
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. More... | |
API for peerstore.
Definition in file peerstore_api.c.
#define LOG | ( | kind, | |
... | |||
) | GNUNET_log_from (kind, "peerstore-api", __VA_ARGS__) |
Definition at line 31 of file peerstore_api.c.
|
static |
Close the existing connection to PEERSTORE and reconnect.
cls | a struct GNUNET_PEERSTORE_Handle *h |
cls | a struct GNUNET_PEERSTORE_Handle * |
Definition at line 798 of file peerstore_api.c.
References GNUNET_ARM_Handle::cfg, GNUNET_CLIENT_connect(), GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_MESSAGE_TYPE_PEERSTORE_ITERATE, GNUNET_MESSAGE_TYPE_PEERSTORE_ITERATE_END, GNUNET_MESSAGE_TYPE_PEERSTORE_ITERATE_RECORD, GNUNET_MESSAGE_TYPE_PEERSTORE_STORE, GNUNET_MESSAGE_TYPE_PEERSTORE_WATCH_RECORD, GNUNET_MQ_handler_end, GNUNET_MQ_hd_fixed_size, GNUNET_MQ_hd_var_size, GNUNET_MQ_notify_sent(), GNUNET_MQ_send(), GNUNET_SCHEDULER_add_delayed(), GNUNET_TIME_STD_BACKOFF, GNUNET_TIME_UNIT_FOREVER_ABS, h, handle_client_error(), LOG, GNUNET_ARM_Handle::mq, GNUNET_FS_SearchContext::options, PEERSTORE_create_record_mq_envelope(), GNUNET_ARM_Handle::reconnect_task, rewatch_it(), sc, and store_request_sent().
Referenced by disconnect_and_schedule_reconnect(), and GNUNET_PEERSTORE_connect().
|
static |
Disconnect from the peerstore service.
h | peerstore handle to disconnect |
Definition at line 265 of file peerstore_api.c.
References GNUNET_MQ_destroy(), GNUNET_PEERSTORE_iterate_cancel(), GNUNET_YES, h, GNUNET_ARM_Handle::mq, and GNUNET_PEERSTORE_IterateContext::next.
Referenced by disconnect_and_schedule_reconnect(), and reconnect().
|
static |
Function that will schedule the job that will try to connect us again to the client.
h | peerstore to reconnect |
Definition at line 301 of file peerstore_api.c.
References disconnect(), GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_SCHEDULER_add_delayed(), GNUNET_STRINGS_relative_time_to_string(), GNUNET_TIME_STD_BACKOFF, GNUNET_YES, h, LOG, reconnect(), and GNUNET_ARM_Handle::reconnect_task.
Referenced by handle_client_error(), handle_iterate_end(), handle_iterate_result(), and handle_watch_record().
|
static |
Callback after MQ envelope is sent.
cls | a struct GNUNET_PEERSTORE_StoreContext * |
Definition at line 320 of file peerstore_api.c.
References GNUNET_PEERSTORE_StoreContext::cont, GNUNET_PEERSTORE_StoreContext::cont_cls, GNUNET_OK, GNUNET_PEERSTORE_store_cancel(), and sc.
Referenced by GNUNET_PEERSTORE_store(), and reconnect().
|
static |
Function called when we had trouble talking to the service.
Definition at line 346 of file peerstore_api.c.
References disconnect_and_schedule_reconnect(), GNUNET_ERROR_TYPE_ERROR, h, and LOG.
Referenced by reconnect().
|
static |
Iterator over previous watches to resend them.
cls | the struct GNUNET_PEERSTORE_Handle |
key | key for the watch |
value | the struct GNUNET_PEERSTORE_WatchContext * |
Definition at line 366 of file peerstore_api.c.
References GNUNET_MESSAGE_TYPE_PEERSTORE_WATCH, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_YES, h, StoreKeyHashMessage::keyhash, GNUNET_PEERSTORE_WatchContext::keyhash, GNUNET_ARM_Handle::mq, and value.
Referenced by reconnect().
|
static |
Iterator over watch requests to cancel them.
cls | unused |
key | key to the watch request |
value | watch context |
Definition at line 389 of file peerstore_api.c.
References GNUNET_PEERSTORE_watch_cancel(), GNUNET_YES, and value.
Referenced by GNUNET_PEERSTORE_disconnect().
|
static |
Kill the connection to the service.
This can be delayed in case of pending STORE requests and the user explicitly asked to sync first. Otherwise it is performed instantly.
h | Handle to the service. |
Definition at line 406 of file peerstore_api.c.
References GNUNET_free, GNUNET_MQ_destroy(), h, and GNUNET_ARM_Handle::mq.
Referenced by GNUNET_PEERSTORE_disconnect(), and GNUNET_PEERSTORE_store_cancel().
|
static |
When a response for iterate request is received.
cls | a struct GNUNET_PEERSTORE_Handle * |
msg | message received |
Definition at line 592 of file peerstore_api.c.
References _, GNUNET_PEERSTORE_IterateContext::callback, GNUNET_PEERSTORE_IterateContext::callback_cls, disconnect_and_schedule_reconnect(), GNUNET_ERROR_TYPE_ERROR, GNUNET_NO, GNUNET_PEERSTORE_iterate_cancel(), GNUNET_TIME_UNIT_ZERO, h, GNUNET_PEERSTORE_IterateContext::iterating, and LOG.
|
static |
When a response for iterate request is received, check the message is well-formed.
cls | a struct GNUNET_PEERSTORE_Handle * |
msg | message received |
Definition at line 626 of file peerstore_api.c.
References GNUNET_OK.
|
static |
When a response for iterate request is received.
cls | a struct GNUNET_PEERSTORE_Handle * |
msg | message received |
Definition at line 640 of file peerstore_api.c.
References _, GNUNET_PEERSTORE_IterateContext::callback, GNUNET_PEERSTORE_IterateContext::callback_cls, disconnect_and_schedule_reconnect(), GNUNET_ERROR_TYPE_ERROR, GNUNET_YES, h, GNUNET_PEERSTORE_IterateContext::iterating, LOG, msg, PEERSTORE_destroy_record(), PEERSTORE_parse_record_message(), and record().
|
static |
When a watch record is received, validate it is well-formed.
cls | a struct GNUNET_PEERSTORE_Handle * |
msg | message received |
Definition at line 746 of file peerstore_api.c.
References GNUNET_OK.
|
static |
When a watch record is received, process it.
cls | a struct GNUNET_PEERSTORE_Handle * |
msg | message received |
Definition at line 760 of file peerstore_api.c.
References _, GNUNET_PEERSTORE_WatchContext::callback, GNUNET_PEERSTORE_WatchContext::callback_cls, disconnect_and_schedule_reconnect(), GNUNET_CONTAINER_multihashmap_get(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_TIME_UNIT_ZERO, h, GNUNET_PEERSTORE_WatchContext::keyhash, LOG, msg, PEERSTORE_destroy_record(), PEERSTORE_hash_key(), PEERSTORE_parse_record_message(), and record().