GNUnet  0.10.x
Macros | Typedefs | Functions
Data Store service

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_HandleGNUNET_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_QueueEntryGNUNET_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_QueueEntryGNUNET_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_QueueEntryGNUNET_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_QueueEntryGNUNET_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_QueueEntryGNUNET_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_QueueEntryGNUNET_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_QueueEntryGNUNET_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...
 

Detailed Description

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.

Macro Definition Documentation

◆ GNUNET_DATASTORE_MAX_VALUE_SIZE

#define GNUNET_DATASTORE_MAX_VALUE_SIZE   65536

Maximum size of a value that can be stored in the datastore.

Definition at line 66 of file gnunet_datastore_service.h.

Typedef Documentation

◆ GNUNET_DATASTORE_ContinuationWithStatus

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.

Parameters
clsclosure
successGNUNET_SYSERR on failure GNUNET_NO if content was already there GNUNET_YES (or other positive value) on success
min_expirationminimum 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
msgNULL on success, otherwise an error message

Definition at line 104 of file gnunet_datastore_service.h.

◆ GNUNET_DATASTORE_DatumProcessor

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.

Parameters
clsclosure
keykey for the content
sizenumber of bytes in data
datacontent stored
typetype of the content
prioritypriority of the content
anonymityanonymity-level for the content
replicationhow often should the content be replicated to other peers?
expirationexpiration time for the content
uidunique identifier for the datum; maybe 0 if no unique identifier is available

Definition at line 249 of file gnunet_datastore_service.h.

Function Documentation

◆ GNUNET_DATASTORE_connect()

struct GNUNET_DATASTORE_Handle* GNUNET_DATASTORE_connect ( const struct GNUNET_CONFIGURATION_Handle cfg)

Connect to the datastore service.

Parameters
cfgconfiguration to use
Returns
handle to use to access the service

Definition at line 377 of file datastore_api.c.

References cfg, GNUNET_DATASTORE_Handle::cfg, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_new, GNUNET_STATISTICS_create(), h, LOG, GNUNET_DATASTORE_Handle::mq, GNUNET_DATASTORE_Handle::stats, 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().

378 {
379  struct GNUNET_DATASTORE_Handle *h;
380 
382  "Establishing DATASTORE connection!\n");
383  h = GNUNET_new (struct GNUNET_DATASTORE_Handle);
384  h->cfg = cfg;
385  try_reconnect (h);
386  if (NULL == h->mq)
387  {
388  GNUNET_free (h);
389  return NULL;
390  }
391  h->stats = GNUNET_STATISTICS_create ("datastore-api",
392  cfg);
393  return h;
394 }
struct GNUNET_MQ_Handle * mq
Current connection to the datastore service.
static void try_reconnect(void *cls)
Try reconnecting to the datastore service.
struct GNUNET_STATISTICS_Handle * GNUNET_STATISTICS_create(const char *subsystem, const struct GNUNET_CONFIGURATION_Handle *cfg)
Get handle for the statistics service.
struct GNUNET_STATISTICS_Handle * stats
Handle for statistics.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
const struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:94
#define LOG(kind,...)
Definition: datastore_api.c:34
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition: gnunet-arm.c:104
Handle to the datastore service.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_DATASTORE_disconnect()

void GNUNET_DATASTORE_disconnect ( struct GNUNET_DATASTORE_Handle h,
int  drop 
)

Disconnect from the datastore service (and free associated resources).

Parameters
hhandle to the datastore
dropset to GNUNET_YES to delete all data in datastore (!)

Definition at line 442 of file datastore_api.c.

References _, GNUNET_DATASTORE_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, LOG, GNUNET_DATASTORE_Handle::mq, ResultContext::proc, ResultContext::proc_cls, GNUNET_DATASTORE_QueueEntry::qc, qe, GNUNET_DATASTORE_Handle::queue_head, QueueContext::rc, GNUNET_DATASTORE_Handle::reconnect_task, GNUNET_DATASTORE_QueueEntry::response_type, QueueContext::sc, and GNUNET_DATASTORE_Handle::stats.

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().

444 {
446 
448  "Datastore disconnect\n");
449  if (NULL != h->mq)
450  {
451  GNUNET_MQ_destroy (h->mq);
452  h->mq = NULL;
453  }
454  if (NULL != h->reconnect_task)
455  {
457  h->reconnect_task = NULL;
458  }
459  while (NULL != (qe = h->queue_head))
460  {
461  switch (qe->response_type)
462  {
464  if (NULL != qe->qc.sc.cont)
465  qe->qc.sc.cont (qe->qc.sc.cont_cls,
468  _("Disconnected from DATASTORE"));
469  break;
471  if (NULL != qe->qc.rc.proc)
472  qe->qc.rc.proc (qe->qc.rc.proc_cls,
473  NULL,
474  0,
475  NULL,
476  0,
477  0,
478  0,
479  0,
481  0);
482  break;
483  default:
484  GNUNET_break (0);
485  }
486  free_queue_entry (qe);
487  }
488  if (GNUNET_YES == drop)
489  {
491  "Re-connecting to issue DROP!\n");
492  GNUNET_assert (NULL == h->mq);
493  h->mq = GNUNET_CLIENT_connect (h->cfg,
494  "datastore",
495  NULL,
497  h);
498  if (NULL != h->mq)
499  {
500  struct GNUNET_MessageHeader *hdr;
501  struct GNUNET_MQ_Envelope *env;
502 
503  env = GNUNET_MQ_msg (hdr,
507  h);
508  GNUNET_MQ_send (h->mq,
509  env);
510  return;
511  }
512  GNUNET_break (0);
513  }
515  GNUNET_NO);
516  h->stats = NULL;
517  GNUNET_free (h);
518 }
#define GNUNET_MESSAGE_TYPE_DATASTORE_STATUS
Message sent by datastore to client informing about status processing a request (in response to RESER...
static struct GNUNET_DATASTORE_QueueEntry * qe
Current operation.
struct GNUNET_MQ_Handle * mq
Current connection to the datastore service.
#define GNUNET_TIME_UNIT_ZERO_ABS
Absolute time zero.
struct GNUNET_MQ_Handle * GNUNET_CLIENT_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *service_name, const struct GNUNET_MQ_MessageHandler *handlers, GNUNET_MQ_ErrorHandler error_handler, void *error_handler_cls)
Create a message queue to connect to a GNUnet service.
Definition: client.c:901
struct GNUNET_STATISTICS_Handle * stats
Handle for statistics.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
void * proc_cls
Closure for proc.
Definition: datastore_api.c:82
struct GNUNET_SCHEDULER_Task * reconnect_task
Task for trying to reconnect.
#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
void GNUNET_STATISTICS_destroy(struct GNUNET_STATISTICS_Handle *h, int sync_first)
Destroy a handle (free all state associated with it).
const struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
#define _(String)
GNU gettext support macro.
Definition: platform.h:208
struct StatusContext sc
Definition: datastore_api.c:93
GNUNET_DATASTORE_DatumProcessor proc
Function to call with the result.
Definition: datastore_api.c:77
struct ResultContext rc
Definition: datastore_api.c:95
static void free_queue_entry(struct GNUNET_DATASTORE_QueueEntry *qe)
Free a queue entry.
Entry in our priority queue.
#define GNUNET_MESSAGE_TYPE_DATASTORE_DROP
Message sent by datastore client to drop the database.
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
GNUNET_DATASTORE_ContinuationWithStatus cont
Continuation to call with the status.
Definition: datastore_api.c:59
static void disconnect_after_drop(void *cls)
Task used by to disconnect from the datastore after we send the GNUNET_MESSAGE_TYPE_DATASTORE_DROP me...
#define LOG(kind,...)
Definition: datastore_api.c:34
union QueueContext qc
Context for the operation.
#define GNUNET_SYSERR
Definition: gnunet_common.h:79
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
static void disconnect_on_mq_error(void *cls, enum GNUNET_MQ_Error error)
Handle error in sending drop request to datastore.
struct GNUNET_DATASTORE_QueueEntry * queue_head
Current head of priority queue.
uint16_t response_type
Expected response type.
Header for all communications.
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:824
#define GNUNET_YES
Definition: gnunet_common.h:80
void * cont_cls
Closure for cont.
Definition: datastore_api.c:64
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
#define GNUNET_MESSAGE_TYPE_DATASTORE_DATA
Message sent by datastore to client providing requested data (in response to GET or GET_RANDOM reques...
#define GNUNET_free(ptr)
Wrapper around free.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:965
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_DATASTORE_reserve()

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

Parameters
hhandle to the datastore
amounthow much space (in bytes) should be reserved (for content only)
entrieshow many entries will be created (to calculate per-entry overhead)
contcontinuation to call when done; "success" will be set to a positive reservation value if space could be reserved.
cont_clsclosure for cont
Returns
NULL if the entry was not queued, otherwise a handle that can be used to cancel; note that even if NULL is returned, the callback will be invoked (or rather, will already have been invoked)

Definition at line 1058 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(), LOG, make_queue_entry(), process_queue(), qe, QueueContext::sc, and GNUNET_DATASTORE_Handle::stats.

Referenced by GNUNET_FS_publish_start().

1063 {
1065  struct GNUNET_MQ_Envelope *env;
1066  struct ReserveMessage *rm;
1067  union QueueContext qc;
1068 
1069  if (NULL == cont)
1070  cont = &drop_status_cont;
1072  "Asked to reserve %llu bytes of data and %u entries\n",
1073  (unsigned long long) amount,
1074  (unsigned int) entries);
1075  env = GNUNET_MQ_msg (rm,
1077  rm->entries = htonl (entries);
1078  rm->amount = GNUNET_htonll (amount);
1079 
1080  qc.sc.cont = cont;
1081  qc.sc.cont_cls = cont_cls;
1082  qe = make_queue_entry (h,
1083  env,
1084  UINT_MAX,
1085  UINT_MAX,
1087  &qc);
1088  if (NULL == qe)
1089  {
1091  "Could not create queue entry to reserve\n");
1092  return NULL;
1093  }
1095  gettext_noop ("# RESERVE requests executed"),
1096  1,
1097  GNUNET_NO);
1098  process_queue (h);
1099  return qe;
1100 }
#define GNUNET_MESSAGE_TYPE_DATASTORE_STATUS
Message sent by datastore to client informing about status processing a request (in response to RESER...
static struct GNUNET_DATASTORE_QueueEntry * qe
Current operation.
uint32_t entries
Number of items to reserve.
Definition: datastore.h:49
Message from datastore service informing client about the current size of the datastore.
Definition: datastore.h:39
static void process_queue(struct GNUNET_DATASTORE_Handle *h)
Process entries in the queue (or do nothing if we are already doing so).
struct GNUNET_STATISTICS_Handle * stats
Handle for statistics.
#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_MESSAGE_TYPE_DATASTORE_RESERVE
Message sent by datastore client on join.
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
static void drop_status_cont(void *cls, int32_t result, struct GNUNET_TIME_Absolute min_expiration, const char *emsg)
Dummy continuation used to do nothing (but be non-zero).
Entry in our priority queue.
struct ListEntry * entries
List of peers in the list.
#define LOG(kind,...)
Definition: datastore_api.c:34
static struct GNUNET_DATASTORE_QueueEntry * make_queue_entry(struct GNUNET_DATASTORE_Handle *h, struct GNUNET_MQ_Envelope *env, unsigned int queue_priority, unsigned int max_queue_size, uint16_t expected_type, const union QueueContext *qc)
Create a new entry for our priority queue (and possibly discard other entires if the queue is getting...
uint64_t GNUNET_htonll(uint64_t n)
Convert unsigned 64-bit integer to network byte order.
Definition: common_endian.c:35
Context for a queue operation.
Definition: datastore_api.c:90
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
#define gettext_noop(String)
Definition: gettext.h:69
uint64_t amount
Number of bytes to reserve.
Definition: datastore.h:54
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_DATASTORE_put()

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.

Parameters
hhandle to the datastore
ridreservation ID to use (from "reserve"); use 0 if no prior reservation was made
keykey for the value
sizenumber of bytes in data
datacontent stored
typetype of the content
prioritypriority of the content
anonymityanonymity-level for the content
replicationhow often should the content be replicated to other peers?
expirationexpiration time for the content
queue_priorityranking of this request in the priority queue
max_queue_sizeat what queue size should this request be dropped (if other requests of higher priority are in the queue)
contcontinuation to call when done
cont_clsclosure for cont
Returns
NULL if the entry was not queued, otherwise a handle that can be used to cancel; note that even if NULL is returned, the callback will be invoked (or rather, will already have been invoked)

If the item is already present, the priorities are summed up and the higher expiration time and lower anonymity level is used.

Parameters
hhandle to the datastore
ridreservation ID to use (from "reserve"); use 0 if no prior reservation was made
keykey for the value
sizenumber of bytes in data
datacontent stored
typetype of the content
prioritypriority of the content
anonymityanonymity-level for the content
replicationhow often should the content be replicated to other peers?
expirationexpiration time for the content
queue_priorityranking of this request in the priority queue
max_queue_sizeat what queue size should this request be dropped (if other requests of higher priority are in the queue)
contcontinuation to call when done
cont_clsclosure for cont
Returns
NULL if the entry was not queued, otherwise a handle that can be used to cancel; note that even if NULL is returned, the callback will be invoked (or rather, will already have been invoked)

Definition at line 973 of file datastore_api.c.

References DataMessage::anonymity, StatusContext::cont, StatusContext::cont_cls, env, 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, key, DataMessage::key, LOG, make_queue_entry(), DataMessage::priority, process_queue(), qe, DataMessage::replication, DataMessage::rid, QueueContext::sc, DataMessage::size, GNUNET_DATASTORE_Handle::stats, and DataMessage::type.

Referenced by block_proc(), GNUNET_FS_publish_ublock_(), handle_dht_reply(), handle_p2p_put(), and put_cb().

987 {
989  struct GNUNET_MQ_Envelope *env;
990  struct DataMessage *dm;
991  union QueueContext qc;
992 
993  if (size + sizeof (*dm) >= GNUNET_MAX_MESSAGE_SIZE)
994  {
995  GNUNET_break (0);
996  return NULL;
997  }
998 
1000  "Asked to put %u bytes of data under key `%s' for %s\n",
1001  size,
1002  GNUNET_h2s (key),
1004  GNUNET_YES));
1005  env = GNUNET_MQ_msg_extra (dm,
1006  size,
1008  dm->rid = htonl (rid);
1009  dm->size = htonl ((uint32_t) size);
1010  dm->type = htonl (type);
1011  dm->priority = htonl (priority);
1012  dm->anonymity = htonl (anonymity);
1013  dm->replication = htonl (replication);
1014  dm->expiration = GNUNET_TIME_absolute_hton (expiration);
1015  dm->key = *key;
1016  GNUNET_memcpy (&dm[1],
1017  data,
1018  size);
1019  qc.sc.cont = cont;
1020  qc.sc.cont_cls = cont_cls;
1021  qe = make_queue_entry (h,
1022  env,
1023  queue_priority,
1024  max_queue_size,
1026  &qc);
1027  if (NULL == qe)
1028  {
1030  "Could not create queue entry for PUT\n");
1031  return NULL;
1032  }
1034  gettext_noop ("# PUT requests executed"),
1035  1,
1036  GNUNET_NO);
1037  process_queue (h);
1038  return qe;
1039 }
#define GNUNET_MESSAGE_TYPE_DATASTORE_STATUS
Message sent by datastore to client informing about status processing a request (in response to RESER...
static struct GNUNET_DATASTORE_QueueEntry * qe
Current operation.
struct GNUNET_TIME_AbsoluteNBO expiration
Expiration time (NBO); zero for remove.
Definition: datastore.h:252
uint32_t type
Type of the item (NBO), zero for remove, (actually an enum GNUNET_BLOCK_Type)
Definition: datastore.h:219
static void process_queue(struct GNUNET_DATASTORE_Handle *h)
Process entries in the queue (or do nothing if we are already doing so).
struct GNUNET_STATISTICS_Handle * stats
Handle for statistics.
static unsigned int replication
#define GNUNET_NO
Definition: gnunet_common.h:81
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
#define GNUNET_MESSAGE_TYPE_DATASTORE_PUT
Message sent by datastore client to store data.
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct...
Definition: gnunet_mq_lib.h:52
Entry in our priority queue.
#define GNUNET_memcpy(dst, src, n)
const char * GNUNET_STRINGS_relative_time_to_string(struct GNUNET_TIME_Relative delta, int do_round)
Give relative time in human-readable fancy format.
Definition: strings.c:727
#define LOG(kind,...)
Definition: datastore_api.c:34
uint32_t replication
Desired replication level.
Definition: datastore.h:234
static struct GNUNET_DATASTORE_QueueEntry * make_queue_entry(struct GNUNET_DATASTORE_Handle *h, struct GNUNET_MQ_Envelope *env, unsigned int queue_priority, unsigned int max_queue_size, uint16_t expected_type, const union QueueContext *qc)
Create a new entry for our priority queue (and possibly discard other entires if the queue is getting...
uint32_t rid
Reservation ID to use; use zero for none.
Definition: datastore.h:209
Message transmitting content from or to the datastore service.
Definition: datastore.h:196
struct GNUNET_HashCode key
The key used in the DHT.
static unsigned int size
Size of the "table".
Definition: peer.c:67
Context for a queue operation.
Definition: datastore_api.c:90
uint32_t size
Number of bytes in the item (NBO).
Definition: datastore.h:214
uint32_t anonymity
Desired anonymity level (NBO), zero for remove.
Definition: datastore.h:229
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
#define GNUNET_MAX_MESSAGE_SIZE
Largest supported message (to be precise, one byte more than the largest possible message...
struct GNUNET_HashCode key
Key under which the item can be found.
Definition: datastore.h:257
uint32_t priority
Priority of the item (NBO), zero for remove.
Definition: datastore.h:224
struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_remaining(struct GNUNET_TIME_Absolute future)
Given a timestamp in the future, how much time remains until then?
Definition: time.c:331
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
#define GNUNET_YES
Definition: gnunet_common.h:80
static unsigned int anonymity
uint32_t data
The data value.
struct GNUNET_TIME_AbsoluteNBO GNUNET_TIME_absolute_hton(struct GNUNET_TIME_Absolute a)
Convert absolute time to network byte order.
Definition: time.c:654
#define gettext_noop(String)
Definition: gettext.h:69
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_DATASTORE_release_reserve()

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.

Parameters
hhandle to the datastore
ridreservation ID (value of "success" in original continuation from the "reserve" function).
queue_priorityranking of this request in the priority queue
max_queue_sizeat what queue size should this request be dropped (if other requests of higher priority are in the queue)
queue_priorityranking of this request in the priority queue
max_queue_sizeat what queue size should this request be dropped (if other requests of higher priority are in the queue)
contcontinuation to call when done
cont_clsclosure for cont
Returns
NULL if the entry was not queued, otherwise a handle that can be used to cancel; note that even if NULL is returned, the callback will be invoked (or rather, will already have been invoked)

Definition at line 1124 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(), LOG, make_queue_entry(), process_queue(), qe, ReleaseReserveMessage::rid, QueueContext::sc, and GNUNET_DATASTORE_Handle::stats.

Referenced by publish_sblocks_cont().

1130 {
1132  struct GNUNET_MQ_Envelope *env;
1133  struct ReleaseReserveMessage *rrm;
1134  union QueueContext qc;
1135 
1136  if (NULL == cont)
1137  cont = &drop_status_cont;
1139  "Asked to release reserve %d\n",
1140  rid);
1141  env = GNUNET_MQ_msg (rrm,
1143  rrm->rid = htonl (rid);
1144  qc.sc.cont = cont;
1145  qc.sc.cont_cls = cont_cls;
1146  qe = make_queue_entry (h,
1147  env,
1148  queue_priority,
1149  max_queue_size,
1151  &qc);
1152  if (NULL == qe)
1153  {
1155  "Could not create queue entry to release reserve\n");
1156  return NULL;
1157  }
1159  gettext_noop
1160  ("# RELEASE RESERVE requests executed"), 1,
1161  GNUNET_NO);
1162  process_queue (h);
1163  return qe;
1164 }
#define GNUNET_MESSAGE_TYPE_DATASTORE_STATUS
Message sent by datastore to client informing about status processing a request (in response to RESER...
static struct GNUNET_DATASTORE_QueueEntry * qe
Current operation.
static void process_queue(struct GNUNET_DATASTORE_Handle *h)
Process entries in the queue (or do nothing if we are already doing so).
struct GNUNET_STATISTICS_Handle * stats
Handle for statistics.
Message from datastore client informing service that the remainder of the reserved bytes can now be r...
Definition: datastore.h:90
#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
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
static void drop_status_cont(void *cls, int32_t result, struct GNUNET_TIME_Absolute min_expiration, const char *emsg)
Dummy continuation used to do nothing (but be non-zero).
#define GNUNET_MESSAGE_TYPE_DATASTORE_RELEASE_RESERVE
Message sent by datastore client on join.
Entry in our priority queue.
#define LOG(kind,...)
Definition: datastore_api.c:34
static struct GNUNET_DATASTORE_QueueEntry * make_queue_entry(struct GNUNET_DATASTORE_Handle *h, struct GNUNET_MQ_Envelope *env, unsigned int queue_priority, unsigned int max_queue_size, uint16_t expected_type, const union QueueContext *qc)
Create a new entry for our priority queue (and possibly discard other entires if the queue is getting...
Context for a queue operation.
Definition: datastore_api.c:90
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
int32_t rid
Reservation id.
Definition: datastore.h:100
#define gettext_noop(String)
Definition: gettext.h:69
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_DATASTORE_remove()

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.

Parameters
hhandle to the datastore
keykey for the value
sizenumber of bytes in data
datacontent stored
queue_priorityranking of this request in the priority queue
max_queue_sizeat what queue size should this request be dropped (if other requests of higher priority are in the queue)
contcontinuation to call when done
cont_clsclosure for cont
Returns
NULL if the entry was not queued, otherwise a handle that can be used to cancel; note that even if NULL is returned, the callback will be invoked (or rather, will already have been invoked)

The cont continuation 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.

Parameters
hhandle to the datastore
keykey for the value
sizenumber of bytes in data
datacontent stored
queue_priorityranking of this request in the priority queue
max_queue_sizeat what queue size should this request be dropped (if other requests of higher priority are in the queue)
contcontinuation to call when done
cont_clsclosure for cont
Returns
NULL if the entry was not queued, otherwise a handle that can be used to cancel; note that even if NULL is returned, the callback will be invoked (or rather, will already have been invoked)

Definition at line 1188 of file datastore_api.c.

References StatusContext::cont, StatusContext::cont_cls, 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(), key, DataMessage::key, LOG, make_queue_entry(), process_queue(), qe, QueueContext::sc, DataMessage::size, and GNUNET_DATASTORE_Handle::stats.

Referenced by GNUNET_FS_handle_on_demand_block(), process_kblock_for_unindex(), process_local_reply(), and unindex_process().

1196 {
1198  struct DataMessage *dm;
1199  struct GNUNET_MQ_Envelope *env;
1200  union QueueContext qc;
1201 
1202  if (sizeof (*dm) + size >= GNUNET_MAX_MESSAGE_SIZE)
1203  {
1204  GNUNET_break (0);
1205  return NULL;
1206  }
1207  if (NULL == cont)
1208  cont = &drop_status_cont;
1210  "Asked to remove %u bytes under key `%s'\n",
1211  size,
1212  GNUNET_h2s (key));
1213  env = GNUNET_MQ_msg_extra (dm,
1214  size,
1216  dm->size = htonl (size);
1217  dm->key = *key;
1218  GNUNET_memcpy (&dm[1],
1219  data,
1220  size);
1221 
1222  qc.sc.cont = cont;
1223  qc.sc.cont_cls = cont_cls;
1224 
1225  qe = make_queue_entry (h,
1226  env,
1227  queue_priority,
1228  max_queue_size,
1230  &qc);
1231  if (NULL == qe)
1232  {
1234  "Could not create queue entry for REMOVE\n");
1235  return NULL;
1236  }
1238  gettext_noop ("# REMOVE requests executed"),
1239  1,
1240  GNUNET_NO);
1241  process_queue (h);
1242  return qe;
1243 }
#define GNUNET_MESSAGE_TYPE_DATASTORE_STATUS
Message sent by datastore to client informing about status processing a request (in response to RESER...
static struct GNUNET_DATASTORE_QueueEntry * qe
Current operation.
static void process_queue(struct GNUNET_DATASTORE_Handle *h)
Process entries in the queue (or do nothing if we are already doing so).
struct GNUNET_STATISTICS_Handle * stats
Handle for statistics.
#define GNUNET_NO
Definition: gnunet_common.h:81
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
static void drop_status_cont(void *cls, int32_t result, struct GNUNET_TIME_Absolute min_expiration, const char *emsg)
Dummy continuation used to do nothing (but be non-zero).
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct...
Definition: gnunet_mq_lib.h:52
Entry in our priority queue.
#define GNUNET_memcpy(dst, src, n)
#define LOG(kind,...)
Definition: datastore_api.c:34
static struct GNUNET_DATASTORE_QueueEntry * make_queue_entry(struct GNUNET_DATASTORE_Handle *h, struct GNUNET_MQ_Envelope *env, unsigned int queue_priority, unsigned int max_queue_size, uint16_t expected_type, const union QueueContext *qc)
Create a new entry for our priority queue (and possibly discard other entires if the queue is getting...
Message transmitting content from or to the datastore service.
Definition: datastore.h:196
struct GNUNET_HashCode key
The key used in the DHT.
static unsigned int size
Size of the "table".
Definition: peer.c:67
Context for a queue operation.
Definition: datastore_api.c:90
uint32_t size
Number of bytes in the item (NBO).
Definition: datastore.h:214
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
#define GNUNET_MAX_MESSAGE_SIZE
Largest supported message (to be precise, one byte more than the largest possible message...
struct GNUNET_HashCode key
Key under which the item can be found.
Definition: datastore.h:257
#define GNUNET_MESSAGE_TYPE_DATASTORE_REMOVE
Message sent by datastore client to remove data.
uint32_t data
The data value.
#define gettext_noop(String)
Definition: gettext.h:69
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_DATASTORE_get_key()

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.

Parameters
hhandle to the datastore
next_uidreturn the result with lowest uid >= next_uid
randomif true, return a random result instead of using next_uid
keymaybe NULL (to match all entries)
typedesired type, 0 for any
queue_priorityranking of this request in the priority queue
max_queue_sizeat what queue size should this request be dropped (if other requests of higher priority are in the queue)
procfunction to call on a matching value; or with a NULL value if no datum matches
proc_clsclosure for proc
Returns
NULL if the entry was not queued, otherwise a handle that can be used to cancel

The processor will only be called once.

Parameters
hhandle to the datastore
next_uidreturn the result with lowest uid >= next_uid
randomif true, return a random result instead of using next_uid
keymaybe NULL (to match all entries)
typedesired type, 0 for any
queue_priorityranking of this request in the priority queue
max_queue_sizeat what queue size should this request be dropped (if other requests of higher priority are in the queue)
procfunction to call on each matching value; will be called once with a NULL value at the end
proc_clsclosure for proc
Returns
NULL if the entry was not queued, otherwise a handle that can be used to cancel

Definition at line 1386 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(), 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, GNUNET_DATASTORE_Handle::stats, 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().

1395 {
1397  struct GNUNET_MQ_Envelope *env;
1398  struct GetKeyMessage *gkm;
1399  struct GetMessage *gm;
1400  union QueueContext qc;
1401 
1402  GNUNET_assert (NULL != proc);
1404  "Asked to look for data of type %u under key `%s'\n",
1405  (unsigned int) type,
1406  GNUNET_h2s (key));
1407  if (NULL == key)
1408  {
1409  env = GNUNET_MQ_msg (gm,
1411  gm->type = htonl (type);
1412  gm->next_uid = GNUNET_htonll (next_uid);
1413  gm->random = random;
1414  }
1415  else
1416  {
1417  env = GNUNET_MQ_msg (gkm,
1419  gkm->type = htonl (type);
1420  gkm->next_uid = GNUNET_htonll (next_uid);
1421  gkm->random = random;
1422  gkm->key = *key;
1423  }
1424  qc.rc.proc = proc;
1425  qc.rc.proc_cls = proc_cls;
1426  qe = make_queue_entry (h,
1427  env,
1428  queue_priority,
1429  max_queue_size,
1431  &qc);
1432  if (NULL == qe)
1433  {
1435  "Could not queue request for `%s'\n",
1436  GNUNET_h2s (key));
1437  return NULL;
1438  }
1439 #if INSANE_STATISTICS
1441  gettext_noop ("# GET requests executed"),
1442  1,
1443  GNUNET_NO);
1444 #endif
1445  process_queue (h);
1446  return qe;
1447 }
static struct GNUNET_DATASTORE_QueueEntry * qe
Current operation.
uint32_t random
If true return a random result.
Definition: datastore.h:129
static void process_queue(struct GNUNET_DATASTORE_Handle *h)
Process entries in the queue (or do nothing if we are already doing so).
struct GNUNET_STATISTICS_Handle * stats
Handle for statistics.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
uint32_t random
If true return a random result.
Definition: datastore.h:163
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
Message to the datastore service asking about specific content.
Definition: datastore.h:109
#define GNUNET_NO
Definition: gnunet_common.h:81
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
uint64_t next_uid
UID at which to start the search.
Definition: datastore.h:158
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
Entry in our priority queue.
Message to the datastore service asking about specific content.
Definition: datastore.h:143
uint32_t type
Desired content type.
Definition: datastore.h:119
uint32_t type
Desired content type.
Definition: datastore.h:153
#define LOG(kind,...)
Definition: datastore_api.c:34
static struct GNUNET_DATASTORE_QueueEntry * make_queue_entry(struct GNUNET_DATASTORE_Handle *h, struct GNUNET_MQ_Envelope *env, unsigned int queue_priority, unsigned int max_queue_size, uint16_t expected_type, const union QueueContext *qc)
Create a new entry for our priority queue (and possibly discard other entires if the queue is getting...
uint64_t GNUNET_htonll(uint64_t n)
Convert unsigned 64-bit integer to network byte order.
Definition: common_endian.c:35
struct GNUNET_HashCode key
Desired key.
Definition: datastore.h:134
struct GNUNET_HashCode key
The key used in the DHT.
Context for a queue operation.
Definition: datastore_api.c:90
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
#define GNUNET_MESSAGE_TYPE_DATASTORE_GET_KEY
Message sent by datastore client to get data by key.
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
uint64_t next_uid
UID at which to start the search.
Definition: datastore.h:124
#define GNUNET_MESSAGE_TYPE_DATASTORE_GET
Message sent by datastore client to get data.
#define GNUNET_MESSAGE_TYPE_DATASTORE_DATA
Message sent by datastore to client providing requested data (in response to GET or GET_RANDOM reques...
#define gettext_noop(String)
Definition: gettext.h:69
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_DATASTORE_get_zero_anonymity()

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.

Parameters
hhandle to the datastore
next_uidreturn the result with lowest uid >= next_uid
queue_priorityranking of this request in the priority queue
max_queue_sizeat what queue size should this request be dropped (if other requests of higher priority are in the queue)
typeallowed type for the operation (never zero)
procfunction to call on a random value; it will be called once with a value (if available) or with NULL if none value exists.
proc_clsclosure for proc
Returns
NULL if the entry was not queued, otherwise a handle that can be used to cancel
Parameters
hhandle to the datastore
next_uidreturn the result with lowest uid >= next_uid
queue_priorityranking of this request in the priority queue
max_queue_sizeat what queue size should this request be dropped (if other requests of higher priority are in the queue)
typeallowed type for the operation (never zero)
procfunction to call on a random value; it will be called once with a value (if available) or with NULL if none value exists.
proc_clsclosure for proc
Returns
NULL if the entry was not queued, otherwise a handle that can be used to cancel

Definition at line 1322 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(), LOG, m, make_queue_entry(), GetZeroAnonymityMessage::next_uid, ResultContext::proc, ResultContext::proc_cls, process_queue(), qe, QueueContext::rc, GNUNET_DATASTORE_Handle::stats, and GetZeroAnonymityMessage::type.

Referenced by gather_dht_put_blocks().

1329 {
1331  struct GNUNET_MQ_Envelope *env;
1332  struct GetZeroAnonymityMessage *m;
1333  union QueueContext qc;
1334 
1335  GNUNET_assert (NULL != proc);
1338  "Asked to get a zero-anonymity entry of type %d\n",
1339  type);
1340  env = GNUNET_MQ_msg (m,
1342  m->type = htonl ((uint32_t) type);
1343  m->next_uid = GNUNET_htonll (next_uid);
1344  qc.rc.proc = proc;
1345  qc.rc.proc_cls = proc_cls;
1346  qe = make_queue_entry (h,
1347  env,
1348  queue_priority,
1349  max_queue_size,
1351  &qc);
1352  if (NULL == qe)
1353  {
1355  "Could not create queue entry for zero-anonymity procation\n");
1356  return NULL;
1357  }
1359  gettext_noop
1360  ("# GET ZERO ANONYMITY requests executed"), 1,
1361  GNUNET_NO);
1362  process_queue (h);
1363  return qe;
1364 }
static struct GNUNET_DATASTORE_QueueEntry * qe
Current operation.
uint32_t type
Desired content type (actually an enum GNUNET_BLOCK_Type)
Definition: datastore.h:182
Any type of block, used as a wildcard when searching.
static void process_queue(struct GNUNET_DATASTORE_Handle *h)
Process entries in the queue (or do nothing if we are already doing so).
struct GNUNET_STATISTICS_Handle * stats
Handle for statistics.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#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
Message to the datastore service asking about zero anonymity content.
Definition: datastore.h:172
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
static struct GNUNET_ARM_MonitorHandle * m
Monitor connection with ARM.
Definition: gnunet-arm.c:99
Entry in our priority queue.
#define LOG(kind,...)
Definition: datastore_api.c:34
static struct GNUNET_DATASTORE_QueueEntry * make_queue_entry(struct GNUNET_DATASTORE_Handle *h, struct GNUNET_MQ_Envelope *env, unsigned int queue_priority, unsigned int max_queue_size, uint16_t expected_type, const union QueueContext *qc)
Create a new entry for our priority queue (and possibly discard other entires if the queue is getting...
uint64_t GNUNET_htonll(uint64_t n)
Convert unsigned 64-bit integer to network byte order.
Definition: common_endian.c:35
Context for a queue operation.
Definition: datastore_api.c:90
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
uint64_t next_uid
UID at which to start the search.
Definition: datastore.h:187
#define GNUNET_MESSAGE_TYPE_DATASTORE_GET_ZERO_ANONYMITY
Message sent by datastore client to get random data.
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
#define GNUNET_MESSAGE_TYPE_DATASTORE_DATA
Message sent by datastore to client providing requested data (in response to GET or GET_RANDOM reques...
#define gettext_noop(String)
Definition: gettext.h:69
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_DATASTORE_get_for_replication()

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

Parameters
hhandle to the datastore
queue_priorityranking of this request in the priority queue
max_queue_sizeat what queue size should this request be dropped (if other requests of higher priority are in the queue)
procfunction 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_clsclosure for proc
Returns
NULL if the entry was not queued, otherwise a handle that can be used to cancel

Definition at line 1266 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(), LOG, m, make_queue_entry(), ResultContext::proc, ResultContext::proc_cls, process_queue(), qe, QueueContext::rc, and GNUNET_DATASTORE_Handle::stats.

Referenced by gather_migration_blocks().

1271 {
1273  struct GNUNET_MQ_Envelope *env;
1274  struct GNUNET_MessageHeader *m;
1275  union QueueContext qc;
1276 
1277  GNUNET_assert (NULL != proc);
1279  "Asked to get replication entry\n");
1280  env = GNUNET_MQ_msg (m,
1282  qc.rc.proc = proc;
1283  qc.rc.proc_cls = proc_cls;
1284  qe = make_queue_entry (h,
1285  env,
1286  queue_priority,
1287  max_queue_size,
1289  &qc);
1290  if (NULL == qe)
1291  {
1293  "Could not create queue entry for GET REPLICATION\n");
1294  return NULL;
1295  }
1297  gettext_noop
1298  ("# GET REPLICATION requests executed"), 1,
1299  GNUNET_NO);
1300  process_queue (h);
1301  return qe;
1302 }
static struct GNUNET_DATASTORE_QueueEntry * qe
Current operation.
static void process_queue(struct GNUNET_DATASTORE_Handle *h)
Process entries in the queue (or do nothing if we are already doing so).
struct GNUNET_STATISTICS_Handle * stats
Handle for statistics.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
#define GNUNET_MESSAGE_TYPE_DATASTORE_GET_REPLICATION
Message sent by datastore client to get random data.
#define GNUNET_NO
Definition: gnunet_common.h:81
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
static struct GNUNET_ARM_MonitorHandle * m
Monitor connection with ARM.
Definition: gnunet-arm.c:99
Entry in our priority queue.
#define LOG(kind,...)
Definition: datastore_api.c:34
static struct GNUNET_DATASTORE_QueueEntry * make_queue_entry(struct GNUNET_DATASTORE_Handle *h, struct GNUNET_MQ_Envelope *env, unsigned int queue_priority, unsigned int max_queue_size, uint16_t expected_type, const union QueueContext *qc)
Create a new entry for our priority queue (and possibly discard other entires if the queue is getting...
Context for a queue operation.
Definition: datastore_api.c:90
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
Header for all communications.
#define GNUNET_MESSAGE_TYPE_DATASTORE_DATA
Message sent by datastore to client providing requested data (in response to GET or GET_RANDOM reques...
#define gettext_noop(String)
Definition: gettext.h:69
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_DATASTORE_cancel()

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.

Parameters
qeoperation to cancel

Definition at line 1457 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(), GNUNET_DATASTORE_Handle::queue_head, and GNUNET_DATASTORE_Handle::skip_next_messages.

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().

1458 {
1459  struct GNUNET_DATASTORE_Handle *h = qe->h;
1460 
1462  "Pending DATASTORE request %p cancelled (%d, %d)\n",
1463  qe,
1464  NULL == qe->env,
1465  h->queue_head == qe);
1466  if (NULL == qe->env)
1467  {
1468  free_queue_entry (qe);
1469  h->skip_next_messages++;
1470  return;
1471  }
1472  free_queue_entry (qe);
1473  process_queue (h);
1474 }
struct GNUNET_DATASTORE_Handle * h
Handle to the master context.
static void process_queue(struct GNUNET_DATASTORE_Handle *h)
Process entries in the queue (or do nothing if we are already doing so).
struct GNUNET_MQ_Envelope * env
Envelope of the request to transmit, NULL after transmission.
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:94
static void free_queue_entry(struct GNUNET_DATASTORE_QueueEntry *qe)
Free a queue entry.
unsigned int skip_next_messages
We should ignore the next message(s) from the service.
#define LOG(kind,...)
Definition: datastore_api.c:34
Handle to the datastore service.
struct GNUNET_DATASTORE_QueueEntry * queue_head
Current head of priority queue.
Here is the call graph for this function:
Here is the caller graph for this function: