2 This file is part of GNUnet.
3 (C) 2009, 2010 Christian Grothoff (and other contributing authors)
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 2, or (at your
8 option) any later version.
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
22 * @file fs/gnunet-service-fs_drq.h
23 * @brief queueing of requests to the datastore service
24 * @author Christian Grothoff
26 #ifndef GNUNET_SERVICE_FS_DRQ_H
27 #define GNUNET_SERVICE_FS_DRQ_H
29 #include "gnunet_datastore_service.h"
30 #include "gnunet_util_lib.h"
34 * Handle for pending, abortable requests for the datastore.
36 struct DatastoreRequestQueue;
40 * Iterate over the results for a particular key
41 * in the datastore. The iterator will only be called
42 * once initially; if the first call did contain a
43 * result, further results can be obtained by calling
44 * "GNUNET_DATASTORE_get_next" with the given argument.
46 * @param key maybe NULL (to match all entries)
47 * @param type desired type, 0 for any
48 * @param iter function to call on each matching value;
49 * will be called once with a NULL value at the end
50 * @param iter_cls closure for iter
51 * @param timeout how long to wait at most for a response
53 struct DatastoreRequestQueue *
54 GNUNET_FS_drq_get (const GNUNET_HashCode * key,
56 GNUNET_DATASTORE_Iterator iter,
58 struct GNUNET_TIME_Relative timeout);
63 GNUNET_FS_drq_get_cancel (struct DatastoreRequestQueue *drq);
67 * Function called to trigger obtaining the next result
68 * from the datastore. Must be called (directly or indirectly)
69 * from the 'iter' callback given to 'GNUNET_FS_drq_get'.
70 * Not calling 'get_next' means no other datastore
71 * interactions (other than remove) will happen.
73 * @param more GNUNET_YES to get more results, GNUNET_NO to abort
74 * iteration (with a final call to "iter" with key/data == NULL).
77 GNUNET_FS_drq_get_next (int more);
81 * Explicitly remove some content from the database.
82 * The "cont"inuation will be called with status
83 * "GNUNET_OK" if content was removed, "GNUNET_NO"
84 * if no matching entry was found and "GNUNET_SYSERR"
85 * on all other types of errors.
87 * @param key key for the value
88 * @param size number of bytes in data
89 * @param data content stored
90 * @param cont continuation to call when done
91 * @param cont_cls closure for cont
92 * @param timeout how long to wait at most for a response
95 GNUNET_FS_drq_remove (const GNUNET_HashCode *key,
96 uint32_t size, const void *data,
97 GNUNET_DATASTORE_ContinuationWithStatus cont,
99 struct GNUNET_TIME_Relative timeout);
104 * Explicitly remove some content from the database.
105 * The "cont"inuation will be called with status
106 * "GNUNET_OK" if content was removed, "GNUNET_NO"
107 * if no matching entry was found and "GNUNET_SYSERR"
108 * on all other types of errors.
110 * @param key key for the value
111 * @param size number of bytes in data
112 * @param data content stored
113 * @param cont continuation to call when done
114 * @param cont_cls closure for cont
115 * @param timeout how long to wait at most for a response
118 GNUNET_FS_drq_remove (const GNUNET_HashCode *key,
119 uint32_t size, const void *data,
120 GNUNET_DATASTORE_ContinuationWithStatus cont,
122 struct GNUNET_TIME_Relative timeout);
124 * Setup datastore request queues.
126 * @param s scheduler to use
127 * @param c configuration to use
128 * @return GNUNET_OK on success
131 GNUNET_FS_drq_init (struct GNUNET_SCHEDULER_Handle *s,
132 const struct GNUNET_CONFIGURATION_Handle *c);
136 /* end of gnunet-service-fs_drq.h */