diff options
Diffstat (limited to 'src/namestore/namestore_api.c')
-rw-r--r-- | src/namestore/namestore_api.c | 83 |
1 files changed, 56 insertions, 27 deletions
diff --git a/src/namestore/namestore_api.c b/src/namestore/namestore_api.c index 71d969022..51ee25acf 100644 --- a/src/namestore/namestore_api.c +++ b/src/namestore/namestore_api.c | |||
@@ -83,6 +83,11 @@ struct GNUNET_NAMESTORE_QueueEntry | |||
83 | GNUNET_NAMESTORE_RecordMonitor proc; | 83 | GNUNET_NAMESTORE_RecordMonitor proc; |
84 | 84 | ||
85 | /** | 85 | /** |
86 | * Function to call with the records we get back; or NULL. | ||
87 | */ | ||
88 | GNUNET_NAMESTORE_RecordSetMonitor proc2; | ||
89 | |||
90 | /** | ||
86 | * Closure for @e proc. | 91 | * Closure for @e proc. |
87 | */ | 92 | */ |
88 | void *proc_cls; | 93 | void *proc_cls; |
@@ -151,6 +156,11 @@ struct GNUNET_NAMESTORE_ZoneIterator | |||
151 | GNUNET_NAMESTORE_RecordMonitor proc; | 156 | GNUNET_NAMESTORE_RecordMonitor proc; |
152 | 157 | ||
153 | /** | 158 | /** |
159 | * The continuation to call with the results | ||
160 | */ | ||
161 | GNUNET_NAMESTORE_RecordSetMonitor proc2; | ||
162 | |||
163 | /** | ||
154 | * Closure for @e proc. | 164 | * Closure for @e proc. |
155 | */ | 165 | */ |
156 | void *proc_cls; | 166 | void *proc_cls; |
@@ -630,6 +640,9 @@ handle_record_result (void *cls, const struct RecordResultMessage *msg) | |||
630 | { | 640 | { |
631 | if (NULL != ze->proc) | 641 | if (NULL != ze->proc) |
632 | ze->proc (ze->proc_cls, &msg->private_key, name, rd_count, rd); | 642 | ze->proc (ze->proc_cls, &msg->private_key, name, rd_count, rd); |
643 | if (NULL != ze->proc2) | ||
644 | ze->proc2 (ze->proc_cls, &msg->private_key, name, | ||
645 | rd_count, rd, GNUNET_TIME_absolute_ntoh (msg->expire)); | ||
633 | return; | 646 | return; |
634 | } | 647 | } |
635 | } | 648 | } |
@@ -1272,25 +1285,6 @@ GNUNET_NAMESTORE_zone_to_name ( | |||
1272 | } | 1285 | } |
1273 | 1286 | ||
1274 | 1287 | ||
1275 | /** | ||
1276 | * Starts a new zone iteration (used to periodically PUT all of our | ||
1277 | * records into our DHT). This MUST lock the struct GNUNET_NAMESTORE_Handle | ||
1278 | * for any other calls than #GNUNET_NAMESTORE_zone_iterator_next and | ||
1279 | * #GNUNET_NAMESTORE_zone_iteration_stop. @a proc will be called once | ||
1280 | * immediately, and then again after | ||
1281 | * #GNUNET_NAMESTORE_zone_iterator_next is invoked. | ||
1282 | * | ||
1283 | * @param h handle to the namestore | ||
1284 | * @param zone zone to access, NULL for all zones | ||
1285 | * @param error_cb function to call on error (i.e. disconnect) | ||
1286 | * @param error_cb_cls closure for @a error_cb | ||
1287 | * @param proc function to call on each name from the zone; it | ||
1288 | * will be called repeatedly with a value (if available) | ||
1289 | * @param proc_cls closure for @a proc | ||
1290 | * @param finish_cb function to call on completion | ||
1291 | * @param finish_cb_cls closure for @a finish_cb | ||
1292 | * @return an iterator handle to use for iteration | ||
1293 | */ | ||
1294 | struct GNUNET_NAMESTORE_ZoneIterator * | 1288 | struct GNUNET_NAMESTORE_ZoneIterator * |
1295 | GNUNET_NAMESTORE_zone_iteration_start ( | 1289 | GNUNET_NAMESTORE_zone_iteration_start ( |
1296 | struct GNUNET_NAMESTORE_Handle *h, | 1290 | struct GNUNET_NAMESTORE_Handle *h, |
@@ -1332,15 +1326,50 @@ GNUNET_NAMESTORE_zone_iteration_start ( | |||
1332 | return it; | 1326 | return it; |
1333 | } | 1327 | } |
1334 | 1328 | ||
1329 | struct GNUNET_NAMESTORE_ZoneIterator * | ||
1330 | GNUNET_NAMESTORE_zone_iteration_start2 ( | ||
1331 | struct GNUNET_NAMESTORE_Handle *h, | ||
1332 | const struct GNUNET_IDENTITY_PrivateKey *zone, | ||
1333 | GNUNET_SCHEDULER_TaskCallback error_cb, | ||
1334 | void *error_cb_cls, | ||
1335 | GNUNET_NAMESTORE_RecordSetMonitor proc, | ||
1336 | void *proc_cls, | ||
1337 | GNUNET_SCHEDULER_TaskCallback finish_cb, | ||
1338 | void *finish_cb_cls, | ||
1339 | enum GNUNET_GNSRECORD_Filter filter) | ||
1340 | { | ||
1341 | struct GNUNET_NAMESTORE_ZoneIterator *it; | ||
1342 | struct GNUNET_MQ_Envelope *env; | ||
1343 | struct ZoneIterationStartMessage *msg; | ||
1344 | uint32_t rid; | ||
1345 | |||
1346 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Sending ZONE_ITERATION_START message\n"); | ||
1347 | rid = get_op_id (h); | ||
1348 | it = GNUNET_new (struct GNUNET_NAMESTORE_ZoneIterator); | ||
1349 | it->h = h; | ||
1350 | it->error_cb = error_cb; | ||
1351 | it->error_cb_cls = error_cb_cls; | ||
1352 | it->finish_cb = finish_cb; | ||
1353 | it->finish_cb_cls = finish_cb_cls; | ||
1354 | it->proc2 = proc; | ||
1355 | it->proc_cls = proc_cls; | ||
1356 | it->op_id = rid; | ||
1357 | if (NULL != zone) | ||
1358 | it->zone = *zone; | ||
1359 | GNUNET_CONTAINER_DLL_insert_tail (h->z_head, h->z_tail, it); | ||
1360 | env = GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_START); | ||
1361 | msg->gns_header.r_id = htonl (rid); | ||
1362 | msg->filter = htons ((uint16_t) filter); | ||
1363 | if (NULL != zone) | ||
1364 | msg->zone = *zone; | ||
1365 | if (NULL == h->mq) | ||
1366 | it->env = env; | ||
1367 | else | ||
1368 | GNUNET_MQ_send (h->mq, env); | ||
1369 | return it; | ||
1370 | } | ||
1371 | |||
1335 | 1372 | ||
1336 | /** | ||
1337 | * Calls the record processor specified in #GNUNET_NAMESTORE_zone_iteration_start | ||
1338 | * for the next record. | ||
1339 | * | ||
1340 | * @param it the iterator | ||
1341 | * @param limit number of records to return to the iterator in one shot | ||
1342 | * (before #GNUNET_NAMESTORE_zone_iterator_next is to be called again) | ||
1343 | */ | ||
1344 | void | 1373 | void |
1345 | GNUNET_NAMESTORE_zone_iterator_next (struct GNUNET_NAMESTORE_ZoneIterator *it, | 1374 | GNUNET_NAMESTORE_zone_iterator_next (struct GNUNET_NAMESTORE_ZoneIterator *it, |
1346 | uint64_t limit) | 1375 | uint64_t limit) |