Data store for files stored on a GNUnet node. More...
Macros | |
#define | GNUNET_DATASTORE_MAX_VALUE_SIZE 65536 |
Maximum size of a value that can be stored in the datastore. More... | |
Typedefs | |
typedef void(* | GNUNET_DATASTORE_ContinuationWithStatus) (void *cls, int32_t success, struct GNUNET_TIME_Absolute min_expiration, const char *msg) |
Continuation called to notify client about result of the operation. More... | |
typedef void(* | GNUNET_DATASTORE_DatumProcessor) (void *cls, const struct GNUNET_HashCode *key, size_t size, const void *data, enum GNUNET_BLOCK_Type type, uint32_t priority, uint32_t anonymity, uint32_t replication, struct GNUNET_TIME_Absolute expiration, uint64_t uid) |
Process a datum that was stored in the datastore. More... | |
Functions | |
struct GNUNET_DATASTORE_Handle * | GNUNET_DATASTORE_connect (const struct GNUNET_CONFIGURATION_Handle *cfg) |
Connect to the datastore service. More... | |
void | GNUNET_DATASTORE_disconnect (struct GNUNET_DATASTORE_Handle *h, int drop) |
Disconnect from the datastore service (and free associated resources). More... | |
struct GNUNET_DATASTORE_QueueEntry * | GNUNET_DATASTORE_reserve (struct GNUNET_DATASTORE_Handle *h, uint64_t amount, uint32_t entries, GNUNET_DATASTORE_ContinuationWithStatus cont, void *cont_cls) |
Reserve space in the datastore. More... | |
struct GNUNET_DATASTORE_QueueEntry * | GNUNET_DATASTORE_put (struct GNUNET_DATASTORE_Handle *h, uint32_t rid, const struct GNUNET_HashCode *key, size_t size, const void *data, enum GNUNET_BLOCK_Type type, uint32_t priority, uint32_t anonymity, uint32_t replication, struct GNUNET_TIME_Absolute expiration, unsigned int queue_priority, unsigned int max_queue_size, GNUNET_DATASTORE_ContinuationWithStatus cont, void *cont_cls) |
Store an item in the datastore. More... | |
struct GNUNET_DATASTORE_QueueEntry * | GNUNET_DATASTORE_release_reserve (struct GNUNET_DATASTORE_Handle *h, uint32_t rid, unsigned int queue_priority, unsigned int max_queue_size, GNUNET_DATASTORE_ContinuationWithStatus cont, void *cont_cls) |
Signal that all of the data for which a reservation was made has been stored and that whatever excess space might have been reserved can now be released. More... | |
struct GNUNET_DATASTORE_QueueEntry * | GNUNET_DATASTORE_remove (struct GNUNET_DATASTORE_Handle *h, const struct GNUNET_HashCode *key, size_t size, const void *data, unsigned int queue_priority, unsigned int max_queue_size, GNUNET_DATASTORE_ContinuationWithStatus cont, void *cont_cls) |
Explicitly remove some content from the database. More... | |
struct GNUNET_DATASTORE_QueueEntry * | GNUNET_DATASTORE_get_key (struct GNUNET_DATASTORE_Handle *h, uint64_t next_uid, bool random, const struct GNUNET_HashCode *key, enum GNUNET_BLOCK_Type type, unsigned int queue_priority, unsigned int max_queue_size, GNUNET_DATASTORE_DatumProcessor proc, void *proc_cls) |
Get a result for a particular key from the datastore. More... | |
struct GNUNET_DATASTORE_QueueEntry * | GNUNET_DATASTORE_get_zero_anonymity (struct GNUNET_DATASTORE_Handle *h, uint64_t next_uid, unsigned int queue_priority, unsigned int max_queue_size, enum GNUNET_BLOCK_Type type, GNUNET_DATASTORE_DatumProcessor proc, void *proc_cls) |
Get a single zero-anonymity value from the datastore. More... | |
struct GNUNET_DATASTORE_QueueEntry * | GNUNET_DATASTORE_get_for_replication (struct GNUNET_DATASTORE_Handle *h, unsigned int queue_priority, unsigned int max_queue_size, GNUNET_DATASTORE_DatumProcessor proc, void *proc_cls) |
Get a random value from the datastore for content replication. More... | |
void | GNUNET_DATASTORE_cancel (struct GNUNET_DATASTORE_QueueEntry *qe) |
Cancel a datastore operation. More... | |
Data store for files stored on a GNUnet node.
Provides an API that can be used manage the datastore for files stored on a GNUnet node. Note that the datastore is NOT responsible for on-demand encoding, that is achieved using a special kind of entry.
#define GNUNET_DATASTORE_MAX_VALUE_SIZE 65536 |
Maximum size of a value that can be stored in the datastore.
Definition at line 70 of file gnunet_datastore_service.h.
typedef void(* GNUNET_DATASTORE_ContinuationWithStatus) (void *cls, int32_t success, struct GNUNET_TIME_Absolute min_expiration, const char *msg) |
Continuation called to notify client about result of the operation.
cls | closure |
success | GNUNET_SYSERR on failure GNUNET_NO if content was already there GNUNET_YES (or other positive value) on success |
min_expiration | minimum expiration time required for 0-priority content to be stored by the datacache at this time, zero for unknown, forever if we have no space for 0-priority content |
msg | NULL on success, otherwise an error message |
Definition at line 107 of file gnunet_datastore_service.h.
typedef void(* GNUNET_DATASTORE_DatumProcessor) (void *cls, const struct GNUNET_HashCode *key, size_t size, const void *data, enum GNUNET_BLOCK_Type type, uint32_t priority, uint32_t anonymity, uint32_t replication, struct GNUNET_TIME_Absolute expiration, uint64_t uid) |
Process a datum that was stored in the datastore.
cls | closure |
key | key for the content |
size | number of bytes in data |
data | content stored |
type | type of the content |
priority | priority of the content |
anonymity | anonymity-level for the content |
replication | how often should the content be replicated to other peers? |
expiration | expiration time for the content |
uid | unique identifier for the datum; maybe 0 if no unique identifier is available |
Definition at line 253 of file gnunet_datastore_service.h.
struct GNUNET_DATASTORE_Handle * GNUNET_DATASTORE_connect | ( | const struct GNUNET_CONFIGURATION_Handle * | cfg | ) |
Connect to the datastore service.
cfg | configuration to use |
Definition at line 371 of file datastore_api.c.
References cfg, GNUNET_ARM_Handle::cfg, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_new, GNUNET_STATISTICS_create(), h, LOG, GNUNET_ARM_Handle::mq, and try_reconnect().
Referenced by deserialize_publish_file(), GNUNET_FS_publish_ksk(), GNUNET_FS_publish_sks(), GNUNET_FS_publish_start(), GNUNET_FS_unindex_do_remove_(), GNUNET_FS_unindex_do_remove_kblocks_(), and run().
void GNUNET_DATASTORE_disconnect | ( | struct GNUNET_DATASTORE_Handle * | h, |
int | drop | ||
) |
Disconnect from the datastore service (and free associated resources).
h | handle to the datastore |
drop | set to GNUNET_YES to delete all data in datastore (!) |
Definition at line 436 of file datastore_api.c.
References _, GNUNET_ARM_Handle::cfg, StatusContext::cont, StatusContext::cont_cls, disconnect_after_drop(), disconnect_on_mq_error(), env, free_queue_entry(), GNUNET_assert, GNUNET_break, GNUNET_CLIENT_connect(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_MESSAGE_TYPE_DATASTORE_DATA, GNUNET_MESSAGE_TYPE_DATASTORE_DROP, GNUNET_MESSAGE_TYPE_DATASTORE_STATUS, GNUNET_MQ_destroy(), GNUNET_MQ_msg, GNUNET_MQ_notify_sent(), GNUNET_MQ_send(), GNUNET_NO, GNUNET_SCHEDULER_cancel(), GNUNET_STATISTICS_destroy(), GNUNET_SYSERR, GNUNET_TIME_UNIT_ZERO_ABS, GNUNET_YES, h, LOG, GNUNET_ARM_Handle::mq, ResultContext::proc, ResultContext::proc_cls, GNUNET_DATASTORE_QueueEntry::qc, qe, QueueContext::rc, GNUNET_ARM_Handle::reconnect_task, GNUNET_DATASTORE_QueueEntry::response_type, and QueueContext::sc.
Referenced by disconnect_after_drop(), disconnect_on_mq_error(), do_shutdown(), GNUNET_FS_publish_ksk_cancel(), GNUNET_FS_publish_sks_cancel(), GNUNET_FS_unindex_do_remove_(), GNUNET_FS_unindex_signal_suspend_(), GNUNET_FS_unindex_stop(), publish_cleanup(), shutdown_task(), suspend_operation(), and unindex_finish().
struct GNUNET_DATASTORE_QueueEntry * GNUNET_DATASTORE_reserve | ( | struct GNUNET_DATASTORE_Handle * | h, |
uint64_t | amount, | ||
uint32_t | entries, | ||
GNUNET_DATASTORE_ContinuationWithStatus | cont, | ||
void * | cont_cls | ||
) |
Reserve space in the datastore.
This function should be used to avoid "out of space" failures during a longer sequence of "put" operations (for example, when a file is being inserted).
h | handle to the datastore |
amount | how much space (in bytes) should be reserved (for content only) |
entries | how many entries will be created (to calculate per-entry overhead) |
cont | continuation to call when done; "success" will be set to a positive reservation value if space could be reserved. |
cont_cls | closure for cont |
Definition at line 1031 of file datastore_api.c.
References ReserveMessage::amount, StatusContext::cont, StatusContext::cont_cls, drop_status_cont(), ReserveMessage::entries, env, gettext_noop, GNUNET_ERROR_TYPE_DEBUG, GNUNET_htonll(), GNUNET_MESSAGE_TYPE_DATASTORE_RESERVE, GNUNET_MESSAGE_TYPE_DATASTORE_STATUS, GNUNET_MQ_msg, GNUNET_NO, GNUNET_STATISTICS_update(), h, LOG, make_queue_entry(), process_queue(), qe, and QueueContext::sc.
Referenced by GNUNET_FS_publish_start().
struct GNUNET_DATASTORE_QueueEntry * GNUNET_DATASTORE_put | ( | struct GNUNET_DATASTORE_Handle * | h, |
uint32_t | rid, | ||
const struct GNUNET_HashCode * | key, | ||
size_t | size, | ||
const void * | data, | ||
enum GNUNET_BLOCK_Type | type, | ||
uint32_t | priority, | ||
uint32_t | anonymity, | ||
uint32_t | replication, | ||
struct GNUNET_TIME_Absolute | expiration, | ||
unsigned int | queue_priority, | ||
unsigned int | max_queue_size, | ||
GNUNET_DATASTORE_ContinuationWithStatus | cont, | ||
void * | cont_cls | ||
) |
Store an item in the datastore.
If the item is already present, the priorities and replication values are summed up and the higher expiration time and lower anonymity level is used.
h | handle to the datastore |
rid | reservation ID to use (from "reserve"); use 0 if no prior reservation was made |
key | key for the value |
size | number of bytes in data |
data | content stored |
type | type of the content |
priority | priority of the content |
anonymity | anonymity-level for the content |
replication | how often should the content be replicated to other peers? |
expiration | expiration time for the content |
queue_priority | ranking of this request in the priority queue |
max_queue_size | at what queue size should this request be dropped (if other requests of higher priority are in the queue) |
cont | continuation to call when done |
cont_cls | closure for cont |
Definition at line 945 of file datastore_api.c.
References anonymity, DataMessage::anonymity, StatusContext::cont, StatusContext::cont_cls, data, env, expiration, DataMessage::expiration, gettext_noop, GNUNET_break, GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_MAX_MESSAGE_SIZE, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_DATASTORE_PUT, GNUNET_MESSAGE_TYPE_DATASTORE_STATUS, GNUNET_MQ_msg_extra, GNUNET_NO, GNUNET_STATISTICS_update(), GNUNET_STRINGS_relative_time_to_string(), GNUNET_TIME_absolute_get_remaining(), GNUNET_TIME_absolute_hton(), GNUNET_YES, h, key, DataMessage::key, LOG, make_queue_entry(), DataMessage::priority, process_queue(), qe, replication, DataMessage::replication, DataMessage::rid, QueueContext::sc, size, DataMessage::size, type, and DataMessage::type.
Referenced by block_proc(), GNUNET_FS_publish_ublock_(), handle_dht_reply(), handle_p2p_put(), and put_cb().
struct GNUNET_DATASTORE_QueueEntry * GNUNET_DATASTORE_release_reserve | ( | struct GNUNET_DATASTORE_Handle * | h, |
uint32_t | rid, | ||
unsigned int | queue_priority, | ||
unsigned int | max_queue_size, | ||
GNUNET_DATASTORE_ContinuationWithStatus | cont, | ||
void * | cont_cls | ||
) |
Signal that all of the data for which a reservation was made has been stored and that whatever excess space might have been reserved can now be released.
h | handle to the datastore |
rid | reservation ID (value of "success" in original continuation from the "reserve" function). |
queue_priority | ranking of this request in the priority queue |
max_queue_size | at what queue size should this request be dropped (if other requests of higher priority are in the queue) |
queue_priority | ranking of this request in the priority queue |
max_queue_size | at what queue size should this request be dropped (if other requests of higher priority are in the queue) |
cont | continuation to call when done |
cont_cls | closure for cont |
Definition at line 1077 of file datastore_api.c.
References StatusContext::cont, StatusContext::cont_cls, drop_status_cont(), env, gettext_noop, GNUNET_ERROR_TYPE_DEBUG, GNUNET_MESSAGE_TYPE_DATASTORE_RELEASE_RESERVE, GNUNET_MESSAGE_TYPE_DATASTORE_STATUS, GNUNET_MQ_msg, GNUNET_NO, GNUNET_STATISTICS_update(), h, LOG, make_queue_entry(), process_queue(), qe, ReleaseReserveMessage::rid, and QueueContext::sc.
Referenced by publish_sblocks_cont().
struct GNUNET_DATASTORE_QueueEntry * GNUNET_DATASTORE_remove | ( | struct GNUNET_DATASTORE_Handle * | h, |
const struct GNUNET_HashCode * | key, | ||
size_t | size, | ||
const void * | data, | ||
unsigned int | queue_priority, | ||
unsigned int | max_queue_size, | ||
GNUNET_DATASTORE_ContinuationWithStatus | cont, | ||
void * | cont_cls | ||
) |
Explicitly remove some content from the database.
cont will be called with status GNUNET_OK if content was removed, GNUNET_NO if no matching entry was found and GNUNET_SYSERR on all other types of errors.
h | handle to the datastore |
key | key for the value |
size | number of bytes in data |
data | content stored |
queue_priority | ranking of this request in the priority queue |
max_queue_size | at what queue size should this request be dropped (if other requests of higher priority are in the queue) |
cont | continuation to call when done |
cont_cls | closure for cont |
Definition at line 1121 of file datastore_api.c.
References StatusContext::cont, StatusContext::cont_cls, data, drop_status_cont(), env, gettext_noop, GNUNET_break, GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_MAX_MESSAGE_SIZE, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_DATASTORE_REMOVE, GNUNET_MESSAGE_TYPE_DATASTORE_STATUS, GNUNET_MQ_msg_extra, GNUNET_NO, GNUNET_STATISTICS_update(), h, key, DataMessage::key, LOG, make_queue_entry(), process_queue(), qe, QueueContext::sc, size, and DataMessage::size.
Referenced by GNUNET_FS_handle_on_demand_block(), process_kblock_for_unindex(), process_local_reply(), and unindex_process().
struct GNUNET_DATASTORE_QueueEntry * GNUNET_DATASTORE_get_key | ( | struct GNUNET_DATASTORE_Handle * | h, |
uint64_t | next_uid, | ||
bool | random, | ||
const struct GNUNET_HashCode * | key, | ||
enum GNUNET_BLOCK_Type | type, | ||
unsigned int | queue_priority, | ||
unsigned int | max_queue_size, | ||
GNUNET_DATASTORE_DatumProcessor | proc, | ||
void * | proc_cls | ||
) |
Get a result for a particular key from the datastore.
The processor will only be called once.
h | handle to the datastore |
next_uid | return the result with lowest uid >= next_uid |
random | if true, return a random result instead of using next_uid |
key | maybe NULL (to match all entries) |
type | desired type, 0 for any |
queue_priority | ranking of this request in the priority queue |
max_queue_size | at what queue size should this request be dropped (if other requests of higher priority are in the queue) |
proc | function to call on a matching value; or with a NULL value if no datum matches |
proc_cls | closure for proc |
The processor will only be called once.
h | handle to the datastore |
next_uid | return the result with lowest uid >= next_uid |
random | if true, return a random result instead of using next_uid |
key | maybe NULL (to match all entries) |
type | desired type, 0 for any |
queue_priority | ranking of this request in the priority queue |
max_queue_size | at what queue size should this request be dropped (if other requests of higher priority are in the queue) |
proc | function to call on each matching value; will be called once with a NULL value at the end |
proc_cls | closure for proc |
Definition at line 1302 of file datastore_api.c.
References env, gettext_noop, GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_htonll(), GNUNET_MESSAGE_TYPE_DATASTORE_DATA, GNUNET_MESSAGE_TYPE_DATASTORE_GET, GNUNET_MESSAGE_TYPE_DATASTORE_GET_KEY, GNUNET_MQ_msg, GNUNET_NO, GNUNET_STATISTICS_update(), h, key, GetKeyMessage::key, LOG, make_queue_entry(), GetKeyMessage::next_uid, GetMessage::next_uid, ResultContext::proc, ResultContext::proc_cls, process_queue(), qe, GetKeyMessage::random, GetMessage::random, QueueContext::rc, type, GetKeyMessage::type, and GetMessage::type.
Referenced by do_get(), GNUNET_FS_unindex_do_remove_kblocks_(), handle_request(), process_kblock_for_unindex(), and start_local_query().
struct GNUNET_DATASTORE_QueueEntry * GNUNET_DATASTORE_get_zero_anonymity | ( | struct GNUNET_DATASTORE_Handle * | h, |
uint64_t | next_uid, | ||
unsigned int | queue_priority, | ||
unsigned int | max_queue_size, | ||
enum GNUNET_BLOCK_Type | type, | ||
GNUNET_DATASTORE_DatumProcessor | proc, | ||
void * | proc_cls | ||
) |
Get a single zero-anonymity value from the datastore.
h | handle to the datastore |
next_uid | return the result with lowest uid >= next_uid |
queue_priority | ranking of this request in the priority queue |
max_queue_size | at what queue size should this request be dropped (if other requests of higher priority are in the queue) |
type | allowed type for the operation (never zero) |
proc | function to call on a random value; it will be called once with a value (if available) or with NULL if none value exists. |
proc_cls | closure for proc |
Definition at line 1238 of file datastore_api.c.
References env, gettext_noop, GNUNET_assert, GNUNET_BLOCK_TYPE_ANY, GNUNET_ERROR_TYPE_DEBUG, GNUNET_htonll(), GNUNET_MESSAGE_TYPE_DATASTORE_DATA, GNUNET_MESSAGE_TYPE_DATASTORE_GET_ZERO_ANONYMITY, GNUNET_MQ_msg, GNUNET_NO, GNUNET_STATISTICS_update(), h, LOG, m, make_queue_entry(), ResultContext::proc, ResultContext::proc_cls, process_queue(), qe, QueueContext::rc, and type.
Referenced by gather_dht_put_blocks().
struct GNUNET_DATASTORE_QueueEntry * GNUNET_DATASTORE_get_for_replication | ( | struct GNUNET_DATASTORE_Handle * | h, |
unsigned int | queue_priority, | ||
unsigned int | max_queue_size, | ||
GNUNET_DATASTORE_DatumProcessor | proc, | ||
void * | proc_cls | ||
) |
Get a random value from the datastore for content replication.
Returns a single, random value among those with the highest replication score, lowering positive replication scores by one for the chosen value (if only content with a replication score exists, a random value is returned and replication scores are not changed).
h | handle to the datastore |
queue_priority | ranking of this request in the priority queue |
max_queue_size | at what queue size should this request be dropped (if other requests of higher priority are in the queue) |
proc | function to call on a random value; it will be called once with a value (if available) and always once with a value of NULL. |
proc_cls | closure for proc |
Definition at line 1198 of file datastore_api.c.
References env, gettext_noop, GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_MESSAGE_TYPE_DATASTORE_DATA, GNUNET_MESSAGE_TYPE_DATASTORE_GET_REPLICATION, GNUNET_MQ_msg, GNUNET_NO, GNUNET_STATISTICS_update(), h, LOG, m, make_queue_entry(), ResultContext::proc, ResultContext::proc_cls, process_queue(), qe, and QueueContext::rc.
Referenced by gather_migration_blocks().
void GNUNET_DATASTORE_cancel | ( | struct GNUNET_DATASTORE_QueueEntry * | qe | ) |
Cancel a datastore operation.
The final callback from the operation must not have been done yet.
qe | operation to cancel |
Definition at line 1373 of file datastore_api.c.
References GNUNET_DATASTORE_QueueEntry::env, free_queue_entry(), GNUNET_ERROR_TYPE_DEBUG, h, GNUNET_DATASTORE_QueueEntry::h, LOG, process_queue(), and qe.
Referenced by clean_request(), disconnect_cb(), do_shutdown(), GNUNET_FS_publish_stop(), GNUNET_FS_publish_ublock_cancel_(), GNUNET_FS_unindex_signal_suspend_(), GNUNET_FS_unindex_stop(), GSF_pending_request_cancel_(), GSF_push_done_(), GSF_put_done_(), and suspend_operation().