aboutsummaryrefslogtreecommitdiff
path: root/src/namestore/plugin_namestore_flat.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2018-04-30 16:22:47 +0200
committerChristian Grothoff <christian@grothoff.org>2018-04-30 16:22:47 +0200
commit4b5c6cceb0284774a161d426b606f40644abfb4c (patch)
treef2f63b8df7e6bb329ef25eca97e27d4deac55b69 /src/namestore/plugin_namestore_flat.c
parentc66809401efc16f2606db7e2c7b7ca8def8be14e (diff)
downloadgnunet-4b5c6cceb0284774a161d426b606f40644abfb4c.tar.gz
gnunet-4b5c6cceb0284774a161d426b606f40644abfb4c.zip
eliminate use of OFFSET in namestore DB queries
Diffstat (limited to 'src/namestore/plugin_namestore_flat.c')
-rw-r--r--src/namestore/plugin_namestore_flat.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/namestore/plugin_namestore_flat.c b/src/namestore/plugin_namestore_flat.c
index f061ab7d1..f40154915 100644
--- a/src/namestore/plugin_namestore_flat.c
+++ b/src/namestore/plugin_namestore_flat.c
@@ -523,6 +523,7 @@ namestore_flat_lookup_records (void *cls,
523 return GNUNET_NO; 523 return GNUNET_NO;
524 if (NULL != iter) 524 if (NULL != iter)
525 iter (iter_cls, 525 iter (iter_cls,
526 0,
526 entry->private_key, 527 entry->private_key,
527 entry->label, 528 entry->label,
528 entry->record_count, 529 entry->record_count,
@@ -547,6 +548,12 @@ struct IterateContext
547 uint64_t limit; 548 uint64_t limit;
548 549
549 /** 550 /**
551 * What is the position of the current entry, counting
552 * starts from 1.
553 */
554 uint64_t pos;
555
556 /**
550 * Target zone. 557 * Target zone.
551 */ 558 */
552 const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone; 559 const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone;
@@ -581,6 +588,7 @@ iterate_zones (void *cls,
581 struct FlatFileEntry *entry = value; 588 struct FlatFileEntry *entry = value;
582 589
583 (void) key; 590 (void) key;
591 ic->pos++;
584 if (0 == ic->limit) 592 if (0 == ic->limit)
585 return GNUNET_NO; 593 return GNUNET_NO;
586 if ( (NULL != ic->zone) && 594 if ( (NULL != ic->zone) &&
@@ -594,6 +602,7 @@ iterate_zones (void *cls,
594 return GNUNET_YES; 602 return GNUNET_YES;
595 } 603 }
596 ic->iter (ic->iter_cls, 604 ic->iter (ic->iter_cls,
605 ic->pos,
597 entry->private_key, 606 entry->private_key,
598 entry->label, 607 entry->label,
599 entry->record_count, 608 entry->record_count,
@@ -611,7 +620,7 @@ iterate_zones (void *cls,
611 * 620 *
612 * @param cls closure (internal context for the plugin) 621 * @param cls closure (internal context for the plugin)
613 * @param zone hash of public key of the zone, NULL to iterate over all zones 622 * @param zone hash of public key of the zone, NULL to iterate over all zones
614 * @param offset offset in the list of all matching records 623 * @param serial serial number to exclude in the list of all matching records
615 * @param limit maximum number of results to return to @a iter 624 * @param limit maximum number of results to return to @a iter
616 * @param iter function to call with the result 625 * @param iter function to call with the result
617 * @param iter_cls closure for @a iter 626 * @param iter_cls closure for @a iter
@@ -620,7 +629,7 @@ iterate_zones (void *cls,
620static int 629static int
621namestore_flat_iterate_records (void *cls, 630namestore_flat_iterate_records (void *cls,
622 const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, 631 const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone,
623 uint64_t offset, 632 uint64_t serial,
624 uint64_t limit, 633 uint64_t limit,
625 GNUNET_NAMESTORE_RecordIterator iter, 634 GNUNET_NAMESTORE_RecordIterator iter,
626 void *iter_cls) 635 void *iter_cls)
@@ -628,7 +637,8 @@ namestore_flat_iterate_records (void *cls,
628 struct Plugin *plugin = cls; 637 struct Plugin *plugin = cls;
629 struct IterateContext ic; 638 struct IterateContext ic;
630 639
631 ic.offset = offset; 640 ic.offset = serial;
641 ic.pos = 0;
632 ic.limit = limit; 642 ic.limit = limit;
633 ic.iter = iter; 643 ic.iter = iter;
634 ic.iter_cls = iter_cls; 644 ic.iter_cls = iter_cls;
@@ -663,6 +673,7 @@ zone_to_name (void *cls,
663 sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey))) 673 sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey)))
664 { 674 {
665 plugin->iter (plugin->iter_cls, 675 plugin->iter (plugin->iter_cls,
676 0,
666 entry->private_key, 677 entry->private_key,
667 entry->label, 678 entry->label,
668 entry->record_count, 679 entry->record_count,