aboutsummaryrefslogtreecommitdiff
path: root/src/datacache/datacache.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-11-13 20:05:40 +0000
committerChristian Grothoff <christian@grothoff.org>2012-11-13 20:05:40 +0000
commit4e1d85bac66209e6655f3fb4d3ddef7929f0f3fc (patch)
treedf5c5a0d972f35d741b51c3a3fc8d2298ac8b4fd /src/datacache/datacache.c
parent855362e698928b0a5a8f72fc6427c2ea42af4e79 (diff)
downloadgnunet-4e1d85bac66209e6655f3fb4d3ddef7929f0f3fc.tar.gz
gnunet-4e1d85bac66209e6655f3fb4d3ddef7929f0f3fc.zip
changing datacache API to separate put-paths from data (so that plugins can test for duplicates), removing support for MySQL
Diffstat (limited to 'src/datacache/datacache.c')
-rw-r--r--src/datacache/datacache.c24
1 files changed, 18 insertions, 6 deletions
diff --git a/src/datacache/datacache.c b/src/datacache/datacache.c
index e5dbfac16..0cd6f884b 100644
--- a/src/datacache/datacache.c
+++ b/src/datacache/datacache.c
@@ -233,22 +233,34 @@ GNUNET_DATACACHE_destroy (struct GNUNET_DATACACHE_Handle *h)
233 * @param data data to store 233 * @param data data to store
234 * @param type type of the value 234 * @param type type of the value
235 * @param discard_time when to discard the value in any case 235 * @param discard_time when to discard the value in any case
236 * @return GNUNET_OK on success, GNUNET_SYSERR on error (full, etc.) 236 * @param path_info_len number of entries in 'path_info'
237 * @param path_info a path through the network
238 * @return GNUNET_OK on success, GNUNET_SYSERR on error, GNUNET_NO if duplicate
237 */ 239 */
238int 240int
239GNUNET_DATACACHE_put (struct GNUNET_DATACACHE_Handle *h, 241GNUNET_DATACACHE_put (struct GNUNET_DATACACHE_Handle *h,
240 const struct GNUNET_HashCode * key, size_t size, 242 const struct GNUNET_HashCode * key, size_t size,
241 const char *data, enum GNUNET_BLOCK_Type type, 243 const char *data, enum GNUNET_BLOCK_Type type,
242 struct GNUNET_TIME_Absolute discard_time) 244 struct GNUNET_TIME_Absolute discard_time,
245 unsigned int path_info_len,
246 const struct GNUNET_PeerIdentity *path_info)
243{ 247{
244 uint32_t used; 248 ssize_t used;
245 249
246 used = h->api->put (h->api->cls, key, size, data, type, discard_time); 250 used = h->api->put (h->api->cls, key,
247 if (0 == used) 251 size, data,
252 type, discard_time,
253 path_info_len, path_info);
254 if (-1 == used)
248 { 255 {
249 /* error or duplicate */ 256 GNUNET_break (0);
250 return GNUNET_SYSERR; 257 return GNUNET_SYSERR;
251 } 258 }
259 if (0 == used)
260 {
261 /* duplicate */
262 return GNUNET_NO;
263 }
252 LOG (GNUNET_ERROR_TYPE_DEBUG, "Stored data under key `%s' in cache\n", 264 LOG (GNUNET_ERROR_TYPE_DEBUG, "Stored data under key `%s' in cache\n",
253 GNUNET_h2s (key)); 265 GNUNET_h2s (key));
254 GNUNET_STATISTICS_update (h->stats, gettext_noop ("# bytes stored"), size, 266 GNUNET_STATISTICS_update (h->stats, gettext_noop ("# bytes stored"), size,