aboutsummaryrefslogtreecommitdiff
path: root/src/datastore
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2010-10-06 12:55:38 +0000
committerChristian Grothoff <christian@grothoff.org>2010-10-06 12:55:38 +0000
commit2ffb6f329c85b24367199f910f6603950e1fba68 (patch)
tree537e401b59e3f7c435d5d8369ba3088e1679743b /src/datastore
parentb8da6057b2c0c66931ccde9b4bba418fc5222724 (diff)
downloadgnunet-2ffb6f329c85b24367199f910f6603950e1fba68.tar.gz
gnunet-2ffb6f329c85b24367199f910f6603950e1fba68.zip
DHT PUT integration into FS
Diffstat (limited to 'src/datastore')
-rw-r--r--src/datastore/datastore.h23
-rw-r--r--src/datastore/datastore_api.c51
-rw-r--r--src/datastore/gnunet-service-datastore.c38
3 files changed, 108 insertions, 4 deletions
diff --git a/src/datastore/datastore.h b/src/datastore/datastore.h
index f827f8766..55ca7c8e5 100644
--- a/src/datastore/datastore.h
+++ b/src/datastore/datastore.h
@@ -109,7 +109,7 @@ struct GetMessage
109 struct GNUNET_MessageHeader header; 109 struct GNUNET_MessageHeader header;
110 110
111 /** 111 /**
112 * Desired content type. 112 * Desired content type. (actually an enum GNUNET_BLOCK_Type)
113 */ 113 */
114 uint32_t type GNUNET_PACKED; 114 uint32_t type GNUNET_PACKED;
115 115
@@ -123,6 +123,25 @@ struct GetMessage
123 123
124 124
125/** 125/**
126 * Message to the datastore service asking about zero
127 * anonymity content.
128 */
129struct GetZeroAnonymityMessage
130{
131 /**
132 * Type is GNUNET_MESSAGE_TYPE_DATASTORE_GET_ZERO_ANONYMITY.
133 */
134 struct GNUNET_MessageHeader header;
135
136 /**
137 * Desired content type (actually an enum GNUNET_BLOCK_Type)
138 */
139 uint32_t type GNUNET_PACKED;
140
141};
142
143
144/**
126 * Message to the datastore service requesting an update 145 * Message to the datastore service requesting an update
127 * to the priority or expiration for some content. 146 * to the priority or expiration for some content.
128 */ 147 */
@@ -176,7 +195,7 @@ struct DataMessage
176 uint32_t size GNUNET_PACKED; 195 uint32_t size GNUNET_PACKED;
177 196
178 /** 197 /**
179 * Type of the item (NBO), zero for remove. 198 * Type of the item (NBO), zero for remove, (actually an enum GNUNET_BLOCK_Type)
180 */ 199 */
181 uint32_t type GNUNET_PACKED; 200 uint32_t type GNUNET_PACKED;
182 201
diff --git a/src/datastore/datastore_api.c b/src/datastore/datastore_api.c
index 18aa0bcdc..a15bc183a 100644
--- a/src/datastore/datastore_api.c
+++ b/src/datastore/datastore_api.c
@@ -1205,6 +1205,57 @@ GNUNET_DATASTORE_get_random (struct GNUNET_DATASTORE_Handle *h,
1205} 1205}
1206 1206
1207 1207
1208/**
1209 * Get a zero-anonymity value from the datastore.
1210 *
1211 * @param h handle to the datastore
1212 * @param queue_priority ranking of this request in the priority queue
1213 * @param max_queue_size at what queue size should this request be dropped
1214 * (if other requests of higher priority are in the queue)
1215 * @param timeout how long to wait at most for a response
1216 * @param type allowed type for the operation
1217 * @param iter function to call on a random value; it
1218 * will be called once with a value (if available)
1219 * and always once with a value of NULL.
1220 * @param iter_cls closure for iter
1221 * @return NULL if the entry was not queued, otherwise a handle that can be used to
1222 * cancel; note that even if NULL is returned, the callback will be invoked
1223 * (or rather, will already have been invoked)
1224 */
1225struct GNUNET_DATASTORE_QueueEntry *
1226GNUNET_DATASTORE_get_zero_anonymity (struct GNUNET_DATASTORE_Handle *h,
1227 unsigned int queue_priority,
1228 unsigned int max_queue_size,
1229 struct GNUNET_TIME_Relative timeout,
1230 enum GNUNET_BLOCK_Type type,
1231 GNUNET_DATASTORE_Iterator iter,
1232 void *iter_cls)
1233{
1234 struct GNUNET_DATASTORE_QueueEntry *qe;
1235 struct GetZeroAnonymityMessage *m;
1236 union QueueContext qc;
1237
1238#if DEBUG_DATASTORE
1239 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1240 "Asked to get zero-anonymity entry in %llu ms\n",
1241 (unsigned long long) timeout.value);
1242#endif
1243 qc.rc.iter = iter;
1244 qc.rc.iter_cls = iter_cls;
1245 qe = make_queue_entry (h, sizeof(struct GetZeroAnonymityMessage),
1246 queue_priority, max_queue_size, timeout,
1247 &process_result_message, &qc);
1248 if (qe == NULL)
1249 return NULL;
1250 m = (struct GetZeroAnonymityMessage*) &qe[1];
1251 m->header.type = htons(GNUNET_MESSAGE_TYPE_DATASTORE_GET_RANDOM);
1252 m->header.size = htons(sizeof (struct GetZeroAnonymityMessage));
1253 m->type = htonl ((uint32_t) type);
1254 process_queue (h);
1255 return qe;
1256}
1257
1258
1208 1259
1209/** 1260/**
1210 * Iterate over the results for a particular key 1261 * Iterate over the results for a particular key
diff --git a/src/datastore/gnunet-service-datastore.c b/src/datastore/gnunet-service-datastore.c
index 8a896a7fb..2f505891c 100644
--- a/src/datastore/gnunet-service-datastore.c
+++ b/src/datastore/gnunet-service-datastore.c
@@ -1255,11 +1255,43 @@ handle_get_random (void *cls,
1255 GNUNET_NO); 1255 GNUNET_NO);
1256 GNUNET_SERVER_client_keep (client); 1256 GNUNET_SERVER_client_keep (client);
1257 plugin->api->iter_migration_order (plugin->api->cls, 1257 plugin->api->iter_migration_order (plugin->api->cls,
1258 0, 1258 GNUNET_BLOCK_TYPE_ANY,
1259 &transmit_item, 1259 &transmit_item,
1260 client); 1260 client);
1261} 1261}
1262 1262
1263/**
1264 * Handle GET_ZERO_ANONYMITY-message.
1265 *
1266 * @param cls closure
1267 * @param client identification of the client
1268 * @param message the actual message
1269 */
1270static void
1271handle_get_zero_anonymity (void *cls,
1272 struct GNUNET_SERVER_Client *client,
1273 const struct GNUNET_MessageHeader *message)
1274{
1275 const struct GetZeroAnonymityMessage * msg = (const struct GetZeroAnonymityMessage*) message;
1276 enum GNUNET_BLOCK_Type type;
1277
1278 type = (enum GNUNET_BLOCK_Type) ntohl (msg->type);
1279#if DEBUG_DATASTORE
1280 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1281 "Processing `%s' request\n",
1282 "GET_ZERO_ANONYMITY");
1283#endif
1284 GNUNET_STATISTICS_update (stats,
1285 gettext_noop ("# GET ZERO ANONYMITY requests received"),
1286 1,
1287 GNUNET_NO);
1288 GNUNET_SERVER_client_keep (client);
1289 plugin->api->iter_zero_anonymity (plugin->api->cls,
1290 type,
1291 &transmit_item,
1292 client);
1293}
1294
1263 1295
1264/** 1296/**
1265 * Context for the 'remove_callback'. 1297 * Context for the 'remove_callback'.
@@ -1373,7 +1405,7 @@ handle_remove (void *cls,
1373 plugin->api->get (plugin->api->cls, 1405 plugin->api->get (plugin->api->cls,
1374 &dm->key, 1406 &dm->key,
1375 &vhash, 1407 &vhash,
1376 ntohl(dm->type), 1408 (enum GNUNET_BLOCK_Type) ntohl(dm->type),
1377 &remove_callback, 1409 &remove_callback,
1378 rc); 1410 rc);
1379} 1411}
@@ -1675,6 +1707,8 @@ run (void *cls,
1675 {&handle_get, NULL, GNUNET_MESSAGE_TYPE_DATASTORE_GET, 0 }, 1707 {&handle_get, NULL, GNUNET_MESSAGE_TYPE_DATASTORE_GET, 0 },
1676 {&handle_get_random, NULL, GNUNET_MESSAGE_TYPE_DATASTORE_GET_RANDOM, 1708 {&handle_get_random, NULL, GNUNET_MESSAGE_TYPE_DATASTORE_GET_RANDOM,
1677 sizeof(struct GNUNET_MessageHeader) }, 1709 sizeof(struct GNUNET_MessageHeader) },
1710 {&handle_get_zero_anonymity, NULL, GNUNET_MESSAGE_TYPE_DATASTORE_GET_ZERO_ANONYMITY,
1711 sizeof(struct GetZeroAnonymityMessage) },
1678 {&handle_remove, NULL, GNUNET_MESSAGE_TYPE_DATASTORE_REMOVE, 0 }, 1712 {&handle_remove, NULL, GNUNET_MESSAGE_TYPE_DATASTORE_REMOVE, 0 },
1679 {&handle_drop, NULL, GNUNET_MESSAGE_TYPE_DATASTORE_DROP, 1713 {&handle_drop, NULL, GNUNET_MESSAGE_TYPE_DATASTORE_DROP,
1680 sizeof(struct GNUNET_MessageHeader) }, 1714 sizeof(struct GNUNET_MessageHeader) },