aboutsummaryrefslogtreecommitdiff
path: root/src/namestore/plugin_namestore_flat.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2018-04-15 20:45:44 +0200
committerChristian Grothoff <christian@grothoff.org>2018-04-15 20:45:44 +0200
commit47a9a3c95de2dfadc431d34c1dc079d35d3d6d18 (patch)
tree3aaf6de1d53a8b2853e03e56e90f725f26184cfa /src/namestore/plugin_namestore_flat.c
parent284cfac7a521ad275b7536ce1075f62b6e45ea44 (diff)
downloadgnunet-47a9a3c95de2dfadc431d34c1dc079d35d3d6d18.tar.gz
gnunet-47a9a3c95de2dfadc431d34c1dc079d35d3d6d18.zip
add transactions to namestore plugin API
Diffstat (limited to 'src/namestore/plugin_namestore_flat.c')
-rw-r--r--src/namestore/plugin_namestore_flat.c93
1 files changed, 68 insertions, 25 deletions
diff --git a/src/namestore/plugin_namestore_flat.c b/src/namestore/plugin_namestore_flat.c
index 024fc34f2..170adb49e 100644
--- a/src/namestore/plugin_namestore_flat.c
+++ b/src/namestore/plugin_namestore_flat.c
@@ -383,7 +383,7 @@ static void
383database_shutdown (struct Plugin *plugin) 383database_shutdown (struct Plugin *plugin)
384{ 384{
385 struct GNUNET_DISK_FileHandle *fh; 385 struct GNUNET_DISK_FileHandle *fh;
386 386
387 fh = GNUNET_DISK_file_open (plugin->fn, 387 fh = GNUNET_DISK_file_open (plugin->fn,
388 GNUNET_DISK_OPEN_CREATE | 388 GNUNET_DISK_OPEN_CREATE |
389 GNUNET_DISK_OPEN_TRUNCATE | 389 GNUNET_DISK_OPEN_TRUNCATE |
@@ -418,11 +418,11 @@ database_shutdown (struct Plugin *plugin)
418 * @return #GNUNET_OK on success, else #GNUNET_SYSERR 418 * @return #GNUNET_OK on success, else #GNUNET_SYSERR
419 */ 419 */
420static int 420static int
421namestore_store_records (void *cls, 421namestore_flat_store_records (void *cls,
422 const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone_key, 422 const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone_key,
423 const char *label, 423 const char *label,
424 unsigned int rd_count, 424 unsigned int rd_count,
425 const struct GNUNET_GNSRECORD_Data *rd) 425 const struct GNUNET_GNSRECORD_Data *rd)
426{ 426{
427 struct Plugin *plugin = cls; 427 struct Plugin *plugin = cls;
428 uint64_t rvalue; 428 uint64_t rvalue;
@@ -488,11 +488,11 @@ namestore_store_records (void *cls,
488 * @return #GNUNET_OK on success, else #GNUNET_SYSERR 488 * @return #GNUNET_OK on success, else #GNUNET_SYSERR
489 */ 489 */
490static int 490static int
491namestore_lookup_records (void *cls, 491namestore_flat_lookup_records (void *cls,
492 const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, 492 const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone,
493 const char *label, 493 const char *label,
494 GNUNET_NAMESTORE_RecordIterator iter, 494 GNUNET_NAMESTORE_RecordIterator iter,
495 void *iter_cls) 495 void *iter_cls)
496{ 496{
497 struct Plugin *plugin = cls; 497 struct Plugin *plugin = cls;
498 struct FlatFileEntry *entry; 498 struct FlatFileEntry *entry;
@@ -571,11 +571,11 @@ iterate_zones (void *cls,
571 * @return #GNUNET_OK on success, #GNUNET_NO if there were no results, #GNUNET_SYSERR on error 571 * @return #GNUNET_OK on success, #GNUNET_NO if there were no results, #GNUNET_SYSERR on error
572 */ 572 */
573static int 573static int
574namestore_iterate_records (void *cls, 574namestore_flat_iterate_records (void *cls,
575 const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, 575 const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone,
576 uint64_t offset, 576 uint64_t offset,
577 GNUNET_NAMESTORE_RecordIterator iter, 577 GNUNET_NAMESTORE_RecordIterator iter,
578 void *iter_cls) 578 void *iter_cls)
579{ 579{
580 struct Plugin *plugin = cls; 580 struct Plugin *plugin = cls;
581 581
@@ -641,11 +641,11 @@ zone_to_name (void *cls,
641 * @return #GNUNET_OK on success, #GNUNET_NO if there were no results, #GNUNET_SYSERR on error 641 * @return #GNUNET_OK on success, #GNUNET_NO if there were no results, #GNUNET_SYSERR on error
642 */ 642 */
643static int 643static int
644namestore_zone_to_name (void *cls, 644namestore_flat_zone_to_name (void *cls,
645 const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, 645 const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone,
646 const struct GNUNET_CRYPTO_EcdsaPublicKey *value_zone, 646 const struct GNUNET_CRYPTO_EcdsaPublicKey *value_zone,
647 GNUNET_NAMESTORE_RecordIterator iter, 647 GNUNET_NAMESTORE_RecordIterator iter,
648 void *iter_cls) 648 void *iter_cls)
649{ 649{
650 struct Plugin *plugin = cls; 650 struct Plugin *plugin = cls;
651 651
@@ -667,6 +667,46 @@ namestore_zone_to_name (void *cls,
667 667
668 668
669/** 669/**
670 * Start a transaction.
671 *
672 * @param cls closure
673 * @return #GNUNET_OK on success, #GNUNET_NO if transactions are not supported,
674 * #GNUNET_SYSERR on internal errors
675 */
676static int
677namestore_flat_begin_transaction (void *cls)
678{
679 return GNUNET_NO;
680}
681
682
683/**
684 * Try to commit a transaction.
685 *
686 * @param cls closure
687 * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure
688 */
689static int
690namestore_flat_commit_transaction (void *cls)
691{
692 GNUNET_break (0);
693 return GNUNET_SYSERR;
694}
695
696
697/**
698 * Rollback a transaction.
699 *
700 * @param cls closure
701 */
702static void
703namestore_flat_rollback_transaction (void *cls)
704{
705 GNUNET_break (0);
706}
707
708
709/**
670 * Entry point for the plugin. 710 * Entry point for the plugin.
671 * 711 *
672 * @param cls the "struct GNUNET_NAMESTORE_PluginEnvironment*" 712 * @param cls the "struct GNUNET_NAMESTORE_PluginEnvironment*"
@@ -692,10 +732,13 @@ libgnunet_plugin_namestore_flat_init (void *cls)
692 } 732 }
693 api = GNUNET_new (struct GNUNET_NAMESTORE_PluginFunctions); 733 api = GNUNET_new (struct GNUNET_NAMESTORE_PluginFunctions);
694 api->cls = &plugin; 734 api->cls = &plugin;
695 api->store_records = &namestore_store_records; 735 api->store_records = &namestore_flat_store_records;
696 api->iterate_records = &namestore_iterate_records; 736 api->iterate_records = &namestore_flat_iterate_records;
697 api->zone_to_name = &namestore_zone_to_name; 737 api->zone_to_name = &namestore_flat_zone_to_name;
698 api->lookup_records = &namestore_lookup_records; 738 api->lookup_records = &namestore_flat_lookup_records;
739 api->begin_transaction = &namestore_flat_begin_transaction;
740 api->commit_transaction = &namestore_flat_commit_transaction;
741 api->rollback_transaction = &namestore_flat_rollback_transaction;
699 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 742 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
700 _("flat file database running\n")); 743 _("flat file database running\n"));
701 return api; 744 return api;