![]() |
GNUnet
0.11.x
|
GNUnet DHT service's datacache integration. More...
#include "platform.h"
#include "gnunet_datacache_lib.h"
#include "gnunet-service-dht_datacache.h"
#include "gnunet-service-dht_neighbours.h"
#include "gnunet-service-dht_routing.h"
#include "gnunet-service-dht.h"
Go to the source code of this file.
Data Structures | |
struct | GetRequestContext |
Context containing information about a GET request. More... | |
struct | SuccContext |
Closure for datacache_get_successors_iterator(). More... | |
Macros | |
#define | LOG(kind, ...) GNUNET_log_from (kind, "dht-dhtcache", __VA_ARGS__) |
#define | NUM_CLOSEST 42 |
How many "closest" results to we return for migration when asked (at most)? More... | |
Functions | |
void | GDS_DATACACHE_handle_put (struct GNUNET_TIME_Absolute expiration, const struct GNUNET_HashCode *key, unsigned int put_path_length, const struct GNUNET_PeerIdentity *put_path, enum GNUNET_BLOCK_Type type, size_t data_size, const void *data) |
Handle a datum we've received from another peer. More... | |
static int | datacache_get_iterator (void *cls, const struct GNUNET_HashCode *key, size_t data_size, const char *data, enum GNUNET_BLOCK_Type type, struct GNUNET_TIME_Absolute exp, unsigned int put_path_length, const struct GNUNET_PeerIdentity *put_path) |
Iterator for local get request results,. More... | |
enum GNUNET_BLOCK_EvaluationResult | GDS_DATACACHE_handle_get (const struct GNUNET_HashCode *key, enum GNUNET_BLOCK_Type type, const void *xquery, size_t xquery_size, struct GNUNET_BLOCK_Group *bg, GDS_DATACACHE_GetCallback gc, void *gc_cls) |
Handle a GET request we've received from another peer. More... | |
static int | datacache_random_iterator (void *cls, const struct GNUNET_HashCode *key, size_t data_size, const char *data, enum GNUNET_BLOCK_Type type, struct GNUNET_TIME_Absolute exp, unsigned int path_info_len, const struct GNUNET_PeerIdentity *path_info) |
Function called with a random element from the datacache. More... | |
int | GDS_DATACACHE_get_random_key (struct GNUNET_HashCode *key) |
Obtain a random key from the datacache. More... | |
static int | datacache_get_successors_iterator (void *cls, const struct GNUNET_HashCode *key, size_t size, const char *data, enum GNUNET_BLOCK_Type type, struct GNUNET_TIME_Absolute exp, unsigned int put_path_length, const struct GNUNET_PeerIdentity *put_path) |
Iterator for local get request results,. More... | |
void | GDS_DATACACHE_get_successors (const struct GNUNET_HashCode *key, GDS_DATACACHE_SuccessorCallback cb, void *cb_cls) |
Handle a request for data close to a key that we have received from another peer. More... | |
void | GDS_DATACACHE_init () |
Initialize datacache subsystem. More... | |
void | GDS_DATACACHE_done () |
Shutdown datacache subsystem. More... | |
Variables | |
static struct GNUNET_DATACACHE_Handle * | datacache |
Handle to the datacache service (for inserting/retrieving data) More... | |
GNUnet DHT service's datacache integration.
Definition in file gnunet-service-dht_datacache.c.
#define LOG | ( | kind, | |
... | |||
) | GNUNET_log_from (kind, "dht-dhtcache", __VA_ARGS__) |
Definition at line 33 of file gnunet-service-dht_datacache.c.
Referenced by datacache_get_iterator(), GDS_DATACACHE_handle_get(), and GDS_DATACACHE_handle_put().
#define NUM_CLOSEST 42 |
How many "closest" results to we return for migration when asked (at most)?
Definition at line 39 of file gnunet-service-dht_datacache.c.
Referenced by GDS_DATACACHE_get_successors().
void GDS_DATACACHE_handle_put | ( | struct GNUNET_TIME_Absolute | expiration, |
const struct GNUNET_HashCode * | key, | ||
unsigned int | put_path_length, | ||
const struct GNUNET_PeerIdentity * | put_path, | ||
enum GNUNET_BLOCK_Type | type, | ||
size_t | data_size, | ||
const void * | data | ||
) |
Handle a datum we've received from another peer.
Cache if possible.
expiration | when will the reply expire |
key | the query this reply is for |
put_path_length | number of peers in put_path |
put_path | path the reply took on put |
type | type of the reply |
data_size | number of bytes in data |
data | application payload data |
Definition at line 60 of file gnunet-service-dht_datacache.c.
References _, GDS_stats, gettext_noop, GNUNET_break, GNUNET_CRYPTO_hash_matching_bits(), GNUNET_DATACACHE_put(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, GNUNET_h2s(), GNUNET_log, GNUNET_MAX_MESSAGE_SIZE, GNUNET_NO, GNUNET_STATISTICS_update(), LOG, and my_identity_hash.
Referenced by handle_dht_local_put(), handle_dht_p2p_put(), and process_reply_with_path().
|
static |
Iterator for local get request results,.
cls | closure for iterator, a struct GetRequestContext |
exp | when does this value expire? |
key | the key this data is stored under |
data_size | the size of the data identified by key |
data | the actual data |
type | the type of the data |
put_path_length | number of peers in put_path |
put_path | path the reply took on put |
Definition at line 162 of file gnunet-service-dht_datacache.c.
References _, GetRequestContext::bg, ctx, GetRequestContext::eval, GetRequestContext::gc, GetRequestContext::gc_cls, GDS_block_context, GDS_stats, gettext_noop, GNUNET_BLOCK_EO_LOCAL_SKIP_CRYPTO, GNUNET_BLOCK_evaluate(), GNUNET_BLOCK_EVALUATION_OK_DUPLICATE, GNUNET_BLOCK_EVALUATION_OK_LAST, GNUNET_BLOCK_EVALUATION_OK_MORE, GNUNET_BLOCK_EVALUATION_REQUEST_INVALID, GNUNET_BLOCK_EVALUATION_REQUEST_VALID, GNUNET_BLOCK_EVALUATION_RESULT_INVALID, GNUNET_BLOCK_EVALUATION_RESULT_IRRELEVANT, GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED, GNUNET_break, GNUNET_break_op, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, GNUNET_h2s(), GNUNET_log, GNUNET_NO, GNUNET_OK, GNUNET_STATISTICS_update(), GNUNET_SYSERR, GNUNET_TIME_absolute_get_remaining(), LOG, GetRequestContext::xquery, and GetRequestContext::xquery_size.
Referenced by GDS_DATACACHE_handle_get().
enum GNUNET_BLOCK_EvaluationResult GDS_DATACACHE_handle_get | ( | const struct GNUNET_HashCode * | key, |
enum GNUNET_BLOCK_Type | type, | ||
const void * | xquery, | ||
size_t | xquery_size, | ||
struct GNUNET_BLOCK_Group * | bg, | ||
GDS_DATACACHE_GetCallback | gc, | ||
void * | gc_cls | ||
) |
Handle a GET request we've received from another peer.
key | the query |
type | requested data type |
xquery | extended query |
xquery_size | number of bytes in xquery |
bg | block group to use for reply evaluation |
gc | function to call on the results |
gc_cls | closure for gc |
Definition at line 277 of file gnunet-service-dht_datacache.c.
References GetRequestContext::bg, datacache_get_iterator(), GetRequestContext::eval, GetRequestContext::gc, GetRequestContext::gc_cls, GDS_stats, gettext_noop, GNUNET_BLOCK_EVALUATION_REQUEST_VALID, GNUNET_DATACACHE_get(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_NO, GNUNET_STATISTICS_update(), GetRequestContext::key, LOG, GetRequestContext::xquery, and GetRequestContext::xquery_size.
Referenced by handle_dht_local_get(), and handle_dht_p2p_get().
|
static |
Function called with a random element from the datacache.
Stores the key in the closure.
cls | a struct GNUNET_HashCode * , where to store the key |
key | key for the content |
data_size | number of bytes in data |
data | content stored |
type | type of the content |
exp | when will the content expire? |
path_info_len | number of entries in path_info |
path_info | a path through the network |
Definition at line 330 of file gnunet-service-dht_datacache.c.
References GNUNET_OK, and GetRequestContext::key.
Referenced by GDS_DATACACHE_get_random_key().
int GDS_DATACACHE_get_random_key | ( | struct GNUNET_HashCode * | key | ) |
Obtain a random key from the datacache.
Used by Whanau for load-balancing.
[out] | key | where to store the key of a random element, randomized by PRNG if datacache is empty |
Definition at line 355 of file gnunet-service-dht_datacache.c.
References datacache_random_iterator(), GNUNET_CRYPTO_hash_create_random(), GNUNET_CRYPTO_QUALITY_NONCE, GNUNET_DATACACHE_get_random(), GNUNET_OK, and GNUNET_SYSERR.
|
static |
Iterator for local get request results,.
cls | closure with the struct GNUNET_HashCode * with the trail ID |
key | the key this data is stored under |
size | the size of the data identified by key |
data | the actual data |
type | the type of the data |
exp | when does this value expire? |
put_path_length | number of peers in put_path |
put_path | path the reply took on put |
Definition at line 403 of file gnunet-service-dht_datacache.c.
References SuccContext::cb, SuccContext::cb_cls, GNUNET_DHT_RO_RECORD_ROUTE, GNUNET_OK, and sc.
Referenced by GDS_DATACACHE_get_successors().
void GDS_DATACACHE_get_successors | ( | const struct GNUNET_HashCode * | key, |
GDS_DATACACHE_SuccessorCallback | cb, | ||
void * | cb_cls | ||
) |
Handle a request for data close to a key that we have received from another peer.
key | the location at which the peer is looking for data that is close |
cb | function to call with the result |
cb_cls | closure for cb |
Definition at line 439 of file gnunet-service-dht_datacache.c.
References SuccContext::cb, SuccContext::cb_cls, datacache_get_successors_iterator(), GNUNET_DATACACHE_get_closest(), and NUM_CLOSEST.
void GDS_DATACACHE_init | ( | void | ) |
Initialize datacache subsystem.
Definition at line 459 of file gnunet-service-dht_datacache.c.
References GDS_cfg, and GNUNET_DATACACHE_create().
Referenced by run().
void GDS_DATACACHE_done | ( | void | ) |
Shutdown datacache subsystem.
Definition at line 469 of file gnunet-service-dht_datacache.c.
References GNUNET_DATACACHE_destroy().
Referenced by shutdown_task().
|
static |
Handle to the datacache service (for inserting/retrieving data)
Definition at line 44 of file gnunet-service-dht_datacache.c.