diff options
Diffstat (limited to 'src/datastore/datastore_api.c')
-rw-r--r-- | src/datastore/datastore_api.c | 110 |
1 files changed, 82 insertions, 28 deletions
diff --git a/src/datastore/datastore_api.c b/src/datastore/datastore_api.c index 95ae25f03..960d7d34e 100644 --- a/src/datastore/datastore_api.c +++ b/src/datastore/datastore_api.c | |||
@@ -26,7 +26,6 @@ | |||
26 | * TODO: | 26 | * TODO: |
27 | * 1) clarify API (wrt. efficient UPDATE of priority/expiration after GET) | 27 | * 1) clarify API (wrt. efficient UPDATE of priority/expiration after GET) |
28 | * 2) implement INIT | 28 | * 2) implement INIT |
29 | * 3) implement SIZE handling (=> API impact?) | ||
30 | * 4) implement DROP | 29 | * 4) implement DROP |
31 | * 5) implement PUT | 30 | * 5) implement PUT |
32 | * 6) implement GET | 31 | * 6) implement GET |
@@ -93,17 +92,6 @@ struct GNUNET_DATASTORE_Handle | |||
93 | */ | 92 | */ |
94 | void *response_proc_cls; | 93 | void *response_proc_cls; |
95 | 94 | ||
96 | /** | ||
97 | * Current size of the datastore (cached). | ||
98 | */ | ||
99 | unsigned long long size; | ||
100 | |||
101 | /** | ||
102 | * Set to GNUNET_YES if we have received the size | ||
103 | * from the datastore. | ||
104 | */ | ||
105 | int ready; | ||
106 | |||
107 | }; | 95 | }; |
108 | 96 | ||
109 | 97 | ||
@@ -129,7 +117,6 @@ struct GNUNET_DATASTORE_Handle *GNUNET_DATASTORE_connect (struct | |||
129 | return NULL; /* oops */ | 117 | return NULL; /* oops */ |
130 | h = GNUNET_malloc (sizeof(struct GNUNET_DATASTORE_Handle)); | 118 | h = GNUNET_malloc (sizeof(struct GNUNET_DATASTORE_Handle)); |
131 | h->client = c; | 119 | h->client = c; |
132 | /* FIXME: send 'join' request */ | ||
133 | return h; | 120 | return h; |
134 | } | 121 | } |
135 | 122 | ||
@@ -154,19 +141,6 @@ void GNUNET_DATASTORE_disconnect (struct GNUNET_DATASTORE_Handle *h, | |||
154 | 141 | ||
155 | 142 | ||
156 | /** | 143 | /** |
157 | * Get the current on-disk size of the datastore. | ||
158 | * @param h handle to the datastore | ||
159 | * @return size estimate, -1 if datastore is not available (yet) | ||
160 | */ | ||
161 | unsigned long long GNUNET_DATASTORE_size (struct GNUNET_DATASTORE_Handle *h) | ||
162 | { | ||
163 | if (GNUNET_YES != h->ready) | ||
164 | return (unsigned long long) -1LL; | ||
165 | return h->size; | ||
166 | } | ||
167 | |||
168 | |||
169 | /** | ||
170 | * Store an item in the datastore. If the item is already present, | 144 | * Store an item in the datastore. If the item is already present, |
171 | * the priorities are summed up and the higher expiration time and | 145 | * the priorities are summed up and the higher expiration time and |
172 | * lower anonymity level is used. | 146 | * lower anonymity level is used. |
@@ -179,17 +153,89 @@ unsigned long long GNUNET_DATASTORE_size (struct GNUNET_DATASTORE_Handle *h) | |||
179 | * @param priority priority of the content | 153 | * @param priority priority of the content |
180 | * @param anonymity anonymity-level for the content | 154 | * @param anonymity anonymity-level for the content |
181 | * @param expiration expiration time for the content | 155 | * @param expiration expiration time for the content |
156 | * @param cont continuation to call when done | ||
157 | * @param cont_cls closure for cont | ||
182 | */ | 158 | */ |
183 | void | 159 | void |
184 | GNUNET_DATASTORE_put (struct GNUNET_DATASTORE_Handle *h, | 160 | GNUNET_DATASTORE_put (struct GNUNET_DATASTORE_Handle *h, |
161 | int rid, | ||
185 | const GNUNET_HashCode * key, | 162 | const GNUNET_HashCode * key, |
186 | uint32_t size, | 163 | uint32_t size, |
187 | const void *data, | 164 | const void *data, |
188 | uint32_t type, | 165 | uint32_t type, |
189 | uint32_t priority, | 166 | uint32_t priority, |
190 | uint32_t anonymity, | 167 | uint32_t anonymity, |
191 | struct GNUNET_TIME_Absolute expiration) | 168 | struct GNUNET_TIME_Absolute expiration, |
169 | GNUNET_DATASTORE_ContinuationWithStatus cont, | ||
170 | void *cont_cls) | ||
171 | { | ||
172 | cont (cont_cls, GNUNET_SYSERR, "not implemented"); | ||
173 | } | ||
174 | |||
175 | |||
176 | /** | ||
177 | * Reserve space in the datastore. This function should be used | ||
178 | * to avoid "out of space" failures during a longer sequence of "put" | ||
179 | * operations (for example, when a file is being inserted). | ||
180 | * | ||
181 | * @param h handle to the datastore | ||
182 | * @param amount how much space (in bytes) should be reserved (for content only) | ||
183 | * @param entries how many entries will be created (to calculate per-entry overhead) | ||
184 | * @param cont continuation to call when done; "success" will be set to | ||
185 | * a positive reservation value if space could be reserved. | ||
186 | * @param cont_cls closure for cont | ||
187 | */ | ||
188 | void | ||
189 | GNUNET_DATASTORE_reserve (struct GNUNET_DATASTORE_Handle *h, | ||
190 | uint64_t amount, | ||
191 | uint64_t entries, | ||
192 | GNUNET_DATASTORE_ContinuationWithStatus cont, | ||
193 | void *cont_cls) | ||
192 | { | 194 | { |
195 | cont (cont_cls, GNUNET_SYSERR, "not implemented"); | ||
196 | } | ||
197 | |||
198 | |||
199 | /** | ||
200 | * Signal that all of the data for which a reservation was made has | ||
201 | * been stored and that whatever excess space might have been reserved | ||
202 | * can now be released. | ||
203 | * | ||
204 | * @param h handle to the datastore | ||
205 | * @param rid reservation ID (value of "success" in original continuation | ||
206 | * from the "reserve" function). | ||
207 | * @param cont continuation to call when done | ||
208 | * @param cont_cls closure for cont | ||
209 | */ | ||
210 | void | ||
211 | GNUNET_DATASTORE_release_reserve (struct GNUNET_DATASTORE_Handle *h, | ||
212 | int rid, | ||
213 | GNUNET_DATASTORE_ContinuationWithStatus cont, | ||
214 | void *cont_cls) | ||
215 | { | ||
216 | cont (cont_cls, GNUNET_OK, NULL); | ||
217 | } | ||
218 | |||
219 | |||
220 | /** | ||
221 | * Update a value in the datastore. | ||
222 | * | ||
223 | * @param h handle to the datastore | ||
224 | * @param uid identifier for the value | ||
225 | * @param priority how much to increase the priority of the value | ||
226 | * @param expiration new expiration value should be MAX of existing and this argument | ||
227 | * @param cont continuation to call when done | ||
228 | * @param cont_cls closure for cont | ||
229 | */ | ||
230 | void | ||
231 | GNUNET_DATASTORE_update (struct GNUNET_DATASTORE_Handle *h, | ||
232 | unsigned long long uid, | ||
233 | uint32_t priority, | ||
234 | struct GNUNET_TIME_Absolute expiration, | ||
235 | GNUNET_DATASTORE_ContinuationWithStatus cont, | ||
236 | void *cont_cls) | ||
237 | { | ||
238 | cont (cont_cls, GNUNET_SYSERR, "not implemented"); | ||
193 | } | 239 | } |
194 | 240 | ||
195 | 241 | ||
@@ -210,6 +256,9 @@ GNUNET_DATASTORE_get (struct GNUNET_DATASTORE_Handle *h, | |||
210 | uint32_t type, | 256 | uint32_t type, |
211 | GNUNET_DATASTORE_Iterator iter, void *iter_cls) | 257 | GNUNET_DATASTORE_Iterator iter, void *iter_cls) |
212 | { | 258 | { |
259 | static struct GNUNET_TIME_Absolute zero; | ||
260 | iter (iter_cls, | ||
261 | NULL, 0, NULL, 0, 0, 0, zero, 0); | ||
213 | } | 262 | } |
214 | 263 | ||
215 | 264 | ||
@@ -240,12 +289,17 @@ GNUNET_DATASTORE_get_random (struct GNUNET_DATASTORE_Handle *h, | |||
240 | * @param key key for the value | 289 | * @param key key for the value |
241 | * @param size number of bytes in data | 290 | * @param size number of bytes in data |
242 | * @param data content stored | 291 | * @param data content stored |
292 | * @param cont continuation to call when done | ||
293 | * @param cont_cls closure for cont | ||
243 | */ | 294 | */ |
244 | void | 295 | void |
245 | GNUNET_DATASTORE_remove (struct GNUNET_DATASTORE_Handle *h, | 296 | GNUNET_DATASTORE_remove (struct GNUNET_DATASTORE_Handle *h, |
246 | const GNUNET_HashCode * key, | 297 | const GNUNET_HashCode * key, |
247 | uint32_t size, const void *data) | 298 | uint32_t size, const void *data, |
299 | GNUNET_DATASTORE_ContinuationWithStatus cont, | ||
300 | void *cont_cls) | ||
248 | { | 301 | { |
302 | cont (cont_cls, GNUNET_SYSERR, "not implemented"); | ||
249 | } | 303 | } |
250 | 304 | ||
251 | 305 | ||