diff options
author | Martin Schanzenbach <schanzen@gnunet.org> | 2023-12-01 22:46:54 +0100 |
---|---|---|
committer | Martin Schanzenbach <schanzen@gnunet.org> | 2023-12-01 22:50:11 +0100 |
commit | 663b6fe492691e06fcdcc5ca55b22deefb40ad4b (patch) | |
tree | 37659832f67f578fe55e721cdbd0b0f56d596fc6 | |
parent | 0d77fac87aba598ba53cf4d0606a1a26786e2186 (diff) | |
download | gnunet-663b6fe492691e06fcdcc5ca55b22deefb40ad4b.tar.gz gnunet-663b6fe492691e06fcdcc5ca55b22deefb40ad4b.zip |
NAMESTORE: Remove TX API again. Add new edit records API with advisory locking.
42 files changed, 1230 insertions, 1705 deletions
diff --git a/po/POTFILES.in b/po/POTFILES.in index 8f6b8b46d..689864e1a 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in | |||
@@ -102,7 +102,6 @@ src/contrib/service/set/ibf_sim.c | |||
102 | src/contrib/service/set/plugin_block_set_test.c | 102 | src/contrib/service/set/plugin_block_set_test.c |
103 | src/contrib/service/set/set_api.c | 103 | src/contrib/service/set/set_api.c |
104 | src/contrib/service/template/gnunet-service-template.c | 104 | src/contrib/service/template/gnunet-service-template.c |
105 | src/gana/gnunet-error-codes/gnunet_error_codes.c | ||
106 | src/lib/block/bg_bf.c | 105 | src/lib/block/bg_bf.c |
107 | src/lib/block/block.c | 106 | src/lib/block/block.c |
108 | src/lib/curl/curl.c | 107 | src/lib/curl/curl.c |
@@ -461,8 +460,6 @@ src/service/testing/testing_api_cmd_netjail_start_cmds_helper.c | |||
461 | src/service/testing/testing_api_cmd_netjail_stop.c | 460 | src/service/testing/testing_api_cmd_netjail_stop.c |
462 | src/service/testing/testing_api_cmd_netjail_stop_cmds_helper.c | 461 | src/service/testing/testing_api_cmd_netjail_stop_cmds_helper.c |
463 | src/service/testing/testing_api_cmd_send_peer_ready.c | 462 | src/service/testing/testing_api_cmd_send_peer_ready.c |
464 | src/service/testing/testing_api_cmd_start_peer.c | ||
465 | src/service/testing/testing_api_cmd_stop_peer.c | ||
466 | src/service/testing/testing_api_cmd_system_create.c | 463 | src/service/testing/testing_api_cmd_system_create.c |
467 | src/service/testing/testing_api_cmd_system_destroy.c | 464 | src/service/testing/testing_api_cmd_system_destroy.c |
468 | src/service/testing/testing_api_loop.c | 465 | src/service/testing/testing_api_loop.c |
@@ -474,6 +471,8 @@ src/service/transport/gnunet-communicator-udp.c | |||
474 | src/service/transport/gnunet-communicator-unix.c | 471 | src/service/transport/gnunet-communicator-unix.c |
475 | src/service/transport/gnunet-service-transport.c | 472 | src/service/transport/gnunet-service-transport.c |
476 | src/service/transport/gnunet-transport.c | 473 | src/service/transport/gnunet-transport.c |
474 | src/service/transport/testing_api_cmd_start_peer.c | ||
475 | src/service/transport/testing_api_cmd_stop_peer.c | ||
477 | src/service/transport/transport-testing-communicator.c | 476 | src/service/transport/transport-testing-communicator.c |
478 | src/service/transport/transport-testing-filenames2.c | 477 | src/service/transport/transport-testing-filenames2.c |
479 | src/service/transport/transport-testing-loggers2.c | 478 | src/service/transport/transport-testing-loggers2.c |
diff --git a/src/cli/namestore/gnunet-namestore-zonefile.c b/src/cli/namestore/gnunet-namestore-zonefile.c index dfd438e94..d43e88006 100644 --- a/src/cli/namestore/gnunet-namestore-zonefile.c +++ b/src/cli/namestore/gnunet-namestore-zonefile.c | |||
@@ -184,21 +184,6 @@ do_shutdown (void *cls) | |||
184 | } | 184 | } |
185 | 185 | ||
186 | static void | 186 | static void |
187 | tx_end (void *cls, enum GNUNET_ErrorCode ec) | ||
188 | { | ||
189 | ns_qe = NULL; | ||
190 | if (GNUNET_EC_NONE != ec) | ||
191 | { | ||
192 | fprintf (stderr, | ||
193 | _ ("Ego `%s' not known to identity service\n"), | ||
194 | ego_name); | ||
195 | GNUNET_SCHEDULER_shutdown (); | ||
196 | ret = -1; | ||
197 | } | ||
198 | GNUNET_SCHEDULER_shutdown (); | ||
199 | } | ||
200 | |||
201 | static void | ||
202 | parse (void *cls); | 187 | parse (void *cls); |
203 | 188 | ||
204 | static char* | 189 | static char* |
@@ -602,7 +587,7 @@ parse (void *cls) | |||
602 | } | 587 | } |
603 | if (rd_count > 0) | 588 | if (rd_count > 0) |
604 | { | 589 | { |
605 | ns_qe = GNUNET_NAMESTORE_records_store (ns, | 590 | ns_qe = GNUNET_NAMESTORE_record_set_store (ns, |
606 | &zone_pkey, | 591 | &zone_pkey, |
607 | lastname, | 592 | lastname, |
608 | rd_count, | 593 | rd_count, |
@@ -642,26 +627,9 @@ parse (void *cls) | |||
642 | } | 627 | } |
643 | printf ("Published %u records sets with total %u records\n", | 628 | printf ("Published %u records sets with total %u records\n", |
644 | published_sets, published_records); | 629 | published_sets, published_records); |
645 | ns_qe = GNUNET_NAMESTORE_transaction_commit (ns, | 630 | GNUNET_SCHEDULER_shutdown (); |
646 | &tx_end, | ||
647 | NULL); | ||
648 | } | 631 | } |
649 | 632 | ||
650 | static void | ||
651 | tx_start (void *cls, enum GNUNET_ErrorCode ec) | ||
652 | { | ||
653 | ns_qe = NULL; | ||
654 | if (GNUNET_EC_NONE != ec) | ||
655 | { | ||
656 | fprintf (stderr, | ||
657 | _ ("Ego `%s' not known to identity service\n"), | ||
658 | ego_name); | ||
659 | GNUNET_SCHEDULER_shutdown (); | ||
660 | ret = -1; | ||
661 | return; | ||
662 | } | ||
663 | parse_task = GNUNET_SCHEDULER_add_now (&parse, NULL); | ||
664 | } | ||
665 | 633 | ||
666 | static void | 634 | static void |
667 | identity_cb (void *cls, struct GNUNET_IDENTITY_Ego *ego) | 635 | identity_cb (void *cls, struct GNUNET_IDENTITY_Ego *ego) |
@@ -684,9 +652,7 @@ identity_cb (void *cls, struct GNUNET_IDENTITY_Ego *ego) | |||
684 | zone_pkey = *GNUNET_IDENTITY_ego_get_private_key (ego); | 652 | zone_pkey = *GNUNET_IDENTITY_ego_get_private_key (ego); |
685 | sprintf (origin, "%s.", ego_name); | 653 | sprintf (origin, "%s.", ego_name); |
686 | state = ZS_ORIGIN_SET; | 654 | state = ZS_ORIGIN_SET; |
687 | ns_qe = GNUNET_NAMESTORE_transaction_begin (ns, | 655 | parse_task = GNUNET_SCHEDULER_add_now (&parse, NULL); |
688 | &tx_start, | ||
689 | NULL); | ||
690 | } | 656 | } |
691 | 657 | ||
692 | 658 | ||
diff --git a/src/cli/namestore/gnunet-namestore.c b/src/cli/namestore/gnunet-namestore.c index 00eacfcfd..ec834cc01 100644 --- a/src/cli/namestore/gnunet-namestore.c +++ b/src/cli/namestore/gnunet-namestore.c | |||
@@ -38,7 +38,7 @@ | |||
38 | * (per record). | 38 | * (per record). |
39 | */ | 39 | */ |
40 | #define WARN_RELATIVE_EXPIRATION_LIMIT GNUNET_TIME_relative_multiply ( \ | 40 | #define WARN_RELATIVE_EXPIRATION_LIMIT GNUNET_TIME_relative_multiply ( \ |
41 | GNUNET_TIME_UNIT_MINUTES, 15) | 41 | GNUNET_TIME_UNIT_MINUTES, 15) |
42 | 42 | ||
43 | /** | 43 | /** |
44 | * Entry in record set for bulk processing. | 44 | * Entry in record set for bulk processing. |
@@ -479,6 +479,7 @@ parse_recordline (const char *line) | |||
479 | return GNUNET_OK; | 479 | return GNUNET_OK; |
480 | } | 480 | } |
481 | 481 | ||
482 | |||
482 | static void | 483 | static void |
483 | reset_handles (void) | 484 | reset_handles (void) |
484 | { | 485 | { |
@@ -588,7 +589,6 @@ reset_handles (void) | |||
588 | } | 589 | } |
589 | 590 | ||
590 | 591 | ||
591 | |||
592 | /** | 592 | /** |
593 | * Task run on shutdown. Cleans up everything. | 593 | * Task run on shutdown. Cleans up everything. |
594 | * | 594 | * |
@@ -626,18 +626,6 @@ do_shutdown (void *cls) | |||
626 | } | 626 | } |
627 | } | 627 | } |
628 | 628 | ||
629 | static void | ||
630 | commit_cb (void *cls, enum GNUNET_ErrorCode ec) | ||
631 | { | ||
632 | ns_qe = NULL; | ||
633 | if (GNUNET_EC_NONE != ec) | ||
634 | { | ||
635 | fprintf (stderr, "Failed to commit to namestore: `%s'\n", | ||
636 | GNUNET_ErrorCode_get_hint (ec)); | ||
637 | ret = 1; | ||
638 | } | ||
639 | GNUNET_SCHEDULER_shutdown (); | ||
640 | } | ||
641 | 629 | ||
642 | static void | 630 | static void |
643 | process_command_stdin (); | 631 | process_command_stdin (); |
@@ -652,7 +640,7 @@ finish_command (void) | |||
652 | process_command_stdin (); | 640 | process_command_stdin (); |
653 | return; | 641 | return; |
654 | } | 642 | } |
655 | ns_qe = GNUNET_NAMESTORE_transaction_commit (ns, &commit_cb, NULL); | 643 | GNUNET_SCHEDULER_shutdown (); |
656 | } | 644 | } |
657 | 645 | ||
658 | 646 | ||
@@ -689,6 +677,7 @@ del_continuation (void *cls, enum GNUNET_ErrorCode ec) | |||
689 | finish_command (); | 677 | finish_command (); |
690 | } | 678 | } |
691 | 679 | ||
680 | |||
692 | static void | 681 | static void |
693 | purge_next_record (void *cls); | 682 | purge_next_record (void *cls); |
694 | 683 | ||
@@ -722,16 +711,17 @@ purge_next_record (void *cls) | |||
722 | GNUNET_CONTAINER_DLL_remove (marked_head, | 711 | GNUNET_CONTAINER_DLL_remove (marked_head, |
723 | marked_tail, | 712 | marked_tail, |
724 | mrec); | 713 | mrec); |
725 | del_qe = GNUNET_NAMESTORE_records_store (ns, | 714 | del_qe = GNUNET_NAMESTORE_record_set_store (ns, |
726 | &mrec->key, | 715 | &mrec->key, |
727 | mrec->name, | 716 | mrec->name, |
728 | 0, NULL, | 717 | 0, NULL, |
729 | &marked_deleted, | 718 | &marked_deleted, |
730 | NULL); | 719 | NULL); |
731 | GNUNET_free (mrec->name); | 720 | GNUNET_free (mrec->name); |
732 | GNUNET_free (mrec); | 721 | GNUNET_free (mrec); |
733 | } | 722 | } |
734 | 723 | ||
724 | |||
735 | /** | 725 | /** |
736 | * Function called when we are done with a zone iteration. | 726 | * Function called when we are done with a zone iteration. |
737 | */ | 727 | */ |
@@ -763,6 +753,7 @@ zone_iteration_error_cb (void *cls) | |||
763 | finish_command (); | 753 | finish_command (); |
764 | } | 754 | } |
765 | 755 | ||
756 | |||
766 | static void | 757 | static void |
767 | collect_zone_records_to_purge (const struct | 758 | collect_zone_records_to_purge (const struct |
768 | GNUNET_CRYPTO_PrivateKey *zone_key, | 759 | GNUNET_CRYPTO_PrivateKey *zone_key, |
@@ -812,6 +803,7 @@ collect_orphans (const struct GNUNET_CRYPTO_PrivateKey *zone_key, | |||
812 | } | 803 | } |
813 | } | 804 | } |
814 | 805 | ||
806 | |||
815 | /** | 807 | /** |
816 | * Process a record that was stored in the namestore. | 808 | * Process a record that was stored in the namestore. |
817 | * | 809 | * |
@@ -929,6 +921,7 @@ display_record (const struct GNUNET_CRYPTO_PrivateKey *zone_key, | |||
929 | // fprintf (stdout, "%s", "\n"); | 921 | // fprintf (stdout, "%s", "\n"); |
930 | } | 922 | } |
931 | 923 | ||
924 | |||
932 | static void | 925 | static void |
933 | purge_zone_iterator (void *cls, | 926 | purge_zone_iterator (void *cls, |
934 | const struct GNUNET_CRYPTO_PrivateKey *zone_key, | 927 | const struct GNUNET_CRYPTO_PrivateKey *zone_key, |
@@ -1160,13 +1153,13 @@ get_existing_record (void *cls, | |||
1160 | else if (GNUNET_NO != etime_is_rel) | 1153 | else if (GNUNET_NO != etime_is_rel) |
1161 | rde->expiration_time = GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us; | 1154 | rde->expiration_time = GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us; |
1162 | GNUNET_assert (NULL != name); | 1155 | GNUNET_assert (NULL != name); |
1163 | add_qe = GNUNET_NAMESTORE_records_store (ns, | 1156 | add_qe = GNUNET_NAMESTORE_record_set_store (ns, |
1164 | &zone_pkey, | 1157 | &zone_pkey, |
1165 | name, | 1158 | name, |
1166 | rd_count + 1, | 1159 | rd_count + 1, |
1167 | rde, | 1160 | rde, |
1168 | &add_continuation, | 1161 | &add_continuation, |
1169 | &add_qe); | 1162 | &add_qe); |
1170 | } | 1163 | } |
1171 | 1164 | ||
1172 | 1165 | ||
@@ -1265,7 +1258,7 @@ del_monitor (void *cls, | |||
1265 | if ((NULL == value) && (NULL == typestring)) | 1258 | if ((NULL == value) && (NULL == typestring)) |
1266 | { | 1259 | { |
1267 | /* delete everything */ | 1260 | /* delete everything */ |
1268 | del_qe = GNUNET_NAMESTORE_records_store (ns, | 1261 | del_qe = GNUNET_NAMESTORE_record_set_store (ns, |
1269 | &zone_pkey, | 1262 | &zone_pkey, |
1270 | name, | 1263 | name, |
1271 | 0, | 1264 | 0, |
@@ -1305,7 +1298,7 @@ del_monitor (void *cls, | |||
1305 | return; | 1298 | return; |
1306 | } | 1299 | } |
1307 | /* delete everything but what we copied to 'rdx' */ | 1300 | /* delete everything but what we copied to 'rdx' */ |
1308 | del_qe = GNUNET_NAMESTORE_records_store (ns, | 1301 | del_qe = GNUNET_NAMESTORE_record_set_store (ns, |
1309 | &zone_pkey, | 1302 | &zone_pkey, |
1310 | name, | 1303 | name, |
1311 | rd_left, | 1304 | rd_left, |
@@ -1393,7 +1386,7 @@ run_with_zone_pkey (const struct GNUNET_CONFIGURATION_Handle *cfg) | |||
1393 | rd[rd_count] = e->record; | 1386 | rd[rd_count] = e->record; |
1394 | rd_count++; | 1387 | rd_count++; |
1395 | } | 1388 | } |
1396 | set_qe = GNUNET_NAMESTORE_records_store (ns, | 1389 | set_qe = GNUNET_NAMESTORE_record_set_store (ns, |
1397 | &zone_pkey, | 1390 | &zone_pkey, |
1398 | name, | 1391 | name, |
1399 | rd_count, | 1392 | rd_count, |
@@ -1637,7 +1630,7 @@ run_with_zone_pkey (const struct GNUNET_CONFIGURATION_Handle *cfg) | |||
1637 | } | 1630 | } |
1638 | if (GNUNET_OK != | 1631 | if (GNUNET_OK != |
1639 | GNUNET_CRYPTO_public_key_from_string (reverse_pkey, | 1632 | GNUNET_CRYPTO_public_key_from_string (reverse_pkey, |
1640 | &pubkey)) | 1633 | &pubkey)) |
1641 | { | 1634 | { |
1642 | fprintf (stderr, | 1635 | fprintf (stderr, |
1643 | _ ("Invalid public key for reverse lookup `%s'\n"), | 1636 | _ ("Invalid public key for reverse lookup `%s'\n"), |
@@ -1708,7 +1701,7 @@ run_with_zone_pkey (const struct GNUNET_CONFIGURATION_Handle *cfg) | |||
1708 | rd.flags |= GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION; | 1701 | rd.flags |= GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION; |
1709 | if (1 == is_shadow) | 1702 | if (1 == is_shadow) |
1710 | rd.flags |= GNUNET_GNSRECORD_RF_SHADOW; | 1703 | rd.flags |= GNUNET_GNSRECORD_RF_SHADOW; |
1711 | add_qe_uri = GNUNET_NAMESTORE_records_store (ns, | 1704 | add_qe_uri = GNUNET_NAMESTORE_record_set_store (ns, |
1712 | &zone_pkey, | 1705 | &zone_pkey, |
1713 | sname, | 1706 | sname, |
1714 | 1, | 1707 | 1, |
@@ -1732,6 +1725,7 @@ run_with_zone_pkey (const struct GNUNET_CONFIGURATION_Handle *cfg) | |||
1732 | } | 1725 | } |
1733 | } | 1726 | } |
1734 | 1727 | ||
1728 | |||
1735 | #define MAX_LINE_LEN 4086 | 1729 | #define MAX_LINE_LEN 4086 |
1736 | 1730 | ||
1737 | #define MAX_ARGS 20 | 1731 | #define MAX_ARGS 20 |
@@ -1746,7 +1740,7 @@ get_identity_for_string (const char *str, | |||
1746 | struct EgoEntry *ego_entry; | 1740 | struct EgoEntry *ego_entry; |
1747 | 1741 | ||
1748 | if (GNUNET_OK == GNUNET_CRYPTO_public_key_from_string (str, | 1742 | if (GNUNET_OK == GNUNET_CRYPTO_public_key_from_string (str, |
1749 | &pubkey)) | 1743 | &pubkey)) |
1750 | { | 1744 | { |
1751 | for (ego_entry = ego_head; | 1745 | for (ego_entry = ego_head; |
1752 | NULL != ego_entry; ego_entry = ego_entry->next) | 1746 | NULL != ego_entry; ego_entry = ego_entry->next) |
@@ -1774,6 +1768,7 @@ get_identity_for_string (const char *str, | |||
1774 | return GNUNET_NO; | 1768 | return GNUNET_NO; |
1775 | } | 1769 | } |
1776 | 1770 | ||
1771 | |||
1777 | static void | 1772 | static void |
1778 | process_command_stdin () | 1773 | process_command_stdin () |
1779 | { | 1774 | { |
@@ -1811,7 +1806,7 @@ process_command_stdin () | |||
1811 | if (NULL == tmp) | 1806 | if (NULL == tmp) |
1812 | { | 1807 | { |
1813 | fprintf (stderr, "Error parsing name `%s'\n", next_name); | 1808 | fprintf (stderr, "Error parsing name `%s'\n", next_name); |
1814 | ns_qe = GNUNET_NAMESTORE_transaction_commit (ns, &commit_cb, NULL); | 1809 | GNUNET_SCHEDULER_shutdown(); |
1815 | ret = 1; | 1810 | ret = 1; |
1816 | return; | 1811 | return; |
1817 | } | 1812 | } |
@@ -1857,32 +1852,11 @@ process_command_stdin () | |||
1857 | fprintf (stderr, "Warning, encountered recordline without zone\n"); | 1852 | fprintf (stderr, "Warning, encountered recordline without zone\n"); |
1858 | } | 1853 | } |
1859 | } | 1854 | } |
1860 | ns_qe = GNUNET_NAMESTORE_transaction_commit (ns, &commit_cb, NULL); | 1855 | GNUNET_SCHEDULER_shutdown(); |
1861 | return; | 1856 | return; |
1862 | } | 1857 | } |
1863 | 1858 | ||
1864 | 1859 | ||
1865 | static void | ||
1866 | begin_cb (void *cls, enum GNUNET_ErrorCode ec) | ||
1867 | { | ||
1868 | ns_qe = NULL; | ||
1869 | if (GNUNET_EC_NONE != ec) | ||
1870 | { | ||
1871 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
1872 | "Failed to start transaction: %s\n", | ||
1873 | GNUNET_ErrorCode_get_hint (ec)); | ||
1874 | GNUNET_SCHEDULER_shutdown (); | ||
1875 | return; | ||
1876 | } | ||
1877 | if (read_from_stdin) | ||
1878 | { | ||
1879 | process_command_stdin (); | ||
1880 | return; | ||
1881 | } | ||
1882 | run_with_zone_pkey (cfg); | ||
1883 | } | ||
1884 | |||
1885 | |||
1886 | /** | 1860 | /** |
1887 | * Function called with ALL of the egos known to the | 1861 | * Function called with ALL of the egos known to the |
1888 | * identity service, used on startup if the user did | 1862 | * identity service, used on startup if the user did |
@@ -1922,13 +1896,15 @@ id_connect_cb (void *cls, | |||
1922 | } | 1896 | } |
1923 | if (NULL != ego) | 1897 | if (NULL != ego) |
1924 | return; | 1898 | return; |
1925 | ns_qe = GNUNET_NAMESTORE_transaction_begin (ns, &begin_cb, (void *) cfg); | 1899 | if (read_from_stdin) |
1900 | { | ||
1901 | process_command_stdin (); | ||
1902 | return; | ||
1903 | } | ||
1904 | run_with_zone_pkey (cfg); | ||
1926 | } | 1905 | } |
1927 | 1906 | ||
1928 | 1907 | ||
1929 | |||
1930 | |||
1931 | |||
1932 | /** | 1908 | /** |
1933 | * Main function that will be run. | 1909 | * Main function that will be run. |
1934 | * | 1910 | * |
@@ -1971,7 +1947,6 @@ run (void *cls, | |||
1971 | } | 1947 | } |
1972 | 1948 | ||
1973 | 1949 | ||
1974 | |||
1975 | /** | 1950 | /** |
1976 | * The main function for gnunet-namestore. | 1951 | * The main function for gnunet-namestore. |
1977 | * | 1952 | * |
diff --git a/src/cli/namestore/gnunet-zoneimport.c b/src/cli/namestore/gnunet-zoneimport.c index 9e8185653..aaed808dd 100644 --- a/src/cli/namestore/gnunet-zoneimport.c +++ b/src/cli/namestore/gnunet-zoneimport.c | |||
@@ -22,7 +22,6 @@ | |||
22 | * @brief import a DNS zone for publication in GNS, incremental | 22 | * @brief import a DNS zone for publication in GNS, incremental |
23 | * @author Christian Grothoff | 23 | * @author Christian Grothoff |
24 | */ | 24 | */ |
25 | #include "platform.h" | ||
26 | #include <gnunet_util_lib.h> | 25 | #include <gnunet_util_lib.h> |
27 | #include <gnunet_gnsrecord_lib.h> | 26 | #include <gnunet_gnsrecord_lib.h> |
28 | #include <gnunet_namestore_service.h> | 27 | #include <gnunet_namestore_service.h> |
@@ -55,7 +54,7 @@ | |||
55 | * How long do we wait at least between series of requests? | 54 | * How long do we wait at least between series of requests? |
56 | */ | 55 | */ |
57 | #define SERIES_DELAY \ | 56 | #define SERIES_DELAY \ |
58 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MICROSECONDS, 10) | 57 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MICROSECONDS, 10) |
59 | 58 | ||
60 | /** | 59 | /** |
61 | * How long do DNS records have to last at least after being imported? | 60 | * How long do DNS records have to last at least after being imported? |
@@ -1160,13 +1159,13 @@ process_result (void *cls, | |||
1160 | rd[off++] = rec->grd; | 1159 | rd[off++] = rec->grd; |
1161 | pending_rs++; | 1160 | pending_rs++; |
1162 | req->op_start_time = GNUNET_TIME_absolute_get (); | 1161 | req->op_start_time = GNUNET_TIME_absolute_get (); |
1163 | req->qe = GNUNET_NAMESTORE_records_store (ns, | 1162 | req->qe = GNUNET_NAMESTORE_record_set_store (ns, |
1164 | &req->zone->key, | 1163 | &req->zone->key, |
1165 | get_label (req), | 1164 | get_label (req), |
1166 | rd_count, | 1165 | rd_count, |
1167 | rd, | 1166 | rd, |
1168 | &store_completed_cb, | 1167 | &store_completed_cb, |
1169 | req); | 1168 | req); |
1170 | GNUNET_assert (NULL != req->qe); | 1169 | GNUNET_assert (NULL != req->qe); |
1171 | } | 1170 | } |
1172 | insert_sorted (req); | 1171 | insert_sorted (req); |
diff --git a/src/cli/reclaim/gnunet-did.c b/src/cli/reclaim/gnunet-did.c index 33f6c5657..2350b6958 100644 --- a/src/cli/reclaim/gnunet-did.c +++ b/src/cli/reclaim/gnunet-did.c | |||
@@ -33,14 +33,12 @@ | |||
33 | * @brief DID Method Wrapper | 33 | * @brief DID Method Wrapper |
34 | * | 34 | * |
35 | */ | 35 | */ |
36 | #include "platform.h" | ||
37 | #include "gnunet_util_lib.h" | 36 | #include "gnunet_util_lib.h" |
38 | #include "gnunet_namestore_service.h" | 37 | #include "gnunet_namestore_service.h" |
39 | #include "gnunet_identity_service.h" | 38 | #include "gnunet_identity_service.h" |
40 | #include "gnunet_gns_service.h" | 39 | #include "gnunet_gns_service.h" |
41 | #include "gnunet_gnsrecord_lib.h" | 40 | #include "gnunet_gnsrecord_lib.h" |
42 | #include "did_core.h" | 41 | #include "did_core.h" |
43 | #include "jansson.h" | ||
44 | 42 | ||
45 | #define GNUNET_DID_DEFAULT_DID_DOCUMENT_EXPIRATION_TIME "1d" | 43 | #define GNUNET_DID_DEFAULT_DID_DOCUMENT_EXPIRATION_TIME "1d" |
46 | 44 | ||
@@ -265,7 +263,7 @@ remove_did_document_ego_lookup_cb (void *cls, struct GNUNET_IDENTITY_Ego *ego) | |||
265 | const struct GNUNET_CRYPTO_PrivateKey *skey = | 263 | const struct GNUNET_CRYPTO_PrivateKey *skey = |
266 | GNUNET_IDENTITY_ego_get_private_key (ego); | 264 | GNUNET_IDENTITY_ego_get_private_key (ego); |
267 | 265 | ||
268 | GNUNET_NAMESTORE_records_store (namestore_handle, | 266 | GNUNET_NAMESTORE_record_set_store (namestore_handle, |
269 | skey, | 267 | skey, |
270 | GNUNET_GNS_EMPTY_LABEL_AT, | 268 | GNUNET_GNS_EMPTY_LABEL_AT, |
271 | 0, | 269 | 0, |
diff --git a/src/include/gnunet_namestore_plugin.h b/src/include/gnunet_namestore_plugin.h index d8dde5af5..c31926a49 100644 --- a/src/include/gnunet_namestore_plugin.h +++ b/src/include/gnunet_namestore_plugin.h | |||
@@ -53,6 +53,7 @@ extern "C" | |||
53 | * @param cls closure | 53 | * @param cls closure |
54 | * @param serial unique serial number of the record, MUST NOT BE ZERO, | 54 | * @param serial unique serial number of the record, MUST NOT BE ZERO, |
55 | * and must be monotonically increasing while iterating | 55 | * and must be monotonically increasing while iterating |
56 | * @param editor_hint content of the editor field when record was read (may be NULL) | ||
56 | * @param zone_key private key of the zone | 57 | * @param zone_key private key of the zone |
57 | * @param label name that is being mapped (at most 255 characters long) | 58 | * @param label name that is being mapped (at most 255 characters long) |
58 | * @param rd_count number of entries in @a rd array | 59 | * @param rd_count number of entries in @a rd array |
@@ -61,6 +62,7 @@ extern "C" | |||
61 | typedef void | 62 | typedef void |
62 | (*GNUNET_NAMESTORE_RecordIterator) (void *cls, | 63 | (*GNUNET_NAMESTORE_RecordIterator) (void *cls, |
63 | uint64_t serial, | 64 | uint64_t serial, |
65 | const char *editor_hint, | ||
64 | const struct | 66 | const struct |
65 | GNUNET_CRYPTO_PrivateKey *private_key, | 67 | GNUNET_CRYPTO_PrivateKey *private_key, |
66 | const char *label, | 68 | const char *label, |
@@ -158,42 +160,13 @@ struct GNUNET_NAMESTORE_PluginFunctions | |||
158 | /** Transaction-based API draft **/ | 160 | /** Transaction-based API draft **/ |
159 | 161 | ||
160 | /** | 162 | /** |
161 | * Start a transaction in the database | 163 | * Edit records in the namestore. |
162 | * | 164 | * This modifies the editor hint, an advisory lock entry. |
163 | * @param cls closure (internal context for the plugin) | 165 | * The record iterator will be called with the old editor hint (if any). |
164 | * @param emsg message. On error, string will be allocated and must be freed. | ||
165 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | ||
166 | */ | ||
167 | enum GNUNET_GenericReturnValue | ||
168 | (*transaction_begin)(void *cls, char **emsg); | ||
169 | |||
170 | /** | ||
171 | * Abort and roll back a transaction in the database | ||
172 | * | ||
173 | * @param cls closure (internal context for the plugin) | ||
174 | * @param emsg message. On error, string will be allocated and must be freed. | ||
175 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | ||
176 | */ | ||
177 | enum GNUNET_GenericReturnValue | ||
178 | (*transaction_rollback)(void *cls, char **emsg); | ||
179 | |||
180 | /** | ||
181 | * Commit a transaction in the database | ||
182 | * | ||
183 | * @param cls closure (internal context for the plugin) | ||
184 | * @param emsg message. On error, string will be allocated and must be freed. | ||
185 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | ||
186 | */ | ||
187 | enum GNUNET_GenericReturnValue | ||
188 | (*transaction_commit)(void *cls, char **emsg); | ||
189 | |||
190 | /** | ||
191 | * Edit records in the datastore for which we are the authority. | ||
192 | * Should be called within a transaction (after begin) and maps | ||
193 | * to a SELECT ... FOR UPDATE in PQ. | ||
194 | * | 166 | * |
195 | * @param cls closure (internal context for the plugin) | 167 | * @param cls closure (internal context for the plugin) |
196 | * @param zone private key of the zone | 168 | * @param zone private key of the zone |
169 | * @param editor_hint the new value for the advisory lock field | ||
197 | * @param label name of the record in the zone | 170 | * @param label name of the record in the zone |
198 | * @param iter function to call with the result | 171 | * @param iter function to call with the result |
199 | * @param iter_cls closure for @a iter | 172 | * @param iter_cls closure for @a iter |
@@ -201,6 +174,7 @@ struct GNUNET_NAMESTORE_PluginFunctions | |||
201 | */ | 174 | */ |
202 | enum GNUNET_GenericReturnValue | 175 | enum GNUNET_GenericReturnValue |
203 | (*edit_records)(void *cls, | 176 | (*edit_records)(void *cls, |
177 | const char *editor_hint, | ||
204 | const struct GNUNET_CRYPTO_PrivateKey *zone, | 178 | const struct GNUNET_CRYPTO_PrivateKey *zone, |
205 | const char *label, | 179 | const char *label, |
206 | GNUNET_NAMESTORE_RecordIterator iter, | 180 | GNUNET_NAMESTORE_RecordIterator iter, |
diff --git a/src/include/gnunet_namestore_service.h b/src/include/gnunet_namestore_service.h index 61691ff55..5d79ebd13 100644 --- a/src/include/gnunet_namestore_service.h +++ b/src/include/gnunet_namestore_service.h | |||
@@ -44,9 +44,7 @@ | |||
44 | 44 | ||
45 | #include "gnunet_error_codes.h" | 45 | #include "gnunet_error_codes.h" |
46 | #include "gnunet_util_lib.h" | 46 | #include "gnunet_util_lib.h" |
47 | #include "gnunet_block_lib.h" | ||
48 | #include "gnunet_gnsrecord_lib.h" | 47 | #include "gnunet_gnsrecord_lib.h" |
49 | #include "gnunet_identity_service.h" | ||
50 | 48 | ||
51 | #ifdef __cplusplus | 49 | #ifdef __cplusplus |
52 | extern "C" | 50 | extern "C" |
@@ -142,6 +140,9 @@ typedef void | |||
142 | * keep up with the changes, calling @a cont will be delayed until the | 140 | * keep up with the changes, calling @a cont will be delayed until the |
143 | * monitors do keep up. | 141 | * monitors do keep up. |
144 | * | 142 | * |
143 | * This always overwrites the record set and unsets any advisory | ||
144 | * lock inrrespective of the currently set editor hint/advisory lock value. | ||
145 | * | ||
145 | * @param h handle to the namestore | 146 | * @param h handle to the namestore |
146 | * @param pkey private key of the zone | 147 | * @param pkey private key of the zone |
147 | * @param label name that is being mapped | 148 | * @param label name that is being mapped |
@@ -152,13 +153,13 @@ typedef void | |||
152 | * @return handle to abort the request | 153 | * @return handle to abort the request |
153 | */ | 154 | */ |
154 | struct GNUNET_NAMESTORE_QueueEntry * | 155 | struct GNUNET_NAMESTORE_QueueEntry * |
155 | GNUNET_NAMESTORE_records_store (struct GNUNET_NAMESTORE_Handle *h, | 156 | GNUNET_NAMESTORE_record_set_store (struct GNUNET_NAMESTORE_Handle *h, |
156 | const struct GNUNET_CRYPTO_PrivateKey *pkey, | 157 | const struct GNUNET_CRYPTO_PrivateKey *pkey, |
157 | const char *label, | 158 | const char *label, |
158 | unsigned int rd_count, | 159 | unsigned int rd_count, |
159 | const struct GNUNET_GNSRECORD_Data *rd, | 160 | const struct GNUNET_GNSRECORD_Data *rd, |
160 | GNUNET_NAMESTORE_ContinuationWithStatus cont, | 161 | GNUNET_NAMESTORE_ContinuationWithStatus cont, |
161 | void *cont_cls); | 162 | void *cont_cls); |
162 | 163 | ||
163 | /** | 164 | /** |
164 | * Store one or more record sets in the namestore. If any item is already present, | 165 | * Store one or more record sets in the namestore. If any item is already present, |
@@ -175,6 +176,9 @@ GNUNET_NAMESTORE_records_store (struct GNUNET_NAMESTORE_Handle *h, | |||
175 | * cause @a cont to be called immediately before the commit and before | 176 | * cause @a cont to be called immediately before the commit and before |
176 | * notification of monitors. | 177 | * notification of monitors. |
177 | * | 178 | * |
179 | * This always overwrites the record set and unsets any advisory | ||
180 | * lock inrrespective of the currently set editor hint/advisory lock value. | ||
181 | * | ||
178 | * @param h handle to the namestore | 182 | * @param h handle to the namestore |
179 | * @param pkey private key of the zone | 183 | * @param pkey private key of the zone |
180 | * @param rd_set_count the number of record sets | 184 | * @param rd_set_count the number of record sets |
@@ -185,7 +189,7 @@ GNUNET_NAMESTORE_records_store (struct GNUNET_NAMESTORE_Handle *h, | |||
185 | * @return handle to abort the request | 189 | * @return handle to abort the request |
186 | */ | 190 | */ |
187 | struct GNUNET_NAMESTORE_QueueEntry * | 191 | struct GNUNET_NAMESTORE_QueueEntry * |
188 | GNUNET_NAMESTORE_records_store2 ( | 192 | GNUNET_NAMESTORE_records_store ( |
189 | struct GNUNET_NAMESTORE_Handle *h, | 193 | struct GNUNET_NAMESTORE_Handle *h, |
190 | const struct GNUNET_CRYPTO_PrivateKey *pkey, | 194 | const struct GNUNET_CRYPTO_PrivateKey *pkey, |
191 | unsigned int rd_set_count, | 195 | unsigned int rd_set_count, |
@@ -216,16 +220,14 @@ GNUNET_NAMESTORE_records_store2 ( | |||
216 | * @return handle to abort the request | 220 | * @return handle to abort the request |
217 | */ | 221 | */ |
218 | struct GNUNET_NAMESTORE_QueueEntry * | 222 | struct GNUNET_NAMESTORE_QueueEntry * |
219 | GNUNET_NAMESTORE_records_store_ (struct GNUNET_NAMESTORE_Handle *h, | 223 | GNUNET_NAMESTORE_record_set_store_ (struct GNUNET_NAMESTORE_Handle *h, |
220 | const struct GNUNET_CRYPTO_PrivateKey *pkey, | 224 | const struct GNUNET_CRYPTO_PrivateKey *pkey, |
221 | const char *label, | 225 | const char *label, |
222 | unsigned int rd_count, | 226 | unsigned int rd_count, |
223 | const struct GNUNET_GNSRECORD_Data *rd, | 227 | const struct GNUNET_GNSRECORD_Data *rd, |
224 | int is_zonemaster, | 228 | int is_zonemaster, |
225 | GNUNET_NAMESTORE_ContinuationWithStatus cont, | 229 | GNUNET_NAMESTORE_ContinuationWithStatus cont, |
226 | void *cont_cls); | 230 | void *cont_cls); |
227 | |||
228 | |||
229 | 231 | ||
230 | 232 | ||
231 | /** | 233 | /** |
@@ -244,6 +246,23 @@ typedef void | |||
244 | const char *label, | 246 | const char *label, |
245 | unsigned int rd_count, | 247 | unsigned int rd_count, |
246 | const struct GNUNET_GNSRECORD_Data *rd); | 248 | const struct GNUNET_GNSRECORD_Data *rd); |
249 | /** | ||
250 | * Process a record that was stored in the namestore. | ||
251 | * | ||
252 | * @param cls closure | ||
253 | * @param ec the error code. #GNUNET_EC_NONE on success. | ||
254 | * @param rd_count number of entries in @a rd array, 0 if label was deleted | ||
255 | * @param rd array of records with data to store | ||
256 | * @param editor_hint the advisory lock value that was replaced. NULL of not advisory lock | ||
257 | was set or if lock was equal to provided editor hint. | ||
258 | */ | ||
259 | typedef void | ||
260 | (*GNUNET_NAMESTORE_EditRecordSetBeginCallback) (void *cls, | ||
261 | enum GNUNET_ErrorCode ec, | ||
262 | unsigned int rd_count, | ||
263 | const struct | ||
264 | GNUNET_GNSRECORD_Data *rd, | ||
265 | const char *editor_hint); | ||
247 | 266 | ||
248 | /** | 267 | /** |
249 | * Process a record set that was stored in the namestore. | 268 | * Process a record set that was stored in the namestore. |
@@ -318,7 +337,6 @@ GNUNET_NAMESTORE_records_lookup2 (struct GNUNET_NAMESTORE_Handle *h, | |||
318 | enum GNUNET_GNSRECORD_Filter filter); | 337 | enum GNUNET_GNSRECORD_Filter filter); |
319 | 338 | ||
320 | 339 | ||
321 | |||
322 | /** | 340 | /** |
323 | * Look for an existing PKEY delegation record for a given public key. | 341 | * Look for an existing PKEY delegation record for a given public key. |
324 | * Returns at most one result to the processor. | 342 | * Returns at most one result to the processor. |
@@ -437,7 +455,6 @@ GNUNET_NAMESTORE_zone_iteration_start2 (struct GNUNET_NAMESTORE_Handle *h, | |||
437 | enum GNUNET_GNSRECORD_Filter filter); | 455 | enum GNUNET_GNSRECORD_Filter filter); |
438 | 456 | ||
439 | 457 | ||
440 | |||
441 | /** | 458 | /** |
442 | * Calls the record processor specified in #GNUNET_NAMESTORE_zone_iteration_start | 459 | * Calls the record processor specified in #GNUNET_NAMESTORE_zone_iteration_start |
443 | * for the next record. | 460 | * for the next record. |
@@ -592,57 +609,62 @@ GNUNET_NAMESTORE_zone_monitor_stop (struct GNUNET_NAMESTORE_ZoneMonitor *zm); | |||
592 | */ | 609 | */ |
593 | 610 | ||
594 | /** | 611 | /** |
595 | * Begin a namestore transaction. | 612 | * This function is used to initiate the editing |
613 | * of a record set under #label. | ||
614 | * It will set the editor hint of the record set to #editor_hint. | ||
615 | * The editor hint serves as an advisory lock that is used in | ||
616 | * #GNUNET_NAMESTORE_EdtirRecordSetBeginCallback if #editor_hint | ||
617 | * differs from the currently set advisory lock in the database. | ||
596 | * | 618 | * |
597 | * @param h handle to the namestore | 619 | * @param h handle to the namestore |
598 | * @param cont function to call on result | 620 | * @param pkey the private key of the zone to edit |
599 | * @param cont_cls closure for @a cont | 621 | * @param label the label of the record set to edit |
600 | * @return handle to abort the request | 622 | * @param editor_hint the editor hint to set as advisory lock |
623 | * @param error_cb the error callback | ||
624 | * @param error_cb_cls closure to #error_cb | ||
625 | * @param edit_cb the #GNUNET_NAMESTORE_EditRecordSetBeginCallback | ||
626 | * @param edit_cb_cls closure to #edit_cb | ||
627 | * @return handle to the operation | ||
601 | */ | 628 | */ |
602 | struct GNUNET_NAMESTORE_QueueEntry * | 629 | struct GNUNET_NAMESTORE_QueueEntry * |
603 | GNUNET_NAMESTORE_transaction_begin (struct GNUNET_NAMESTORE_Handle *h, | 630 | GNUNET_NAMESTORE_record_set_edit_begin (struct GNUNET_NAMESTORE_Handle *h, |
604 | GNUNET_NAMESTORE_ContinuationWithStatus | 631 | const struct |
605 | cont, | 632 | GNUNET_CRYPTO_PrivateKey *pkey, |
606 | void *cont_cls); | 633 | const char *label, |
634 | const char *editor_hint, | ||
635 | GNUNET_NAMESTORE_EditRecordSetBeginCallback | ||
636 | edit_cb, | ||
637 | void *edit_cb_cls); | ||
607 | 638 | ||
608 | /** | 639 | /** |
609 | * Begin rollback all actions in a transaction. | 640 | * If the current advisory lock is set to the provided editor hint, |
610 | * Reverts all actions performed since #GNUNET_NAMESTORE_transaction_begin | 641 | * this API cancels the editing of a record set and unsets the advisory lock in database. |
642 | * Optionally, a new editor hint can be provided: For example, | ||
643 | * the value that was returned in in the callback to | ||
644 | * #GNUNET_NAMESTORE_record_set_edit_begin. | ||
611 | * | 645 | * |
612 | * @param h handle to the namestore | 646 | * If provided editor hint does not match the current advisory lock, |
613 | * @param cont function to call on result | 647 | * this function is not doing anything (NOP). |
614 | * @param cont_cls closure for @a cont | ||
615 | * @return handle to abort the request | ||
616 | */ | ||
617 | struct GNUNET_NAMESTORE_QueueEntry * | ||
618 | GNUNET_NAMESTORE_transaction_rollback (struct GNUNET_NAMESTORE_Handle *h, | ||
619 | GNUNET_NAMESTORE_ContinuationWithStatus | ||
620 | cont, | ||
621 | void *cont_cls); | ||
622 | /** | ||
623 | * Commit a namestore transaction. | ||
624 | * Saves all actions performed since #GNUNET_NAMESTORE_transaction_begin | ||
625 | * | 648 | * |
626 | * @param h handle to the namestore | 649 | * @param h handle to the namestore |
627 | * @param cont function to call on result | 650 | * @param pkey the private key of the zone to edit |
628 | * @param cont_cls closure for @a cont | 651 | * @param label the label of the record set to edit |
629 | * @return handle to abort the request | 652 | * @param editor_hint the editor hint to set as advisory lock |
653 | * @param editor_hint_replacement the editor hint to set as advisory lock instead of clearing it | ||
654 | * @param finished_cb the callback called when cancelled | ||
655 | * @param finished_cb_cls closure to #finished_cb | ||
656 | * @return handle to the operation | ||
630 | */ | 657 | */ |
631 | struct GNUNET_NAMESTORE_QueueEntry * | 658 | struct GNUNET_NAMESTORE_QueueEntry * |
632 | GNUNET_NAMESTORE_transaction_commit (struct GNUNET_NAMESTORE_Handle *h, | 659 | GNUNET_NAMESTORE_record_set_edit_cancel (struct GNUNET_NAMESTORE_Handle *h, |
633 | GNUNET_NAMESTORE_ContinuationWithStatus | 660 | const struct |
634 | cont, | 661 | GNUNET_CRYPTO_PrivateKey *pkey, |
635 | void *cont_cls); | 662 | const char *label, |
636 | 663 | const char *editor_hint, | |
637 | struct GNUNET_NAMESTORE_QueueEntry * | 664 | const char *editor_hint_replacement, |
638 | GNUNET_NAMESTORE_records_edit ( | 665 | GNUNET_SCHEDULER_TaskCallback |
639 | struct GNUNET_NAMESTORE_Handle *h, | 666 | finished_cb, |
640 | const struct GNUNET_CRYPTO_PrivateKey *pkey, | 667 | void *finished_cls); |
641 | const char *label, | ||
642 | GNUNET_SCHEDULER_TaskCallback error_cb, | ||
643 | void *error_cb_cls, | ||
644 | GNUNET_NAMESTORE_RecordMonitor rm, | ||
645 | void *rm_cls); | ||
646 | 668 | ||
647 | #if 0 /* keep Emacsens' auto-indent happy */ | 669 | #if 0 /* keep Emacsens' auto-indent happy */ |
648 | { | 670 | { |
diff --git a/src/include/gnunet_protocols.h b/src/include/gnunet_protocols.h index a998344b9..17aeff63f 100644 --- a/src/include/gnunet_protocols.h +++ b/src/include/gnunet_protocols.h | |||
@@ -1327,7 +1327,7 @@ extern "C" { | |||
1327 | /** | 1327 | /** |
1328 | * Service to client: result of store operation. | 1328 | * Service to client: result of store operation. |
1329 | */ | 1329 | */ |
1330 | #define GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_STORE_RESPONSE 436 | 1330 | #define GNUNET_MESSAGE_TYPE_NAMESTORE_GENERIC_RESPONSE 436 |
1331 | 1331 | ||
1332 | /** | 1332 | /** |
1333 | * Client to service: lookup label | 1333 | * Client to service: lookup label |
@@ -3631,20 +3631,19 @@ extern "C" { | |||
3631 | */ | 3631 | */ |
3632 | 3632 | ||
3633 | /** | 3633 | /** |
3634 | * Message type for Begin, Commit or Rollback | 3634 | * Message type for start of record edit with advisory lock |
3635 | */ | 3635 | */ |
3636 | #define GNUNET_MESSAGE_TYPE_NAMESTORE_TX_CONTROL 1750 | 3636 | #define GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_SET_EDIT 1750 |
3637 | 3637 | ||
3638 | /** | 3638 | /** |
3639 | * Return status message for control message | 3639 | * Return record set to edit with previous editor hint/advisory lock |
3640 | */ | 3640 | */ |
3641 | #define GNUNET_MESSAGE_TYPE_NAMESTORE_TX_CONTROL_RESULT 1751 | 3641 | #define GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_SET_EDIT_RESPONSE 1751 |
3642 | 3642 | ||
3643 | /** | 3643 | /** |
3644 | * Open and lock records for editing message | 3644 | * Message type for cancellation/reset of editor hint/advisory lock |
3645 | */ | 3645 | */ |
3646 | #define GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_EDIT 1752 | 3646 | #define GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_SET_EDIT_CANCEL 1752 |
3647 | |||
3648 | 3647 | ||
3649 | /** | 3648 | /** |
3650 | * Type used to match 'all' message types. | 3649 | * Type used to match 'all' message types. |
diff --git a/src/lib/util/gnunet_error_codes.c b/src/lib/util/gnunet_error_codes.c index 11ce2d0c8..c286f2e52 100644 --- a/src/lib/util/gnunet_error_codes.c +++ b/src/lib/util/gnunet_error_codes.c | |||
@@ -17,6 +17,7 @@ | |||
17 | 17 | ||
18 | SPDX-License-Identifier: AGPL3.0-or-later | 18 | SPDX-License-Identifier: AGPL3.0-or-later |
19 | */ | 19 | */ |
20 | #include "platform.h" | ||
20 | #include "gnunet_error_codes.h" | 21 | #include "gnunet_error_codes.h" |
21 | #include <stddef.h> | 22 | #include <stddef.h> |
22 | #include <microhttpd.h> | 23 | #include <microhttpd.h> |
diff --git a/src/plugin/namestore/namestore-0001.sql b/src/plugin/namestore/namestore-0001.sql index bdfb31976..bd323e365 100644 --- a/src/plugin/namestore/namestore-0001.sql +++ b/src/plugin/namestore/namestore-0001.sql | |||
@@ -35,6 +35,7 @@ CREATE TABLE ns098records ( | |||
35 | record_count INTEGER NOT NULL DEFAULT 0, | 35 | record_count INTEGER NOT NULL DEFAULT 0, |
36 | record_data BYTEA NOT NULL DEFAULT '', | 36 | record_data BYTEA NOT NULL DEFAULT '', |
37 | label TEXT NOT NULL DEFAULT '', | 37 | label TEXT NOT NULL DEFAULT '', |
38 | editor_hint TEXT NOT NULL DEFAULT '', | ||
38 | CONSTRAINT zl UNIQUE (zone_private_key,label)); | 39 | CONSTRAINT zl UNIQUE (zone_private_key,label)); |
39 | 40 | ||
40 | CREATE INDEX IF NOT EXISTS ir_pkey_reverse | 41 | CREATE INDEX IF NOT EXISTS ir_pkey_reverse |
diff --git a/src/plugin/namestore/plugin_namestore_flat.c b/src/plugin/namestore/plugin_namestore_flat.c index 716071ff3..20019e1db 100644 --- a/src/plugin/namestore/plugin_namestore_flat.c +++ b/src/plugin/namestore/plugin_namestore_flat.c | |||
@@ -26,7 +26,6 @@ | |||
26 | 26 | ||
27 | #include "platform.h" | 27 | #include "platform.h" |
28 | #include "gnunet_namestore_plugin.h" | 28 | #include "gnunet_namestore_plugin.h" |
29 | #include "gnunet_namestore_service.h" | ||
30 | #include "gnunet_gnsrecord_lib.h" | 29 | #include "gnunet_gnsrecord_lib.h" |
31 | 30 | ||
32 | /** | 31 | /** |
diff --git a/src/plugin/namestore/plugin_namestore_postgres.c b/src/plugin/namestore/plugin_namestore_postgres.c index 1dc526dc2..e4c350a3e 100644 --- a/src/plugin/namestore/plugin_namestore_postgres.c +++ b/src/plugin/namestore/plugin_namestore_postgres.c | |||
@@ -23,9 +23,7 @@ | |||
23 | * @brief postgres-based namestore backend | 23 | * @brief postgres-based namestore backend |
24 | * @author Christian Grothoff | 24 | * @author Christian Grothoff |
25 | */ | 25 | */ |
26 | #include "platform.h" | ||
27 | #include "gnunet_namestore_plugin.h" | 26 | #include "gnunet_namestore_plugin.h" |
28 | #include "gnunet_namestore_service.h" | ||
29 | #include "gnunet_gnsrecord_lib.h" | 27 | #include "gnunet_gnsrecord_lib.h" |
30 | #include "gnunet_pq_lib.h" | 28 | #include "gnunet_pq_lib.h" |
31 | 29 | ||
@@ -122,8 +120,8 @@ database_prepare (struct Plugin *plugin) | |||
122 | struct GNUNET_PQ_PreparedStatement ps[] = { | 120 | struct GNUNET_PQ_PreparedStatement ps[] = { |
123 | GNUNET_PQ_make_prepare ("store_records", | 121 | GNUNET_PQ_make_prepare ("store_records", |
124 | "INSERT INTO namestore.ns098records" | 122 | "INSERT INTO namestore.ns098records" |
125 | " (zone_private_key, pkey, rvalue, record_count, record_data, label)" | 123 | " (zone_private_key, pkey, rvalue, record_count, record_data, label, editor_hint)" |
126 | " VALUES ($1, $2, $3, $4, $5, $6)" | 124 | " VALUES ($1, $2, $3, $4, $5, $6, '')" |
127 | " ON CONFLICT ON CONSTRAINT zl" | 125 | " ON CONFLICT ON CONSTRAINT zl" |
128 | " DO UPDATE" | 126 | " DO UPDATE" |
129 | " SET pkey=$2,rvalue=$3,record_count=$4,record_data=$5" | 127 | " SET pkey=$2,rvalue=$3,record_count=$4,record_data=$5" |
@@ -133,20 +131,22 @@ database_prepare (struct Plugin *plugin) | |||
133 | "DELETE FROM namestore.ns098records " | 131 | "DELETE FROM namestore.ns098records " |
134 | "WHERE zone_private_key=$1 AND label=$2"), | 132 | "WHERE zone_private_key=$1 AND label=$2"), |
135 | GNUNET_PQ_make_prepare ("zone_to_name", | 133 | GNUNET_PQ_make_prepare ("zone_to_name", |
136 | "SELECT seq,record_count,record_data,label FROM namestore.ns098records" | 134 | "SELECT seq,record_count,record_data,label,editor_hint FROM namestore.ns098records" |
137 | " WHERE zone_private_key=$1 AND pkey=$2"), | 135 | " WHERE zone_private_key=$1 AND pkey=$2"), |
138 | GNUNET_PQ_make_prepare ("iterate_zone", | 136 | GNUNET_PQ_make_prepare ("iterate_zone", |
139 | "SELECT seq,record_count,record_data,label FROM namestore.ns098records " | 137 | "SELECT seq,record_count,record_data,label,editor_hint FROM namestore.ns098records " |
140 | "WHERE zone_private_key=$1 AND seq > $2 ORDER BY seq ASC LIMIT $3"), | 138 | "WHERE zone_private_key=$1 AND seq > $2 ORDER BY seq ASC LIMIT $3"), |
141 | GNUNET_PQ_make_prepare ("iterate_all_zones", | 139 | GNUNET_PQ_make_prepare ("iterate_all_zones", |
142 | "SELECT seq,record_count,record_data,label,zone_private_key" | 140 | "SELECT seq,record_count,record_data,label,editor_hint,zone_private_key" |
143 | " FROM namestore.ns098records WHERE seq > $1 ORDER BY seq ASC LIMIT $2"), | 141 | " FROM namestore.ns098records WHERE seq > $1 ORDER BY seq ASC LIMIT $2"), |
144 | GNUNET_PQ_make_prepare ("lookup_label", | 142 | GNUNET_PQ_make_prepare ("lookup_label", |
145 | "SELECT seq,record_count,record_data,label " | 143 | "SELECT seq,record_count,record_data,label,editor_hint " |
146 | "FROM namestore.ns098records WHERE zone_private_key=$1 AND label=$2"), | 144 | "FROM namestore.ns098records WHERE zone_private_key=$1 AND label=$2"), |
147 | GNUNET_PQ_make_prepare ("edit_set", | 145 | GNUNET_PQ_make_prepare ("edit_set", |
148 | "SELECT seq,record_count,record_data,label " | 146 | "UPDATE namestore.ns098records" |
149 | "FROM namestore.ns098records WHERE zone_private_key=$1 AND label=$2 FOR UPDATE NOWAIT"), | 147 | "SET editor_hint=$3" |
148 | "WHERE zone_private_key=$1 AND label=$2" | ||
149 | "RETURNING seq,record_count,record_data,label,editor_hint "), | ||
150 | GNUNET_PQ_PREPARED_STATEMENT_END | 150 | GNUNET_PQ_PREPARED_STATEMENT_END |
151 | }; | 151 | }; |
152 | 152 | ||
@@ -377,12 +377,14 @@ parse_result_call_iterator (void *cls, | |||
377 | size_t data_size; | 377 | size_t data_size; |
378 | uint32_t record_count; | 378 | uint32_t record_count; |
379 | char *label; | 379 | char *label; |
380 | char *editor_hint; | ||
380 | struct GNUNET_CRYPTO_PrivateKey zk; | 381 | struct GNUNET_CRYPTO_PrivateKey zk; |
381 | struct GNUNET_PQ_ResultSpec rs_with_zone[] = { | 382 | struct GNUNET_PQ_ResultSpec rs_with_zone[] = { |
382 | GNUNET_PQ_result_spec_uint64 ("seq", &serial), | 383 | GNUNET_PQ_result_spec_uint64 ("seq", &serial), |
383 | GNUNET_PQ_result_spec_uint32 ("record_count", &record_count), | 384 | GNUNET_PQ_result_spec_uint32 ("record_count", &record_count), |
384 | GNUNET_PQ_result_spec_variable_size ("record_data", &data, &data_size), | 385 | GNUNET_PQ_result_spec_variable_size ("record_data", &data, &data_size), |
385 | GNUNET_PQ_result_spec_string ("label", &label), | 386 | GNUNET_PQ_result_spec_string ("label", &label), |
387 | GNUNET_PQ_result_spec_string ("editor_hint", &editor_hint), | ||
386 | GNUNET_PQ_result_spec_auto_from_type ("zone_private_key", &zk), | 388 | GNUNET_PQ_result_spec_auto_from_type ("zone_private_key", &zk), |
387 | GNUNET_PQ_result_spec_end | 389 | GNUNET_PQ_result_spec_end |
388 | }; | 390 | }; |
@@ -391,6 +393,7 @@ parse_result_call_iterator (void *cls, | |||
391 | GNUNET_PQ_result_spec_uint32 ("record_count", &record_count), | 393 | GNUNET_PQ_result_spec_uint32 ("record_count", &record_count), |
392 | GNUNET_PQ_result_spec_variable_size ("record_data", &data, &data_size), | 394 | GNUNET_PQ_result_spec_variable_size ("record_data", &data, &data_size), |
393 | GNUNET_PQ_result_spec_string ("label", &label), | 395 | GNUNET_PQ_result_spec_string ("label", &label), |
396 | GNUNET_PQ_result_spec_string ("editor_hint", &editor_hint), | ||
394 | GNUNET_PQ_result_spec_end | 397 | GNUNET_PQ_result_spec_end |
395 | }; | 398 | }; |
396 | struct GNUNET_PQ_ResultSpec *rs; | 399 | struct GNUNET_PQ_ResultSpec *rs; |
@@ -430,6 +433,7 @@ parse_result_call_iterator (void *cls, | |||
430 | } | 433 | } |
431 | pc->iter (pc->iter_cls, | 434 | pc->iter (pc->iter_cls, |
432 | serial, | 435 | serial, |
436 | editor_hint, | ||
433 | (NULL == pc->zone_key) ? &zk : pc->zone_key, | 437 | (NULL == pc->zone_key) ? &zk : pc->zone_key, |
434 | label, | 438 | label, |
435 | record_count, | 439 | record_count, |
@@ -459,13 +463,15 @@ lookup_records (void *cls, | |||
459 | const char *label, | 463 | const char *label, |
460 | GNUNET_NAMESTORE_RecordIterator iter, | 464 | GNUNET_NAMESTORE_RecordIterator iter, |
461 | void *iter_cls, | 465 | void *iter_cls, |
462 | const char*method) | 466 | const char *method, |
467 | const char *editor_hint) | ||
463 | { | 468 | { |
464 | struct Plugin *plugin = cls; | 469 | struct Plugin *plugin = cls; |
465 | GNUNET_assert (GNUNET_OK == database_prepare (plugin)); | 470 | GNUNET_assert (GNUNET_OK == database_prepare (plugin)); |
466 | struct GNUNET_PQ_QueryParam params[] = { | 471 | struct GNUNET_PQ_QueryParam params[] = { |
467 | GNUNET_PQ_query_param_auto_from_type (zone), | 472 | GNUNET_PQ_query_param_auto_from_type (zone), |
468 | GNUNET_PQ_query_param_string (label), | 473 | GNUNET_PQ_query_param_string (label), |
474 | GNUNET_PQ_query_param_string (editor_hint), | ||
469 | GNUNET_PQ_query_param_end | 475 | GNUNET_PQ_query_param_end |
470 | }; | 476 | }; |
471 | struct ParserContext pc; | 477 | struct ParserContext pc; |
@@ -510,7 +516,7 @@ namestore_postgres_lookup_records (void *cls, | |||
510 | GNUNET_NAMESTORE_RecordIterator iter, | 516 | GNUNET_NAMESTORE_RecordIterator iter, |
511 | void *iter_cls) | 517 | void *iter_cls) |
512 | { | 518 | { |
513 | return lookup_records (cls, zone, label, iter, iter_cls, "lookup_label"); | 519 | return lookup_records (cls, zone, label, iter, iter_cls, "lookup_label", ""); |
514 | } | 520 | } |
515 | 521 | ||
516 | 522 | ||
@@ -526,13 +532,15 @@ namestore_postgres_lookup_records (void *cls, | |||
526 | */ | 532 | */ |
527 | static int | 533 | static int |
528 | namestore_postgres_edit_records (void *cls, | 534 | namestore_postgres_edit_records (void *cls, |
535 | const char *editor_hint, | ||
529 | const struct | 536 | const struct |
530 | GNUNET_CRYPTO_PrivateKey *zone, | 537 | GNUNET_CRYPTO_PrivateKey *zone, |
531 | const char *label, | 538 | const char *label, |
532 | GNUNET_NAMESTORE_RecordIterator iter, | 539 | GNUNET_NAMESTORE_RecordIterator iter, |
533 | void *iter_cls) | 540 | void *iter_cls) |
534 | { | 541 | { |
535 | return lookup_records (cls, zone, label, iter, iter_cls, "edit_set"); | 542 | return lookup_records (cls, zone, label, iter, iter_cls, "edit_set", |
543 | (NULL == editor_hint) ? "" : editor_hint); | ||
536 | } | 544 | } |
537 | 545 | ||
538 | 546 | ||
@@ -650,74 +658,6 @@ namestore_postgres_zone_to_name (void *cls, | |||
650 | 658 | ||
651 | 659 | ||
652 | /** | 660 | /** |
653 | * Begin a transaction for a client. | ||
654 | * | ||
655 | * @param cls closure (internal context for the plugin) | ||
656 | * @param emsg error message set of return code is #GNUNET_SYSERR | ||
657 | * @return #GNUNET_YES on success, #GNUNET_SYSERR if transaction cannot be started. | ||
658 | */ | ||
659 | static enum GNUNET_GenericReturnValue | ||
660 | namestore_postgres_transaction_begin (void *cls, | ||
661 | char **emsg) | ||
662 | { | ||
663 | struct Plugin *plugin = cls; | ||
664 | GNUNET_assert (GNUNET_OK == database_prepare (plugin)); | ||
665 | struct GNUNET_PQ_ExecuteStatement es[] = { | ||
666 | GNUNET_PQ_make_execute ("BEGIN"), | ||
667 | GNUNET_PQ_EXECUTE_STATEMENT_END | ||
668 | }; | ||
669 | |||
670 | return GNUNET_PQ_exec_statements (plugin->dbh, es); | ||
671 | } | ||
672 | |||
673 | |||
674 | /** | ||
675 | * Commit a transaction for a client. | ||
676 | * This releases the lock on the database. | ||
677 | * | ||
678 | * @param cls closure (internal context for the plugin) | ||
679 | * @param emsg error message set of return code is #GNUNET_SYSERR | ||
680 | * @return #GNUNET_YES on success, #GNUNET_SYSERR if transaction cannot be started. | ||
681 | */ | ||
682 | static enum GNUNET_GenericReturnValue | ||
683 | namestore_postgres_transaction_rollback (void *cls, | ||
684 | char **emsg) | ||
685 | { | ||
686 | struct Plugin *plugin = cls; | ||
687 | GNUNET_assert (GNUNET_OK == database_prepare (plugin)); | ||
688 | struct GNUNET_PQ_ExecuteStatement es[] = { | ||
689 | GNUNET_PQ_make_execute ("ROLLBACK"), | ||
690 | GNUNET_PQ_EXECUTE_STATEMENT_END | ||
691 | }; | ||
692 | |||
693 | return GNUNET_PQ_exec_statements (plugin->dbh, es); | ||
694 | } | ||
695 | |||
696 | |||
697 | /** | ||
698 | * Roll back a transaction for a client. | ||
699 | * This releases the lock on the database. | ||
700 | * | ||
701 | * @param cls closure (internal context for the plugin) | ||
702 | * @param emsg error message set of return code is #GNUNET_SYSERR | ||
703 | * @return #GNUNET_YES on success, #GNUNET_SYSERR if transaction cannot be started. | ||
704 | */ | ||
705 | static enum GNUNET_GenericReturnValue | ||
706 | namestore_postgres_transaction_commit (void *cls, | ||
707 | char **emsg) | ||
708 | { | ||
709 | struct Plugin *plugin = cls; | ||
710 | GNUNET_assert (GNUNET_OK == database_prepare (plugin)); | ||
711 | struct GNUNET_PQ_ExecuteStatement es[] = { | ||
712 | GNUNET_PQ_make_execute ("COMMIT"), | ||
713 | GNUNET_PQ_EXECUTE_STATEMENT_END | ||
714 | }; | ||
715 | |||
716 | return GNUNET_PQ_exec_statements (plugin->dbh, es); | ||
717 | } | ||
718 | |||
719 | |||
720 | /** | ||
721 | * Shutdown database connection and associate data | 661 | * Shutdown database connection and associate data |
722 | * structures. | 662 | * structures. |
723 | * | 663 | * |
@@ -760,9 +700,6 @@ libgnunet_plugin_namestore_postgres_init (void *cls) | |||
760 | api->iterate_records = &namestore_postgres_iterate_records; | 700 | api->iterate_records = &namestore_postgres_iterate_records; |
761 | api->zone_to_name = &namestore_postgres_zone_to_name; | 701 | api->zone_to_name = &namestore_postgres_zone_to_name; |
762 | api->lookup_records = &namestore_postgres_lookup_records; | 702 | api->lookup_records = &namestore_postgres_lookup_records; |
763 | api->transaction_begin = &namestore_postgres_transaction_begin; | ||
764 | api->transaction_commit = &namestore_postgres_transaction_commit; | ||
765 | api->transaction_rollback = &namestore_postgres_transaction_rollback; | ||
766 | api->edit_records = &namestore_postgres_edit_records; | 703 | api->edit_records = &namestore_postgres_edit_records; |
767 | LOG (GNUNET_ERROR_TYPE_INFO, | 704 | LOG (GNUNET_ERROR_TYPE_INFO, |
768 | "Postgres namestore plugin running\n"); | 705 | "Postgres namestore plugin running\n"); |
diff --git a/src/plugin/namestore/plugin_namestore_sqlite.c b/src/plugin/namestore/plugin_namestore_sqlite.c index ada9ca25b..c38e9e08f 100644 --- a/src/plugin/namestore/plugin_namestore_sqlite.c +++ b/src/plugin/namestore/plugin_namestore_sqlite.c | |||
@@ -26,7 +26,6 @@ | |||
26 | 26 | ||
27 | #include "platform.h" | 27 | #include "platform.h" |
28 | #include "gnunet_namestore_plugin.h" | 28 | #include "gnunet_namestore_plugin.h" |
29 | #include "gnunet_namestore_service.h" | ||
30 | #include "gnunet_gnsrecord_lib.h" | 29 | #include "gnunet_gnsrecord_lib.h" |
31 | #include "gnunet_sq_lib.h" | 30 | #include "gnunet_sq_lib.h" |
32 | #include <sqlite3.h> | 31 | #include <sqlite3.h> |
@@ -50,13 +49,13 @@ | |||
50 | * with the message given by strerror(errno). | 49 | * with the message given by strerror(errno). |
51 | */ | 50 | */ |
52 | #define LOG_SQLITE(db, level, cmd) do { \ | 51 | #define LOG_SQLITE(db, level, cmd) do { \ |
53 | GNUNET_log_from (level, \ | 52 | GNUNET_log_from (level, \ |
54 | "namestore-sqlite", _ ( \ | 53 | "namestore-sqlite", _ ( \ |
55 | "`%s' failed at %s:%d with error: %s\n"), \ | 54 | "`%s' failed at %s:%d with error: %s\n"), \ |
56 | cmd, \ | 55 | cmd, \ |
57 | __FILE__, __LINE__, \ | 56 | __FILE__, __LINE__, \ |
58 | sqlite3_errmsg ( \ | 57 | sqlite3_errmsg ( \ |
59 | db->dbh)); \ | 58 | db->dbh)); \ |
60 | } while (0) | 59 | } while (0) |
61 | 60 | ||
62 | #define LOG(kind, ...) GNUNET_log_from (kind, "namestore-sqlite", __VA_ARGS__) | 61 | #define LOG(kind, ...) GNUNET_log_from (kind, "namestore-sqlite", __VA_ARGS__) |
@@ -142,32 +141,35 @@ database_prepare (struct Plugin *plugin) | |||
142 | }; | 141 | }; |
143 | struct GNUNET_SQ_PrepareStatement ps[] = { | 142 | struct GNUNET_SQ_PrepareStatement ps[] = { |
144 | GNUNET_SQ_make_prepare ("INSERT INTO ns098records " | 143 | GNUNET_SQ_make_prepare ("INSERT INTO ns098records " |
145 | "(zone_private_key,pkey,rvalue,record_count,record_data,label)" | 144 | "(zone_private_key,pkey,rvalue,record_count,record_data," |
146 | " VALUES (?, ?, ?, ?, ?, ?)", | 145 | "label,editor_hint)" |
146 | " VALUES (?, ?, ?, ?, ?, ?, '')", | ||
147 | &plugin->store_records), | 147 | &plugin->store_records), |
148 | GNUNET_SQ_make_prepare ("DELETE FROM ns098records " | 148 | GNUNET_SQ_make_prepare ("DELETE FROM ns098records " |
149 | "WHERE zone_private_key=? AND label=?", | 149 | "WHERE zone_private_key=? AND label=?", |
150 | &plugin->delete_records), | 150 | &plugin->delete_records), |
151 | GNUNET_SQ_make_prepare ("SELECT uid,record_count,record_data,label" | 151 | GNUNET_SQ_make_prepare ("SELECT uid,record_count,record_data,label,editor_hint" |
152 | " FROM ns098records" | 152 | " FROM ns098records" |
153 | " WHERE zone_private_key=? AND pkey=?", | 153 | " WHERE zone_private_key=? AND pkey=?", |
154 | &plugin->zone_to_name), | 154 | &plugin->zone_to_name), |
155 | GNUNET_SQ_make_prepare ("SELECT uid,record_count,record_data,label" | 155 | GNUNET_SQ_make_prepare ("SELECT uid,record_count,record_data,label,editor_hint" |
156 | " FROM ns098records" | 156 | " FROM ns098records" |
157 | " WHERE zone_private_key=? AND uid > ?" | 157 | " WHERE zone_private_key=? AND uid > ?" |
158 | " ORDER BY uid ASC" | 158 | " ORDER BY uid ASC" |
159 | " LIMIT ?", | 159 | " LIMIT ?", |
160 | &plugin->iterate_zone), | 160 | &plugin->iterate_zone), |
161 | GNUNET_SQ_make_prepare ( | 161 | GNUNET_SQ_make_prepare ( |
162 | "SELECT uid,record_count,record_data,label,zone_private_key" | 162 | "SELECT uid,record_count,record_data,label,editor_hint,zone_private_key" |
163 | " FROM ns098records" | 163 | " FROM ns098records" |
164 | " WHERE uid > ?" | 164 | " WHERE uid > ?" |
165 | " ORDER BY uid ASC" | 165 | " ORDER BY uid ASC" |
166 | " LIMIT ?", | 166 | " LIMIT ?", |
167 | &plugin->iterate_all_zones), | 167 | &plugin->iterate_all_zones), |
168 | GNUNET_SQ_make_prepare ("SELECT uid,record_count,record_data,label" | 168 | GNUNET_SQ_make_prepare ("UPDATE ns098records" |
169 | " FROM ns098records" | 169 | " SET editor_hint=?" |
170 | " WHERE zone_private_key=? AND label=?", | 170 | " FROM ns098records AS old_ns098records" |
171 | " WHERE ns098records.zone_private_key=? AND ns098records.label=?" | ||
172 | " RETURNING ns098records.uid,ns098records.record_count,ns098records.record_data,ns098records.label,editor_hint ", | ||
171 | &plugin->lookup_label), | 173 | &plugin->lookup_label), |
172 | GNUNET_SQ_PREPARE_END | 174 | GNUNET_SQ_PREPARE_END |
173 | }; | 175 | }; |
@@ -460,6 +462,7 @@ get_records_and_call_iterator (struct Plugin *plugin, | |||
460 | size_t data_size; | 462 | size_t data_size; |
461 | void *data; | 463 | void *data; |
462 | char *label; | 464 | char *label; |
465 | char *editor_hint; | ||
463 | struct GNUNET_CRYPTO_PrivateKey zk; | 466 | struct GNUNET_CRYPTO_PrivateKey zk; |
464 | struct GNUNET_SQ_ResultSpec rs[] = { | 467 | struct GNUNET_SQ_ResultSpec rs[] = { |
465 | GNUNET_SQ_result_spec_uint64 (&seq), | 468 | GNUNET_SQ_result_spec_uint64 (&seq), |
@@ -467,6 +470,7 @@ get_records_and_call_iterator (struct Plugin *plugin, | |||
467 | GNUNET_SQ_result_spec_variable_size (&data, | 470 | GNUNET_SQ_result_spec_variable_size (&data, |
468 | &data_size), | 471 | &data_size), |
469 | GNUNET_SQ_result_spec_string (&label), | 472 | GNUNET_SQ_result_spec_string (&label), |
473 | GNUNET_SQ_result_spec_string (&editor_hint), | ||
470 | GNUNET_SQ_result_spec_end | 474 | GNUNET_SQ_result_spec_end |
471 | }; | 475 | }; |
472 | struct GNUNET_SQ_ResultSpec rsx[] = { | 476 | struct GNUNET_SQ_ResultSpec rsx[] = { |
@@ -475,6 +479,7 @@ get_records_and_call_iterator (struct Plugin *plugin, | |||
475 | GNUNET_SQ_result_spec_variable_size (&data, | 479 | GNUNET_SQ_result_spec_variable_size (&data, |
476 | &data_size), | 480 | &data_size), |
477 | GNUNET_SQ_result_spec_string (&label), | 481 | GNUNET_SQ_result_spec_string (&label), |
482 | GNUNET_SQ_result_spec_string (&editor_hint), | ||
478 | GNUNET_SQ_result_spec_auto_from_type (&zk), | 483 | GNUNET_SQ_result_spec_auto_from_type (&zk), |
479 | GNUNET_SQ_result_spec_end | 484 | GNUNET_SQ_result_spec_end |
480 | }; | 485 | }; |
@@ -514,6 +519,7 @@ get_records_and_call_iterator (struct Plugin *plugin, | |||
514 | if (NULL != iter) | 519 | if (NULL != iter) |
515 | iter (iter_cls, | 520 | iter (iter_cls, |
516 | seq, | 521 | seq, |
522 | editor_hint, | ||
517 | &zk, | 523 | &zk, |
518 | label, | 524 | label, |
519 | record_count, | 525 | record_count, |
@@ -540,16 +546,18 @@ get_records_and_call_iterator (struct Plugin *plugin, | |||
540 | * @return #GNUNET_OK on success, #GNUNET_NO for no results, else #GNUNET_SYSERR | 546 | * @return #GNUNET_OK on success, #GNUNET_NO for no results, else #GNUNET_SYSERR |
541 | */ | 547 | */ |
542 | static enum GNUNET_GenericReturnValue | 548 | static enum GNUNET_GenericReturnValue |
543 | namestore_sqlite_lookup_records (void *cls, | 549 | lookup_records (void *cls, |
544 | const struct | 550 | const struct |
545 | GNUNET_CRYPTO_PrivateKey *zone, | 551 | GNUNET_CRYPTO_PrivateKey *zone, |
546 | const char *label, | 552 | const char *label, |
547 | GNUNET_NAMESTORE_RecordIterator iter, | 553 | GNUNET_NAMESTORE_RecordIterator iter, |
548 | void *iter_cls) | 554 | void *iter_cls, |
555 | const char *editor_hint) | ||
549 | { | 556 | { |
550 | struct Plugin *plugin = cls; | 557 | struct Plugin *plugin = cls; |
551 | GNUNET_assert (GNUNET_OK == database_prepare (plugin)); | 558 | GNUNET_assert (GNUNET_OK == database_prepare (plugin)); |
552 | struct GNUNET_SQ_QueryParam params[] = { | 559 | struct GNUNET_SQ_QueryParam params[] = { |
560 | GNUNET_SQ_query_param_string (editor_hint), | ||
553 | GNUNET_SQ_query_param_auto_from_type (zone), | 561 | GNUNET_SQ_query_param_auto_from_type (zone), |
554 | GNUNET_SQ_query_param_string (label), | 562 | GNUNET_SQ_query_param_string (label), |
555 | GNUNET_SQ_query_param_end | 563 | GNUNET_SQ_query_param_end |
@@ -580,6 +588,51 @@ namestore_sqlite_lookup_records (void *cls, | |||
580 | 588 | ||
581 | 589 | ||
582 | /** | 590 | /** |
591 | * Lookup records in the datastore for which we are the authority. | ||
592 | * | ||
593 | * @param cls closure (internal context for the plugin) | ||
594 | * @param zone private key of the zone | ||
595 | * @param label name of the record in the zone | ||
596 | * @param iter function to call with the result | ||
597 | * @param iter_cls closure for @a iter | ||
598 | * @return #GNUNET_OK on success, #GNUNET_NO for no results, else #GNUNET_SYSERR | ||
599 | */ | ||
600 | static enum GNUNET_GenericReturnValue | ||
601 | namestore_sqlite_lookup_records (void *cls, | ||
602 | const struct | ||
603 | GNUNET_CRYPTO_PrivateKey *zone, | ||
604 | const char *label, | ||
605 | GNUNET_NAMESTORE_RecordIterator iter, | ||
606 | void *iter_cls) | ||
607 | { | ||
608 | return lookup_records (cls, zone, label, iter, iter_cls, ""); | ||
609 | } | ||
610 | |||
611 | |||
612 | /** | ||
613 | * Lookup records in the datastore for which we are the authority. | ||
614 | * | ||
615 | * @param cls closure (internal context for the plugin) | ||
616 | * @param zone private key of the zone | ||
617 | * @param label name of the record in the zone | ||
618 | * @param iter function to call with the result | ||
619 | * @param iter_cls closure for @a iter | ||
620 | * @return #GNUNET_OK on success, #GNUNET_NO for no results, else #GNUNET_SYSERR | ||
621 | */ | ||
622 | static enum GNUNET_GenericReturnValue | ||
623 | namestore_sqlite_edit_records (void *cls, | ||
624 | const char *editor_hint, | ||
625 | const struct | ||
626 | GNUNET_CRYPTO_PrivateKey *zone, | ||
627 | const char *label, | ||
628 | GNUNET_NAMESTORE_RecordIterator iter, | ||
629 | void *iter_cls) | ||
630 | { | ||
631 | return lookup_records (cls, zone, label, iter, iter_cls, editor_hint); | ||
632 | } | ||
633 | |||
634 | |||
635 | /** | ||
583 | * Iterate over the results for a particular key and zone in the | 636 | * Iterate over the results for a particular key and zone in the |
584 | * datastore. Will return at most one result to the iterator. | 637 | * datastore. Will return at most one result to the iterator. |
585 | * | 638 | * |
@@ -698,92 +751,6 @@ namestore_sqlite_zone_to_name (void *cls, | |||
698 | } | 751 | } |
699 | 752 | ||
700 | 753 | ||
701 | /** | ||
702 | * Begin a transaction for a client. | ||
703 | * This locks the database. SQLite is unable to discern between different | ||
704 | * rows with a specific zone key but the API looks like this anyway. | ||
705 | * https://www.sqlite.org/lang_transaction.html | ||
706 | * | ||
707 | * @param cls closure (internal context for the plugin) | ||
708 | * @param emsg error message set of return code is #GNUNET_SYSERR | ||
709 | * @return #GNUNET_YES on success, #GNUNET_SYSERR if transaction cannot be started. | ||
710 | */ | ||
711 | static enum GNUNET_GenericReturnValue | ||
712 | namestore_sqlite_transaction_begin (void *cls, | ||
713 | char **emsg) | ||
714 | { | ||
715 | struct Plugin *plugin = cls; | ||
716 | int rc; | ||
717 | char *sqlEmsg; | ||
718 | |||
719 | GNUNET_assert (GNUNET_OK == database_prepare (plugin)); | ||
720 | rc = sqlite3_exec (plugin->dbh, "BEGIN IMMEDIATE TRANSACTION;", | ||
721 | NULL, NULL, &sqlEmsg); | ||
722 | if (SQLITE_OK != rc) | ||
723 | { | ||
724 | *emsg = GNUNET_strdup (sqlEmsg); | ||
725 | sqlite3_free (sqlEmsg); | ||
726 | } | ||
727 | return (SQLITE_OK != rc) ? GNUNET_SYSERR : GNUNET_YES; | ||
728 | } | ||
729 | |||
730 | |||
731 | /** | ||
732 | * Commit a transaction for a client. | ||
733 | * This releases the lock on the database. | ||
734 | * | ||
735 | * @param cls closure (internal context for the plugin) | ||
736 | * @param emsg error message set of return code is #GNUNET_SYSERR | ||
737 | * @return #GNUNET_YES on success, #GNUNET_SYSERR if transaction cannot be started. | ||
738 | */ | ||
739 | static enum GNUNET_GenericReturnValue | ||
740 | namestore_sqlite_transaction_rollback (void *cls, | ||
741 | char **emsg) | ||
742 | { | ||
743 | struct Plugin *plugin = cls; | ||
744 | int rc; | ||
745 | char *sqlEmsg; | ||
746 | |||
747 | GNUNET_assert (GNUNET_OK == database_prepare (plugin)); | ||
748 | rc = sqlite3_exec (plugin->dbh, "ROLLBACK;", | ||
749 | NULL, NULL, &sqlEmsg); | ||
750 | if (SQLITE_OK != rc) | ||
751 | { | ||
752 | *emsg = GNUNET_strdup (sqlEmsg); | ||
753 | sqlite3_free (sqlEmsg); | ||
754 | } | ||
755 | return (SQLITE_OK != rc) ? GNUNET_SYSERR : GNUNET_YES; | ||
756 | } | ||
757 | |||
758 | |||
759 | /** | ||
760 | * Roll back a transaction for a client. | ||
761 | * This releases the lock on the database. | ||
762 | * | ||
763 | * @param cls closure (internal context for the plugin) | ||
764 | * @param emsg error message set of return code is #GNUNET_SYSERR | ||
765 | * @return #GNUNET_YES on success, #GNUNET_SYSERR if transaction cannot be started. | ||
766 | */ | ||
767 | static enum GNUNET_GenericReturnValue | ||
768 | namestore_sqlite_transaction_commit (void *cls, | ||
769 | char **emsg) | ||
770 | { | ||
771 | struct Plugin *plugin = cls; | ||
772 | int rc; | ||
773 | char *sqlEmsg; | ||
774 | |||
775 | GNUNET_assert (GNUNET_OK == database_prepare (plugin)); | ||
776 | rc = sqlite3_exec (plugin->dbh, "END TRANSACTION;", | ||
777 | NULL, NULL, &sqlEmsg); | ||
778 | if (SQLITE_OK != rc) | ||
779 | { | ||
780 | *emsg = GNUNET_strdup (sqlEmsg); | ||
781 | sqlite3_free (sqlEmsg); | ||
782 | } | ||
783 | return (SQLITE_OK != rc) ? GNUNET_SYSERR : GNUNET_YES; | ||
784 | } | ||
785 | |||
786 | |||
787 | static enum GNUNET_GenericReturnValue | 754 | static enum GNUNET_GenericReturnValue |
788 | namestore_sqlite_create_tables (void *cls) | 755 | namestore_sqlite_create_tables (void *cls) |
789 | { | 756 | { |
@@ -804,7 +771,8 @@ namestore_sqlite_create_tables (void *cls) | |||
804 | " rvalue INT8 NOT NULL," | 771 | " rvalue INT8 NOT NULL," |
805 | " record_count INT NOT NULL," | 772 | " record_count INT NOT NULL," |
806 | " record_data BLOB NOT NULL," | 773 | " record_data BLOB NOT NULL," |
807 | " label TEXT NOT NULL" | 774 | " label TEXT NOT NULL," |
775 | " editor_hint TEXT NOT NULL" | ||
808 | ")"), | 776 | ")"), |
809 | GNUNET_SQ_make_try_execute ("CREATE INDEX ir_pkey_reverse " | 777 | GNUNET_SQ_make_try_execute ("CREATE INDEX ir_pkey_reverse " |
810 | "ON ns098records (zone_private_key,pkey)"), | 778 | "ON ns098records (zone_private_key,pkey)"), |
@@ -940,17 +908,9 @@ libgnunet_plugin_namestore_sqlite_init (void *cls) | |||
940 | api->iterate_records = &namestore_sqlite_iterate_records; | 908 | api->iterate_records = &namestore_sqlite_iterate_records; |
941 | api->zone_to_name = &namestore_sqlite_zone_to_name; | 909 | api->zone_to_name = &namestore_sqlite_zone_to_name; |
942 | api->lookup_records = &namestore_sqlite_lookup_records; | 910 | api->lookup_records = &namestore_sqlite_lookup_records; |
943 | api->transaction_begin = &namestore_sqlite_transaction_begin; | ||
944 | api->transaction_commit = &namestore_sqlite_transaction_commit; | ||
945 | api->transaction_rollback = &namestore_sqlite_transaction_rollback; | ||
946 | api->create_tables = &namestore_sqlite_create_tables; | 911 | api->create_tables = &namestore_sqlite_create_tables; |
947 | api->drop_tables = &namestore_sqlite_drop_tables; | 912 | api->drop_tables = &namestore_sqlite_drop_tables; |
948 | /** | 913 | api->edit_records = &namestore_sqlite_edit_records; |
949 | * NOTE: Since SQlite does not support SELECT ... FOR UPDATE this is | ||
950 | * just an alias to lookup_records. The BEGIN IMMEDIATE mechanic currently | ||
951 | * implicitly ensures this API behaves as it should | ||
952 | */ | ||
953 | api->edit_records = &namestore_sqlite_lookup_records; | ||
954 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 914 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
955 | _ ("SQlite database running\n")); | 915 | _ ("SQlite database running\n")); |
956 | return api; | 916 | return api; |
diff --git a/src/plugin/namestore/test_plugin_namestore.c b/src/plugin/namestore/test_plugin_namestore.c index d90651255..db943ab9a 100644 --- a/src/plugin/namestore/test_plugin_namestore.c +++ b/src/plugin/namestore/test_plugin_namestore.c | |||
@@ -22,7 +22,6 @@ | |||
22 | * @brief Test for the namestore plugins | 22 | * @brief Test for the namestore plugins |
23 | * @author Christian Grothoff | 23 | * @author Christian Grothoff |
24 | */ | 24 | */ |
25 | #include "platform.h" | ||
26 | #include "gnunet_util_lib.h" | 25 | #include "gnunet_util_lib.h" |
27 | #include "gnunet_namestore_plugin.h" | 26 | #include "gnunet_namestore_plugin.h" |
28 | 27 | ||
@@ -97,6 +96,7 @@ load_plugin (const struct GNUNET_CONFIGURATION_Handle *cfg) | |||
97 | static void | 96 | static void |
98 | test_record (void *cls, | 97 | test_record (void *cls, |
99 | uint64_t seq, | 98 | uint64_t seq, |
99 | const char *editor_hint, | ||
100 | const struct GNUNET_CRYPTO_PrivateKey *private_key, | 100 | const struct GNUNET_CRYPTO_PrivateKey *private_key, |
101 | const char *label, | 101 | const char *label, |
102 | unsigned int rd_count, | 102 | unsigned int rd_count, |
diff --git a/src/service/core/meson.build b/src/service/core/meson.build index 6f7ff7404..19ffd0ddc 100644 --- a/src/service/core/meson.build +++ b/src/service/core/meson.build | |||
@@ -53,6 +53,7 @@ shared_module('gnunet_test_core_plugin_cmd_just_run', | |||
53 | dependencies: [libgnunetutil_dep, | 53 | dependencies: [libgnunetutil_dep, |
54 | libgnunettesting_dep, | 54 | libgnunettesting_dep, |
55 | libgnunetcoretesting_dep, | 55 | libgnunetcoretesting_dep, |
56 | libgnunettransporttesting2_dep, | ||
56 | libgnunettransportcore_dep, | 57 | libgnunettransportcore_dep, |
57 | libgnunettransportapplication_dep, | 58 | libgnunettransportapplication_dep, |
58 | libgnunettesting_dep, | 59 | libgnunettesting_dep, |
diff --git a/src/service/namestore/Makefile.am b/src/service/namestore/Makefile.am index d8f6a5318..01c6e9096 100644 --- a/src/service/namestore/Makefile.am +++ b/src/service/namestore/Makefile.am | |||
@@ -76,10 +76,10 @@ SQLITE_TESTS = \ | |||
76 | test_namestore_api_zone_iteration_stop_sqlite \ | 76 | test_namestore_api_zone_iteration_stop_sqlite \ |
77 | test_namestore_api_monitoring_existing_sqlite \ | 77 | test_namestore_api_monitoring_existing_sqlite \ |
78 | test_namestore_api_zone_to_name_sqlite \ | 78 | test_namestore_api_zone_to_name_sqlite \ |
79 | test_namestore_api_edit_records_sqlite \ | ||
79 | perf_namestore_api_zone_iteration_sqlite \ | 80 | perf_namestore_api_zone_iteration_sqlite \ |
80 | perf_namestore_api_import_sqlite \ | 81 | perf_namestore_api_import_sqlite \ |
81 | perf_namestore_api_import_postgres \ | 82 | perf_namestore_api_import_postgres |
82 | test_namestore_api_tx_rollback_sqlite | ||
83 | endif | 83 | endif |
84 | 84 | ||
85 | 85 | ||
@@ -97,8 +97,7 @@ POSTGRES_TESTS = \ | |||
97 | test_namestore_api_zone_iteration_stop_postgres \ | 97 | test_namestore_api_zone_iteration_stop_postgres \ |
98 | test_namestore_api_monitoring_existing_postgres \ | 98 | test_namestore_api_monitoring_existing_postgres \ |
99 | test_namestore_api_zone_to_name_postgres \ | 99 | test_namestore_api_zone_to_name_postgres \ |
100 | perf_namestore_api_zone_iteration_postgres \ | 100 | perf_namestore_api_zone_iteration_postgres |
101 | test_namestore_api_tx_rollback_postgres | ||
102 | if HAVE_EXPERIMENTAL | 101 | if HAVE_EXPERIMENTAL |
103 | POSTGRES_TESTS += test_namestore_api_edit_records_postgres | 102 | POSTGRES_TESTS += test_namestore_api_edit_records_postgres |
104 | endif | 103 | endif |
@@ -261,34 +260,25 @@ test_namestore_api_monitoring_existing_postgres_LDADD = \ | |||
261 | $(top_builddir)/src/service/identity/libgnunetidentity.la \ | 260 | $(top_builddir)/src/service/identity/libgnunetidentity.la \ |
262 | $(top_builddir)/src/lib/util/libgnunetutil.la | 261 | $(top_builddir)/src/lib/util/libgnunetutil.la |
263 | 262 | ||
264 | test_namestore_api_tx_rollback_sqlite_SOURCES = \ | 263 | if HAVE_EXPERIMENTAL |
265 | test_namestore_api_tx_rollback.c | 264 | test_namestore_api_edit_records_postgres_SOURCES = \ |
266 | test_namestore_api_tx_rollback_sqlite_LDADD = \ | 265 | test_namestore_api_edit_records.c |
267 | $(top_builddir)/src/service/testing/libgnunettesting.la \ | 266 | test_namestore_api_edit_records_postgres_LDADD = \ |
268 | $(top_builddir)/src/service/identity/libgnunetidentity.la \ | ||
269 | $(top_builddir)/src/service/namestore/libgnunetnamestore.la \ | ||
270 | $(top_builddir)/src/lib/gnsrecord/libgnunetgnsrecord.la \ | ||
271 | $(top_builddir)/src/lib/util/libgnunetutil.la | ||
272 | |||
273 | test_namestore_api_tx_rollback_postgres_SOURCES = \ | ||
274 | test_namestore_api_tx_rollback.c | ||
275 | test_namestore_api_tx_rollback_postgres_LDADD = \ | ||
276 | $(top_builddir)/src/service/testing/libgnunettesting.la \ | 267 | $(top_builddir)/src/service/testing/libgnunettesting.la \ |
277 | $(top_builddir)/src/service/identity/libgnunetidentity.la \ | 268 | $(top_builddir)/src/service/identity/libgnunetidentity.la \ |
278 | $(top_builddir)/src/service/namestore/libgnunetnamestore.la \ | 269 | $(top_builddir)/src/service/namestore/libgnunetnamestore.la \ |
279 | $(top_builddir)/src/lib/gnsrecord/libgnunetgnsrecord.la \ | 270 | $(top_builddir)/src/lib/gnsrecord/libgnunetgnsrecord.la \ |
280 | $(top_builddir)/src/lib/util/libgnunetutil.la | 271 | $(top_builddir)/src/lib/util/libgnunetutil.la |
272 | endif | ||
281 | 273 | ||
282 | if HAVE_EXPERIMENTAL | 274 | test_namestore_api_edit_records_sqlite_SOURCES = \ |
283 | test_namestore_api_edit_records_postgres_SOURCES = \ | ||
284 | test_namestore_api_edit_records.c | 275 | test_namestore_api_edit_records.c |
285 | test_namestore_api_edit_records_postgres_LDADD = \ | 276 | test_namestore_api_edit_records_sqlite_LDADD = \ |
286 | $(top_builddir)/src/service/testing/libgnunettesting.la \ | 277 | $(top_builddir)/src/service/testing/libgnunettesting.la \ |
287 | $(top_builddir)/src/service/identity/libgnunetidentity.la \ | 278 | $(top_builddir)/src/service/identity/libgnunetidentity.la \ |
288 | $(top_builddir)/src/service/namestore/libgnunetnamestore.la \ | 279 | $(top_builddir)/src/service/namestore/libgnunetnamestore.la \ |
289 | $(top_builddir)/src/lib/gnsrecord/libgnunetgnsrecord.la \ | 280 | $(top_builddir)/src/lib/gnsrecord/libgnunetgnsrecord.la \ |
290 | $(top_builddir)/src/lib/util/libgnunetutil.la | 281 | $(top_builddir)/src/lib/util/libgnunetutil.la |
291 | endif | ||
292 | 282 | ||
293 | test_namestore_api_zone_iteration_sqlite_SOURCES = \ | 283 | test_namestore_api_zone_iteration_sqlite_SOURCES = \ |
294 | test_namestore_api_zone_iteration.c | 284 | test_namestore_api_zone_iteration.c |
diff --git a/src/service/namestore/gnunet-namestore-fcfsd.c b/src/service/namestore/gnunet-namestore-fcfsd.c index 4948ae441..03ded7fcb 100644 --- a/src/service/namestore/gnunet-namestore-fcfsd.c +++ b/src/service/namestore/gnunet-namestore-fcfsd.c | |||
@@ -533,13 +533,13 @@ register_do_cb (void *cls, | |||
533 | gd.expiration_time = record_exp.rel_value_us; | 533 | gd.expiration_time = record_exp.rel_value_us; |
534 | gd.flags = GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION; | 534 | gd.flags = GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION; |
535 | 535 | ||
536 | rd->searching = GNUNET_NAMESTORE_records_store (namestore, | 536 | rd->searching = GNUNET_NAMESTORE_record_set_store (namestore, |
537 | zone_key, | 537 | zone_key, |
538 | rd->register_name, | 538 | rd->register_name, |
539 | 1, | 539 | 1, |
540 | &gd, | 540 | &gd, |
541 | ®ister_done_cb, | 541 | ®ister_done_cb, |
542 | rd); | 542 | rd); |
543 | 543 | ||
544 | GNUNET_free (gdraw); | 544 | GNUNET_free (gdraw); |
545 | } | 545 | } |
@@ -839,7 +839,7 @@ create_response (void *cls, | |||
839 | } | 839 | } |
840 | 840 | ||
841 | if (GNUNET_OK != GNUNET_CRYPTO_public_key_from_string (rd->register_key, | 841 | if (GNUNET_OK != GNUNET_CRYPTO_public_key_from_string (rd->register_key, |
842 | &(rd->key))) | 842 | &(rd->key))) |
843 | { | 843 | { |
844 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 844 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
845 | _ ("Unable to parse key %s\n"), | 845 | _ ("Unable to parse key %s\n"), |
@@ -1066,7 +1066,7 @@ run_service (void *cls, | |||
1066 | &record_exp)) | 1066 | &record_exp)) |
1067 | { | 1067 | { |
1068 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 1068 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
1069 | _("No expiration specified for records.\n")); | 1069 | _ ("No expiration specified for records.\n")); |
1070 | GNUNET_SCHEDULER_shutdown (); | 1070 | GNUNET_SCHEDULER_shutdown (); |
1071 | return; | 1071 | return; |
1072 | } | 1072 | } |
diff --git a/src/service/namestore/gnunet-service-namestore.c b/src/service/namestore/gnunet-service-namestore.c index 26de295bf..230583936 100644 --- a/src/service/namestore/gnunet-service-namestore.c +++ b/src/service/namestore/gnunet-service-namestore.c | |||
@@ -24,17 +24,16 @@ | |||
24 | * @author Matthias Wachs | 24 | * @author Matthias Wachs |
25 | * @author Christian Grothoff | 25 | * @author Christian Grothoff |
26 | */ | 26 | */ |
27 | #include "platform.h" | 27 | #include "gnunet_error_codes.h" |
28 | #include "gnunet_gnsrecord_lib.h" | ||
29 | #include "gnunet_protocols.h" | ||
28 | #include "gnunet_util_lib.h" | 30 | #include "gnunet_util_lib.h" |
29 | #include "gnunet_gns_service.h" | ||
30 | #include "gnunet_namestore_service.h" | ||
31 | #include "gnunet_namestore_plugin.h" | 31 | #include "gnunet_namestore_plugin.h" |
32 | #include "gnunet_statistics_service.h" | 32 | #include "gnunet_statistics_service.h" |
33 | #include "gnunet_signatures.h" | ||
34 | #include "namestore.h" | 33 | #include "namestore.h" |
35 | 34 | ||
36 | #define LOG_STRERROR_FILE(kind, syscall, filename) \ | 35 | #define LOG_STRERROR_FILE(kind, syscall, filename) \ |
37 | GNUNET_log_from_strerror_file (kind, "util", syscall, filename) | 36 | GNUNET_log_from_strerror_file (kind, "util", syscall, filename) |
38 | 37 | ||
39 | /** | 38 | /** |
40 | * If a monitor takes more than 1 minute to process an event, print a warning. | 39 | * If a monitor takes more than 1 minute to process an event, print a warning. |
@@ -145,11 +144,6 @@ struct NamestoreClient | |||
145 | char *db_lib_name; | 144 | char *db_lib_name; |
146 | 145 | ||
147 | /** | 146 | /** |
148 | * GNUNET_YES if this nc has begun a transaction which is uncommited. | ||
149 | */ | ||
150 | int in_transaction; | ||
151 | |||
152 | /** | ||
153 | * Message queue for transmission to @e client | 147 | * Message queue for transmission to @e client |
154 | */ | 148 | */ |
155 | struct GNUNET_MQ_Handle *mq; | 149 | struct GNUNET_MQ_Handle *mq; |
@@ -256,7 +250,6 @@ struct ZoneMonitor | |||
256 | }; | 250 | }; |
257 | 251 | ||
258 | 252 | ||
259 | |||
260 | /** | 253 | /** |
261 | * Information for an ongoing #handle_record_store() operation. | 254 | * Information for an ongoing #handle_record_store() operation. |
262 | * Needed as we may wait for monitors to be ready for the notification. | 255 | * Needed as we may wait for monitors to be ready for the notification. |
@@ -294,12 +287,6 @@ struct StoreActivity | |||
294 | uint16_t rd_set_count; | 287 | uint16_t rd_set_count; |
295 | 288 | ||
296 | /** | 289 | /** |
297 | * Wheather or not this store action is already commited. | ||
298 | * The store activity will not be processed unless this field is GNUNET_YES | ||
299 | */ | ||
300 | int uncommited; | ||
301 | |||
302 | /** | ||
303 | * The zone private key | 290 | * The zone private key |
304 | */ | 291 | */ |
305 | struct GNUNET_CRYPTO_PrivateKey private_key; | 292 | struct GNUNET_CRYPTO_PrivateKey private_key; |
@@ -438,6 +425,7 @@ free_store_activity (struct StoreActivity *sa) | |||
438 | GNUNET_free (sa); | 425 | GNUNET_free (sa); |
439 | } | 426 | } |
440 | 427 | ||
428 | |||
441 | /** | 429 | /** |
442 | * Function called with the records for the #GNUNET_GNS_EMPTY_LABEL_AT | 430 | * Function called with the records for the #GNUNET_GNS_EMPTY_LABEL_AT |
443 | * label in the zone. Used to locate the #GNUNET_GNSRECORD_TYPE_NICK | 431 | * label in the zone. Used to locate the #GNUNET_GNSRECORD_TYPE_NICK |
@@ -453,6 +441,7 @@ free_store_activity (struct StoreActivity *sa) | |||
453 | static void | 441 | static void |
454 | lookup_nick_it (void *cls, | 442 | lookup_nick_it (void *cls, |
455 | uint64_t seq, | 443 | uint64_t seq, |
444 | const char *editor_hint, | ||
456 | const struct GNUNET_CRYPTO_PrivateKey *private_key, | 445 | const struct GNUNET_CRYPTO_PrivateKey *private_key, |
457 | const char *label, | 446 | const char *label, |
458 | unsigned int rd_count, | 447 | unsigned int rd_count, |
@@ -788,8 +777,8 @@ send_lookup_response_with_filter (struct NamestoreClient *nc, | |||
788 | zir_msg->rd_len = htons ((uint16_t) rd_ser_len); | 777 | zir_msg->rd_len = htons ((uint16_t) rd_ser_len); |
789 | zir_msg->key_len = htons (key_len); | 778 | zir_msg->key_len = htons (key_len); |
790 | GNUNET_CRYPTO_write_private_key_to_buffer (zone_key, | 779 | GNUNET_CRYPTO_write_private_key_to_buffer (zone_key, |
791 | &zir_msg[1], | 780 | &zir_msg[1], |
792 | key_len); | 781 | key_len); |
793 | zir_msg->expire = GNUNET_TIME_absolute_hton (block_exp); | 782 | zir_msg->expire = GNUNET_TIME_absolute_hton (block_exp); |
794 | name_tmp = (char *) &zir_msg[1] + key_len; | 783 | name_tmp = (char *) &zir_msg[1] + key_len; |
795 | GNUNET_memcpy (name_tmp, name, name_len); | 784 | GNUNET_memcpy (name_tmp, name, name_len); |
@@ -810,6 +799,7 @@ send_lookup_response_with_filter (struct NamestoreClient *nc, | |||
810 | return res_count; | 799 | return res_count; |
811 | } | 800 | } |
812 | 801 | ||
802 | |||
813 | /** | 803 | /** |
814 | * Send response to the store request to the client. | 804 | * Send response to the store request to the client. |
815 | * | 805 | * |
@@ -823,17 +813,17 @@ send_store_response (struct NamestoreClient *nc, | |||
823 | uint32_t rid) | 813 | uint32_t rid) |
824 | { | 814 | { |
825 | struct GNUNET_MQ_Envelope *env; | 815 | struct GNUNET_MQ_Envelope *env; |
826 | struct RecordStoreResponseMessage *rcr_msg; | 816 | struct NamestoreResponseMessage *rcr_msg; |
827 | 817 | ||
828 | GNUNET_assert (NULL != nc); | 818 | GNUNET_assert (NULL != nc); |
829 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 819 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
830 | "Sending RECORD_STORE_RESPONSE message\n"); | 820 | "Sending GENERIC_RESPONSE message\n"); |
831 | GNUNET_STATISTICS_update (statistics, | 821 | GNUNET_STATISTICS_update (statistics, |
832 | "Store requests completed", | 822 | "Store requests completed", |
833 | 1, | 823 | 1, |
834 | GNUNET_NO); | 824 | GNUNET_NO); |
835 | env = GNUNET_MQ_msg (rcr_msg, | 825 | env = GNUNET_MQ_msg (rcr_msg, |
836 | GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_STORE_RESPONSE); | 826 | GNUNET_MESSAGE_TYPE_NAMESTORE_GENERIC_RESPONSE); |
837 | rcr_msg->gns_header.r_id = htonl (rid); | 827 | rcr_msg->gns_header.r_id = htonl (rid); |
838 | rcr_msg->ec = htonl (ec); | 828 | rcr_msg->ec = htonl (ec); |
839 | GNUNET_MQ_send (nc->mq, env); | 829 | GNUNET_MQ_send (nc->mq, env); |
@@ -865,8 +855,6 @@ zone_iteration_done_client_continue (struct ZoneIteration *zi) | |||
865 | } | 855 | } |
866 | 856 | ||
867 | 857 | ||
868 | |||
869 | |||
870 | /** | 858 | /** |
871 | * Print a warning that one of our monitors is no longer reacting. | 859 | * Print a warning that one of our monitors is no longer reacting. |
872 | * | 860 | * |
@@ -904,17 +892,6 @@ continue_store_activity (struct StoreActivity *sa, | |||
904 | const char *buf; | 892 | const char *buf; |
905 | char *conv_name; | 893 | char *conv_name; |
906 | 894 | ||
907 | // If we are in a transaction, do not notify monitors or update | ||
908 | // cached. This will be done when we are commiting. | ||
909 | if (GNUNET_YES == sa->uncommited) | ||
910 | { | ||
911 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
912 | "Transaction not yet committed, delaying monitor and cache updates\n"); | ||
913 | send_store_response (sa->nc, GNUNET_EC_NONE, sa->rid); | ||
914 | if (GNUNET_YES == call_continue) | ||
915 | GNUNET_SERVICE_client_continue (sa->nc->client); | ||
916 | return GNUNET_OK; | ||
917 | } | ||
918 | buf = (const char *) &sa[1]; | 895 | buf = (const char *) &sa[1]; |
919 | for (int i = sa->rd_set_pos; i < sa->rd_set_count; i++) | 896 | for (int i = sa->rd_set_pos; i < sa->rd_set_count; i++) |
920 | { | 897 | { |
@@ -1004,39 +981,9 @@ client_disconnect_cb (void *cls, | |||
1004 | struct ZoneIteration *no; | 981 | struct ZoneIteration *no; |
1005 | struct StoreActivity *sa = sa_head; | 982 | struct StoreActivity *sa = sa_head; |
1006 | struct StoreActivity *sn; | 983 | struct StoreActivity *sn; |
1007 | char *emsg; | ||
1008 | 984 | ||
1009 | (void) cls; | 985 | (void) cls; |
1010 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Client %p disconnected\n", client); | 986 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Client %p disconnected\n", client); |
1011 | if (GNUNET_YES == nc->in_transaction) | ||
1012 | { | ||
1013 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
1014 | "Client in transaction, rolling back...\n"); | ||
1015 | if (GNUNET_SYSERR == nc->GSN_database->transaction_rollback ( | ||
1016 | nc->GSN_database->cls, | ||
1017 | &emsg)) | ||
1018 | { | ||
1019 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
1020 | "Unable to roll back: %s\n", emsg); | ||
1021 | GNUNET_free (emsg); | ||
1022 | } | ||
1023 | else | ||
1024 | { | ||
1025 | nc->in_transaction = GNUNET_NO; | ||
1026 | while (NULL != sa) | ||
1027 | { | ||
1028 | if ((nc != sa->nc) || | ||
1029 | (GNUNET_NO == sa->uncommited)) | ||
1030 | { | ||
1031 | sa = sa->next; | ||
1032 | continue; | ||
1033 | } | ||
1034 | sn = sa->next; | ||
1035 | free_store_activity (sa); | ||
1036 | sa = sn; | ||
1037 | } | ||
1038 | } | ||
1039 | } | ||
1040 | for (struct ZoneMonitor *zm = monitor_head; NULL != zm; zm = zm->next) | 987 | for (struct ZoneMonitor *zm = monitor_head; NULL != zm; zm = zm->next) |
1041 | { | 988 | { |
1042 | if (nc != zm->nc) | 989 | if (nc != zm->nc) |
@@ -1148,6 +1095,11 @@ struct RecordLookupContext | |||
1148 | const char *label; | 1095 | const char *label; |
1149 | 1096 | ||
1150 | /** | 1097 | /** |
1098 | * The editor hint for set | ||
1099 | */ | ||
1100 | const char *editor_hint; | ||
1101 | |||
1102 | /** | ||
1151 | * The record result. | 1103 | * The record result. |
1152 | */ | 1104 | */ |
1153 | char *res_rd; | 1105 | char *res_rd; |
@@ -1194,6 +1146,7 @@ struct RecordLookupContext | |||
1194 | static void | 1146 | static void |
1195 | lookup_it (void *cls, | 1147 | lookup_it (void *cls, |
1196 | uint64_t seq, | 1148 | uint64_t seq, |
1149 | const char *editor_hint, | ||
1197 | const struct GNUNET_CRYPTO_PrivateKey *private_key, | 1150 | const struct GNUNET_CRYPTO_PrivateKey *private_key, |
1198 | const char *label, | 1151 | const char *label, |
1199 | unsigned int rd_count_nf, | 1152 | unsigned int rd_count_nf, |
@@ -1210,7 +1163,7 @@ lookup_it (void *cls, | |||
1210 | if (0 != strcmp (label, rlc->label)) | 1163 | if (0 != strcmp (label, rlc->label)) |
1211 | return; | 1164 | return; |
1212 | rlc->found = GNUNET_YES; | 1165 | rlc->found = GNUNET_YES; |
1213 | 1166 | rlc->editor_hint = editor_hint; | |
1214 | if (GNUNET_OK != GNUNET_GNSRECORD_normalize_record_set (rlc->label, | 1167 | if (GNUNET_OK != GNUNET_GNSRECORD_normalize_record_set (rlc->label, |
1215 | rd_nf, | 1168 | rd_nf, |
1216 | rd_count_nf, | 1169 | rd_count_nf, |
@@ -1302,6 +1255,132 @@ lookup_it (void *cls, | |||
1302 | 1255 | ||
1303 | 1256 | ||
1304 | /** | 1257 | /** |
1258 | * Handles a #GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_SET_EDIT message | ||
1259 | * | ||
1260 | * @param cls client sending the message | ||
1261 | * @param er_msg message of type `struct EditRecordSetMessage` | ||
1262 | * @return #GNUNET_OK if @a er_msg is well-formed | ||
1263 | */ | ||
1264 | static int | ||
1265 | check_edit_record_set (void *cls, const struct EditRecordSetMessage *er_msg) | ||
1266 | { | ||
1267 | uint16_t name_len; | ||
1268 | uint16_t editor_hint_len; | ||
1269 | size_t src_size; | ||
1270 | size_t key_len; | ||
1271 | |||
1272 | (void) cls; | ||
1273 | name_len = ntohs (er_msg->label_len); | ||
1274 | editor_hint_len = ntohs (er_msg->editor_hint_len); | ||
1275 | key_len = ntohs (er_msg->key_len); | ||
1276 | src_size = ntohs (er_msg->gns_header.header.size); | ||
1277 | if (name_len + editor_hint_len + key_len != src_size - sizeof(struct | ||
1278 | LabelLookupMessage)) | ||
1279 | { | ||
1280 | GNUNET_break (0); | ||
1281 | return GNUNET_SYSERR; | ||
1282 | } | ||
1283 | return GNUNET_OK; | ||
1284 | } | ||
1285 | |||
1286 | |||
1287 | /** | ||
1288 | * Handles a #GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_LOOKUP message | ||
1289 | * | ||
1290 | * @param cls client sending the message | ||
1291 | * @param ll_msg message of type `struct LabelLookupMessage` | ||
1292 | */ | ||
1293 | static void | ||
1294 | handle_edit_record_set (void *cls, const struct EditRecordSetMessage *er_msg) | ||
1295 | { | ||
1296 | struct GNUNET_CRYPTO_PrivateKey zone; | ||
1297 | struct NamestoreClient *nc = cls; | ||
1298 | struct GNUNET_MQ_Envelope *env; | ||
1299 | struct EditRecordSetResponseMessage *rer_msg; | ||
1300 | struct RecordLookupContext rlc; | ||
1301 | const char *name_tmp; | ||
1302 | const char *editor_hint; | ||
1303 | char *conv_name; | ||
1304 | uint16_t name_len; | ||
1305 | uint16_t old_editor_hint_len; | ||
1306 | int res; | ||
1307 | size_t key_len; | ||
1308 | size_t kb_read; | ||
1309 | |||
1310 | key_len = ntohs (er_msg->key_len); | ||
1311 | name_len = ntohs (er_msg->label_len); | ||
1312 | if ((GNUNET_SYSERR == | ||
1313 | GNUNET_CRYPTO_read_private_key_from_buffer (&er_msg[1], | ||
1314 | key_len, | ||
1315 | &zone, | ||
1316 | &kb_read)) || | ||
1317 | (kb_read != key_len)) | ||
1318 | { | ||
1319 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
1320 | "Error reading private key\n"); | ||
1321 | GNUNET_SERVICE_client_drop (nc->client); | ||
1322 | return; | ||
1323 | } | ||
1324 | name_tmp = (const char *) &er_msg[1] + key_len; | ||
1325 | editor_hint = (const char *) name_tmp + name_len; | ||
1326 | GNUNET_SERVICE_client_continue (nc->client); | ||
1327 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1328 | "Received NAMESTORE_RECORD_SET_EDIT message for name `%s'\n", | ||
1329 | name_tmp); | ||
1330 | |||
1331 | conv_name = GNUNET_GNSRECORD_string_normalize (name_tmp); | ||
1332 | if (NULL == conv_name) | ||
1333 | { | ||
1334 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
1335 | "Error converting name `%s'\n", | ||
1336 | name_tmp); | ||
1337 | GNUNET_SERVICE_client_drop (nc->client); | ||
1338 | return; | ||
1339 | } | ||
1340 | name_len = strlen (conv_name) + 1; | ||
1341 | rlc.label = conv_name; | ||
1342 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1343 | "Looking up without filter\n"); | ||
1344 | rlc.filter = GNUNET_GNSRECORD_FILTER_NONE; | ||
1345 | rlc.found = GNUNET_NO; | ||
1346 | rlc.res_rd_count = 0; | ||
1347 | rlc.res_rd = NULL; | ||
1348 | rlc.rd_ser_len = 0; | ||
1349 | rlc.nick = get_nick_record (&zone); | ||
1350 | res = nc->GSN_database->edit_records (nc->GSN_database->cls, | ||
1351 | editor_hint, | ||
1352 | &zone, | ||
1353 | conv_name, | ||
1354 | &lookup_it, | ||
1355 | &rlc); | ||
1356 | |||
1357 | old_editor_hint_len = 0; | ||
1358 | if (NULL != rlc.editor_hint) | ||
1359 | old_editor_hint_len = strlen (rlc.editor_hint) + 1; | ||
1360 | env = | ||
1361 | GNUNET_MQ_msg_extra (rer_msg, | ||
1362 | rlc.rd_ser_len + old_editor_hint_len, | ||
1363 | GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_SET_EDIT_RESPONSE); | ||
1364 | rer_msg->editor_hint_len = htons (old_editor_hint_len); | ||
1365 | rer_msg->gns_header.r_id = er_msg->gns_header.r_id; | ||
1366 | rer_msg->rd_count = htons (rlc.res_rd_count); | ||
1367 | rer_msg->rd_len = htons (rlc.rd_ser_len); | ||
1368 | if (GNUNET_YES == rlc.found) | ||
1369 | rer_msg->ec = htons (GNUNET_EC_NONE); | ||
1370 | else if (GNUNET_SYSERR == res) | ||
1371 | rer_msg->ec = htons (GNUNET_EC_NAMESTORE_UNKNOWN); | ||
1372 | else | ||
1373 | rer_msg->ec = htons (GNUNET_EC_NAMESTORE_NO_RESULTS); | ||
1374 | GNUNET_memcpy (&rer_msg[1], rlc.editor_hint, old_editor_hint_len); | ||
1375 | GNUNET_memcpy ((char*) &rer_msg[1] + old_editor_hint_len, rlc.res_rd, | ||
1376 | rlc.rd_ser_len); | ||
1377 | GNUNET_MQ_send (nc->mq, env); | ||
1378 | GNUNET_free (rlc.res_rd); | ||
1379 | GNUNET_free (conv_name); | ||
1380 | } | ||
1381 | |||
1382 | |||
1383 | /** | ||
1305 | * Handles a #GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_LOOKUP message | 1384 | * Handles a #GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_LOOKUP message |
1306 | * | 1385 | * |
1307 | * @param cls client sending the message | 1386 | * @param cls client sending the message |
@@ -1353,9 +1432,9 @@ handle_record_lookup (void *cls, const struct LabelLookupMessage *ll_msg) | |||
1353 | key_len = ntohs (ll_msg->key_len); | 1432 | key_len = ntohs (ll_msg->key_len); |
1354 | if ((GNUNET_SYSERR == | 1433 | if ((GNUNET_SYSERR == |
1355 | GNUNET_CRYPTO_read_private_key_from_buffer (&ll_msg[1], | 1434 | GNUNET_CRYPTO_read_private_key_from_buffer (&ll_msg[1], |
1356 | key_len, | 1435 | key_len, |
1357 | &zone, | 1436 | &zone, |
1358 | &kb_read)) || | 1437 | &kb_read)) || |
1359 | (kb_read != key_len)) | 1438 | (kb_read != key_len)) |
1360 | { | 1439 | { |
1361 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1440 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
@@ -1388,19 +1467,11 @@ handle_record_lookup (void *cls, const struct LabelLookupMessage *ll_msg) | |||
1388 | rlc.res_rd = NULL; | 1467 | rlc.res_rd = NULL; |
1389 | rlc.rd_ser_len = 0; | 1468 | rlc.rd_ser_len = 0; |
1390 | rlc.nick = get_nick_record (&zone); | 1469 | rlc.nick = get_nick_record (&zone); |
1391 | if (GNUNET_YES != ntohs (ll_msg->is_edit_request)) | 1470 | res = nc->GSN_database->lookup_records (nc->GSN_database->cls, |
1392 | res = nc->GSN_database->lookup_records (nc->GSN_database->cls, | ||
1393 | &zone, | ||
1394 | conv_name, | ||
1395 | &lookup_it, | ||
1396 | &rlc); | ||
1397 | else | ||
1398 | res = nc->GSN_database->edit_records (nc->GSN_database->cls, | ||
1399 | &zone, | 1471 | &zone, |
1400 | conv_name, | 1472 | conv_name, |
1401 | &lookup_it, | 1473 | &lookup_it, |
1402 | &rlc); | 1474 | &rlc); |
1403 | |||
1404 | env = | 1475 | env = |
1405 | GNUNET_MQ_msg_extra (llr_msg, | 1476 | GNUNET_MQ_msg_extra (llr_msg, |
1406 | key_len + name_len + rlc.rd_ser_len, | 1477 | key_len + name_len + rlc.rd_ser_len, |
@@ -1427,7 +1498,6 @@ handle_record_lookup (void *cls, const struct LabelLookupMessage *ll_msg) | |||
1427 | } | 1498 | } |
1428 | 1499 | ||
1429 | 1500 | ||
1430 | |||
1431 | /** | 1501 | /** |
1432 | * Checks a #GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_STORE message | 1502 | * Checks a #GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_STORE message |
1433 | * | 1503 | * |
@@ -1458,6 +1528,7 @@ check_record_store (void *cls, const struct RecordStoreMessage *rp_msg) | |||
1458 | return GNUNET_OK; | 1528 | return GNUNET_OK; |
1459 | } | 1529 | } |
1460 | 1530 | ||
1531 | |||
1461 | struct LookupExistingRecordsContext | 1532 | struct LookupExistingRecordsContext |
1462 | { | 1533 | { |
1463 | 1534 | ||
@@ -1488,6 +1559,7 @@ struct LookupExistingRecordsContext | |||
1488 | static void | 1559 | static void |
1489 | get_existing_rd_exp (void *cls, | 1560 | get_existing_rd_exp (void *cls, |
1490 | uint64_t seq, | 1561 | uint64_t seq, |
1562 | const char *editor_hint, | ||
1491 | const struct | 1563 | const struct |
1492 | GNUNET_CRYPTO_PrivateKey *private_key, | 1564 | GNUNET_CRYPTO_PrivateKey *private_key, |
1493 | const char *label, | 1565 | const char *label, |
@@ -1521,6 +1593,7 @@ get_existing_rd_exp (void *cls, | |||
1521 | } | 1593 | } |
1522 | } | 1594 | } |
1523 | 1595 | ||
1596 | |||
1524 | static enum GNUNET_ErrorCode | 1597 | static enum GNUNET_ErrorCode |
1525 | store_record_set (struct NamestoreClient *nc, | 1598 | store_record_set (struct NamestoreClient *nc, |
1526 | const struct GNUNET_CRYPTO_PrivateKey *private_key, | 1599 | const struct GNUNET_CRYPTO_PrivateKey *private_key, |
@@ -1635,8 +1708,6 @@ store_record_set (struct NamestoreClient *nc, | |||
1635 | if ((0 == strcmp (GNUNET_GNS_EMPTY_LABEL_AT, conv_name)) && | 1708 | if ((0 == strcmp (GNUNET_GNS_EMPTY_LABEL_AT, conv_name)) && |
1636 | (GNUNET_GNSRECORD_TYPE_NICK == rd[i].record_type)) | 1709 | (GNUNET_GNSRECORD_TYPE_NICK == rd[i].record_type)) |
1637 | { | 1710 | { |
1638 | // FIXME: In case this is an uncommited transaction, | ||
1639 | // we should not do this here. Can we do this in the store activity? | ||
1640 | cache_nick (private_key, &rd[i]); | 1711 | cache_nick (private_key, &rd[i]); |
1641 | have_nick = GNUNET_YES; | 1712 | have_nick = GNUNET_YES; |
1642 | } | 1713 | } |
@@ -1681,9 +1752,6 @@ store_record_set (struct NamestoreClient *nc, | |||
1681 | if ((0 == strcmp (GNUNET_GNS_EMPTY_LABEL_AT, conv_name)) && | 1752 | if ((0 == strcmp (GNUNET_GNS_EMPTY_LABEL_AT, conv_name)) && |
1682 | (GNUNET_NO == have_nick)) | 1753 | (GNUNET_NO == have_nick)) |
1683 | { | 1754 | { |
1684 | /* remove nick record from cache, in case we have one there */ | ||
1685 | // FIXME: In case this is an uncommited transaction, | ||
1686 | // we should not do this here. Can we do this in the store activity? | ||
1687 | cache_nick (private_key, NULL); | 1755 | cache_nick (private_key, NULL); |
1688 | } | 1756 | } |
1689 | res = nc->GSN_database->store_records (nc->GSN_database->cls, | 1757 | res = nc->GSN_database->store_records (nc->GSN_database->cls, |
@@ -1718,6 +1786,7 @@ store_record_set (struct NamestoreClient *nc, | |||
1718 | return ec; | 1786 | return ec; |
1719 | } | 1787 | } |
1720 | 1788 | ||
1789 | |||
1721 | /** | 1790 | /** |
1722 | * Handles a #GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_STORE message | 1791 | * Handles a #GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_STORE message |
1723 | * | 1792 | * |
@@ -1748,9 +1817,9 @@ handle_record_store (void *cls, const struct RecordStoreMessage *rp_msg) | |||
1748 | rs_len = rp_msg_len - rs_off; | 1817 | rs_len = rp_msg_len - rs_off; |
1749 | if ((GNUNET_SYSERR == | 1818 | if ((GNUNET_SYSERR == |
1750 | GNUNET_CRYPTO_read_private_key_from_buffer (&rp_msg[1], | 1819 | GNUNET_CRYPTO_read_private_key_from_buffer (&rp_msg[1], |
1751 | key_len, | 1820 | key_len, |
1752 | &zone, | 1821 | &zone, |
1753 | &kb_read)) || | 1822 | &kb_read)) || |
1754 | (kb_read != key_len)) | 1823 | (kb_read != key_len)) |
1755 | { | 1824 | { |
1756 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1825 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
@@ -1786,130 +1855,9 @@ handle_record_store (void *cls, const struct RecordStoreMessage *rp_msg) | |||
1786 | sa->rd_set_pos = 0; | 1855 | sa->rd_set_pos = 0; |
1787 | sa->private_key = zone; | 1856 | sa->private_key = zone; |
1788 | sa->zm_pos = monitor_head; | 1857 | sa->zm_pos = monitor_head; |
1789 | sa->uncommited = nc->in_transaction; | ||
1790 | continue_store_activity (sa, GNUNET_YES); | 1858 | continue_store_activity (sa, GNUNET_YES); |
1791 | } | 1859 | } |
1792 | 1860 | ||
1793 | static void | ||
1794 | send_tx_response (int rid, enum GNUNET_ErrorCode ec, struct NamestoreClient *nc) | ||
1795 | { | ||
1796 | struct TxControlResultMessage *txr_msg; | ||
1797 | struct GNUNET_MQ_Envelope *env; | ||
1798 | |||
1799 | env = | ||
1800 | GNUNET_MQ_msg (txr_msg, GNUNET_MESSAGE_TYPE_NAMESTORE_TX_CONTROL_RESULT); | ||
1801 | txr_msg->gns_header.r_id = rid; | ||
1802 | txr_msg->ec = htonl (ec); | ||
1803 | GNUNET_MQ_send (nc->mq, env); | ||
1804 | } | ||
1805 | |||
1806 | /** | ||
1807 | * Handles a #GNUNET_MESSAGE_TYPE_NAMESTORE_TX_CONTROL message | ||
1808 | * | ||
1809 | * @param cls client sending the message | ||
1810 | * @param tx_msg message of type `struct TxControlMessage` | ||
1811 | */ | ||
1812 | static void | ||
1813 | handle_tx_control (void *cls, const struct TxControlMessage *tx_msg) | ||
1814 | { | ||
1815 | struct NamestoreClient *nc = cls; | ||
1816 | struct StoreActivity *sa = sa_head; | ||
1817 | struct StoreActivity *sn; | ||
1818 | enum GNUNET_GenericReturnValue ret; | ||
1819 | char *emsg = NULL; | ||
1820 | int blocked = GNUNET_NO; | ||
1821 | |||
1822 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received TX_CONTROL message\n"); | ||
1823 | |||
1824 | switch (ntohs (tx_msg->control)) | ||
1825 | { | ||
1826 | case GNUNET_NAMESTORE_TX_BEGIN: | ||
1827 | ret = nc->GSN_database->transaction_begin (nc->GSN_database->cls, | ||
1828 | &emsg); | ||
1829 | send_tx_response (tx_msg->gns_header.r_id, | ||
1830 | (GNUNET_SYSERR == ret) ? | ||
1831 | GNUNET_EC_NAMESTORE_BACKEND_FAILED : GNUNET_EC_NONE, nc); | ||
1832 | if (GNUNET_SYSERR == ret) | ||
1833 | { | ||
1834 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
1835 | "Databse backend error: `%s'", emsg); | ||
1836 | GNUNET_free (emsg); | ||
1837 | } | ||
1838 | GNUNET_SERVICE_client_continue (nc->client); | ||
1839 | nc->in_transaction = GNUNET_YES; | ||
1840 | break; | ||
1841 | case GNUNET_NAMESTORE_TX_COMMIT: | ||
1842 | ret = nc->GSN_database->transaction_commit (nc->GSN_database->cls, | ||
1843 | &emsg); | ||
1844 | send_tx_response (tx_msg->gns_header.r_id, | ||
1845 | (GNUNET_SYSERR == ret) ? | ||
1846 | GNUNET_EC_NAMESTORE_BACKEND_FAILED : GNUNET_EC_NONE, | ||
1847 | nc); | ||
1848 | if (GNUNET_SYSERR == ret) | ||
1849 | { | ||
1850 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
1851 | "Databse backend error: `%s'", emsg); | ||
1852 | GNUNET_free (emsg); | ||
1853 | } | ||
1854 | if (GNUNET_SYSERR != ret) | ||
1855 | { | ||
1856 | nc->in_transaction = GNUNET_NO; | ||
1857 | while (NULL != sa) | ||
1858 | { | ||
1859 | if ((nc != sa->nc) || | ||
1860 | (GNUNET_NO == sa->uncommited)) | ||
1861 | { | ||
1862 | sa = sa->next; | ||
1863 | continue; | ||
1864 | } | ||
1865 | sa->uncommited = GNUNET_NO; | ||
1866 | sn = sa->next; | ||
1867 | if (GNUNET_OK != continue_store_activity (sa, GNUNET_NO)) | ||
1868 | blocked = GNUNET_YES; | ||
1869 | sa = sn; | ||
1870 | } | ||
1871 | if (GNUNET_YES != blocked) | ||
1872 | GNUNET_SERVICE_client_continue (nc->client); | ||
1873 | } | ||
1874 | break; | ||
1875 | case GNUNET_NAMESTORE_TX_ROLLBACK: | ||
1876 | ret = nc->GSN_database->transaction_rollback (nc->GSN_database->cls, | ||
1877 | &emsg); | ||
1878 | send_tx_response (tx_msg->gns_header.r_id, | ||
1879 | (GNUNET_SYSERR == ret) ? | ||
1880 | GNUNET_EC_NAMESTORE_BACKEND_FAILED : GNUNET_EC_NONE, nc); | ||
1881 | GNUNET_SERVICE_client_continue (nc->client); | ||
1882 | if (GNUNET_SYSERR == ret) | ||
1883 | { | ||
1884 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
1885 | "Databse backend error: `%s'", emsg); | ||
1886 | GNUNET_free (emsg); | ||
1887 | } | ||
1888 | if (GNUNET_SYSERR != ret) | ||
1889 | { | ||
1890 | nc->in_transaction = GNUNET_NO; | ||
1891 | while (NULL != sa) | ||
1892 | { | ||
1893 | if ((nc != sa->nc) || | ||
1894 | (GNUNET_NO == sa->uncommited)) | ||
1895 | { | ||
1896 | sa = sa->next; | ||
1897 | continue; | ||
1898 | } | ||
1899 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1900 | "Discarding uncommited StoreActivity\n"); | ||
1901 | sn = sa->next; | ||
1902 | free_store_activity (sa); | ||
1903 | sa = sn; | ||
1904 | } | ||
1905 | } | ||
1906 | break; | ||
1907 | default: | ||
1908 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
1909 | "Unknown control type %u\n", ntohs (tx_msg->control)); | ||
1910 | GNUNET_break (0); | ||
1911 | } | ||
1912 | } | ||
1913 | 1861 | ||
1914 | /** | 1862 | /** |
1915 | * Context for record remove operations passed from #handle_zone_to_name to | 1863 | * Context for record remove operations passed from #handle_zone_to_name to |
@@ -1949,6 +1897,7 @@ struct ZoneToNameCtx | |||
1949 | static void | 1897 | static void |
1950 | handle_zone_to_name_it (void *cls, | 1898 | handle_zone_to_name_it (void *cls, |
1951 | uint64_t seq, | 1899 | uint64_t seq, |
1900 | const char *editor_hint, | ||
1952 | const struct GNUNET_CRYPTO_PrivateKey *zone_key, | 1901 | const struct GNUNET_CRYPTO_PrivateKey *zone_key, |
1953 | const char *name, | 1902 | const char *name, |
1954 | unsigned int rd_count, | 1903 | unsigned int rd_count, |
@@ -1998,8 +1947,8 @@ handle_zone_to_name_it (void *cls, | |||
1998 | ztnr_msg->name_len = htons (name_len); | 1947 | ztnr_msg->name_len = htons (name_len); |
1999 | ztnr_msg->key_len = htons (key_len); | 1948 | ztnr_msg->key_len = htons (key_len); |
2000 | GNUNET_CRYPTO_write_private_key_to_buffer (zone_key, | 1949 | GNUNET_CRYPTO_write_private_key_to_buffer (zone_key, |
2001 | &ztnr_msg[1], | 1950 | &ztnr_msg[1], |
2002 | key_len); | 1951 | key_len); |
2003 | name_tmp = (char *) &ztnr_msg[1] + key_len; | 1952 | name_tmp = (char *) &ztnr_msg[1] + key_len; |
2004 | GNUNET_memcpy (name_tmp, name, name_len); | 1953 | GNUNET_memcpy (name_tmp, name, name_len); |
2005 | rd_tmp = &name_tmp[name_len]; | 1954 | rd_tmp = &name_tmp[name_len]; |
@@ -2010,6 +1959,7 @@ handle_zone_to_name_it (void *cls, | |||
2010 | GNUNET_MQ_send (ztn_ctx->nc->mq, env); | 1959 | GNUNET_MQ_send (ztn_ctx->nc->mq, env); |
2011 | } | 1960 | } |
2012 | 1961 | ||
1962 | |||
2013 | static enum GNUNET_GenericReturnValue | 1963 | static enum GNUNET_GenericReturnValue |
2014 | check_zone_to_name (void *cls, | 1964 | check_zone_to_name (void *cls, |
2015 | const struct ZoneToNameMessage *zis_msg) | 1965 | const struct ZoneToNameMessage *zis_msg) |
@@ -2044,9 +1994,9 @@ handle_zone_to_name (void *cls, const struct ZoneToNameMessage *ztn_msg) | |||
2044 | key_len = ntohs (ztn_msg->key_len); | 1994 | key_len = ntohs (ztn_msg->key_len); |
2045 | if ((GNUNET_SYSERR == | 1995 | if ((GNUNET_SYSERR == |
2046 | GNUNET_CRYPTO_read_private_key_from_buffer (&ztn_msg[1], | 1996 | GNUNET_CRYPTO_read_private_key_from_buffer (&ztn_msg[1], |
2047 | key_len, | 1997 | key_len, |
2048 | &zone, | 1998 | &zone, |
2049 | &kb_read)) || | 1999 | &kb_read)) || |
2050 | (kb_read != key_len)) | 2000 | (kb_read != key_len)) |
2051 | { | 2001 | { |
2052 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2002 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -2058,10 +2008,10 @@ handle_zone_to_name (void *cls, const struct ZoneToNameMessage *ztn_msg) | |||
2058 | pkey_len = ntohs (ztn_msg->pkey_len); | 2008 | pkey_len = ntohs (ztn_msg->pkey_len); |
2059 | if ((GNUNET_SYSERR == | 2009 | if ((GNUNET_SYSERR == |
2060 | GNUNET_CRYPTO_read_public_key_from_buffer ((char*) &ztn_msg[1] | 2010 | GNUNET_CRYPTO_read_public_key_from_buffer ((char*) &ztn_msg[1] |
2061 | + key_len, | 2011 | + key_len, |
2062 | pkey_len, | 2012 | pkey_len, |
2063 | &value_zone, | 2013 | &value_zone, |
2064 | &kb_read)) || | 2014 | &kb_read)) || |
2065 | (kb_read != pkey_len)) | 2015 | (kb_read != pkey_len)) |
2066 | { | 2016 | { |
2067 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2017 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -2133,6 +2083,7 @@ struct ZoneIterationProcResult | |||
2133 | static void | 2083 | static void |
2134 | zone_iterate_proc (void *cls, | 2084 | zone_iterate_proc (void *cls, |
2135 | uint64_t seq, | 2085 | uint64_t seq, |
2086 | const char *editor_hint, | ||
2136 | const struct GNUNET_CRYPTO_PrivateKey *zone_key, | 2087 | const struct GNUNET_CRYPTO_PrivateKey *zone_key, |
2137 | const char *name, | 2088 | const char *name, |
2138 | unsigned int rd_count, | 2089 | unsigned int rd_count, |
@@ -2225,6 +2176,7 @@ run_zone_iteration_round (struct ZoneIteration *zi, uint64_t limit) | |||
2225 | zone_iteration_done_client_continue (zi); | 2176 | zone_iteration_done_client_continue (zi); |
2226 | } | 2177 | } |
2227 | 2178 | ||
2179 | |||
2228 | static enum GNUNET_GenericReturnValue | 2180 | static enum GNUNET_GenericReturnValue |
2229 | check_iteration_start (void *cls, | 2181 | check_iteration_start (void *cls, |
2230 | const struct ZoneIterationStartMessage *zis_msg) | 2182 | const struct ZoneIterationStartMessage *zis_msg) |
@@ -2268,9 +2220,9 @@ handle_iteration_start (void *cls, | |||
2268 | { | 2220 | { |
2269 | if ((GNUNET_SYSERR == | 2221 | if ((GNUNET_SYSERR == |
2270 | GNUNET_CRYPTO_read_private_key_from_buffer (&zis_msg[1], | 2222 | GNUNET_CRYPTO_read_private_key_from_buffer (&zis_msg[1], |
2271 | key_len, | 2223 | key_len, |
2272 | &zone, | 2224 | &zone, |
2273 | &kb_read)) || | 2225 | &kb_read)) || |
2274 | (kb_read != key_len)) | 2226 | (kb_read != key_len)) |
2275 | { | 2227 | { |
2276 | GNUNET_SERVICE_client_drop (nc->client); | 2228 | GNUNET_SERVICE_client_drop (nc->client); |
@@ -2443,6 +2395,7 @@ monitor_iteration_next (void *cls); | |||
2443 | static void | 2395 | static void |
2444 | monitor_iterate_cb (void *cls, | 2396 | monitor_iterate_cb (void *cls, |
2445 | uint64_t seq, | 2397 | uint64_t seq, |
2398 | const char *editor_hint, | ||
2446 | const struct GNUNET_CRYPTO_PrivateKey *zone_key, | 2399 | const struct GNUNET_CRYPTO_PrivateKey *zone_key, |
2447 | const char *name, | 2400 | const char *name, |
2448 | unsigned int rd_count, | 2401 | unsigned int rd_count, |
@@ -2476,6 +2429,7 @@ monitor_iterate_cb (void *cls, | |||
2476 | } | 2429 | } |
2477 | } | 2430 | } |
2478 | 2431 | ||
2432 | |||
2479 | static enum GNUNET_GenericReturnValue | 2433 | static enum GNUNET_GenericReturnValue |
2480 | check_monitor_start (void *cls, | 2434 | check_monitor_start (void *cls, |
2481 | const struct ZoneMonitorStartMessage *zis_msg) | 2435 | const struct ZoneMonitorStartMessage *zis_msg) |
@@ -2520,9 +2474,9 @@ handle_monitor_start (void *cls, const struct | |||
2520 | { | 2474 | { |
2521 | if ((GNUNET_SYSERR == | 2475 | if ((GNUNET_SYSERR == |
2522 | GNUNET_CRYPTO_read_private_key_from_buffer (&zis_msg[1], | 2476 | GNUNET_CRYPTO_read_private_key_from_buffer (&zis_msg[1], |
2523 | key_len, | 2477 | key_len, |
2524 | &zone, | 2478 | &zone, |
2525 | &kb_read)) || | 2479 | &kb_read)) || |
2526 | (kb_read != key_len)) | 2480 | (kb_read != key_len)) |
2527 | { | 2481 | { |
2528 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 2482 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
@@ -2594,6 +2548,7 @@ monitor_iteration_next (void *cls) | |||
2594 | } | 2548 | } |
2595 | } | 2549 | } |
2596 | 2550 | ||
2551 | |||
2597 | /** | 2552 | /** |
2598 | * Handles a #GNUNET_MESSAGE_TYPE_NAMESTORE_MONITOR_NEXT message | 2553 | * Handles a #GNUNET_MESSAGE_TYPE_NAMESTORE_MONITOR_NEXT message |
2599 | * | 2554 | * |
@@ -2652,6 +2607,7 @@ handle_monitor_next (void *cls, const struct ZoneMonitorNextMessage *nm) | |||
2652 | } | 2607 | } |
2653 | } | 2608 | } |
2654 | 2609 | ||
2610 | |||
2655 | /** | 2611 | /** |
2656 | * Process namestore requests. | 2612 | * Process namestore requests. |
2657 | * | 2613 | * |
@@ -2710,14 +2666,14 @@ GNUNET_SERVICE_MAIN ( | |||
2710 | &client_connect_cb, | 2666 | &client_connect_cb, |
2711 | &client_disconnect_cb, | 2667 | &client_disconnect_cb, |
2712 | NULL, | 2668 | NULL, |
2713 | GNUNET_MQ_hd_fixed_size (tx_control, | ||
2714 | GNUNET_MESSAGE_TYPE_NAMESTORE_TX_CONTROL, | ||
2715 | struct TxControlMessage, | ||
2716 | NULL), | ||
2717 | GNUNET_MQ_hd_var_size (record_store, | 2669 | GNUNET_MQ_hd_var_size (record_store, |
2718 | GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_STORE, | 2670 | GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_STORE, |
2719 | struct RecordStoreMessage, | 2671 | struct RecordStoreMessage, |
2720 | NULL), | 2672 | NULL), |
2673 | GNUNET_MQ_hd_var_size (edit_record_set, | ||
2674 | GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_SET_EDIT, | ||
2675 | struct EditRecordSetMessage, | ||
2676 | NULL), | ||
2721 | GNUNET_MQ_hd_var_size (record_lookup, | 2677 | GNUNET_MQ_hd_var_size (record_lookup, |
2722 | GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_LOOKUP, | 2678 | GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_LOOKUP, |
2723 | struct LabelLookupMessage, | 2679 | struct LabelLookupMessage, |
diff --git a/src/service/namestore/meson.build b/src/service/namestore/meson.build index d4fc9579a..090ed1520 100644 --- a/src/service/namestore/meson.build +++ b/src/service/namestore/meson.build | |||
@@ -72,12 +72,12 @@ namestoreapitestnames = [ | |||
72 | 'test_namestore_api_remove_not_existing_record', | 72 | 'test_namestore_api_remove_not_existing_record', |
73 | 'test_namestore_api_store', | 73 | 'test_namestore_api_store', |
74 | 'test_namestore_api_store_update', | 74 | 'test_namestore_api_store_update', |
75 | 'test_namestore_api_tx_rollback', | ||
76 | 'test_namestore_api_zone_iteration', | 75 | 'test_namestore_api_zone_iteration', |
77 | 'test_namestore_api_zone_iteration_nick', | 76 | 'test_namestore_api_zone_iteration_nick', |
78 | 'test_namestore_api_zone_iteration_specific_zone', | 77 | 'test_namestore_api_zone_iteration_specific_zone', |
79 | 'test_namestore_api_zone_iteration_stop', | 78 | 'test_namestore_api_zone_iteration_stop', |
80 | 'test_namestore_api_zone_to_name' | 79 | 'test_namestore_api_zone_to_name', |
80 | 'test_namestore_api_edit_records' | ||
81 | ] | 81 | ] |
82 | 82 | ||
83 | if get_option('experimental') | 83 | if get_option('experimental') |
diff --git a/src/service/namestore/namestore.h b/src/service/namestore/namestore.h index 35d54d317..2ace6a83e 100644 --- a/src/service/namestore/namestore.h +++ b/src/service/namestore/namestore.h | |||
@@ -110,10 +110,10 @@ struct RecordStoreMessage | |||
110 | /** | 110 | /** |
111 | * Response to a record storage request. | 111 | * Response to a record storage request. |
112 | */ | 112 | */ |
113 | struct RecordStoreResponseMessage | 113 | struct NamestoreResponseMessage |
114 | { | 114 | { |
115 | /** | 115 | /** |
116 | * Type will be #GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_STORE_RESPONSE | 116 | * Type will be #GNUNET_MESSAGE_TYPE_NAMESTORE_GENERIC_RESPONSE |
117 | */ | 117 | */ |
118 | struct GNUNET_NAMESTORE_Header gns_header; | 118 | struct GNUNET_NAMESTORE_Header gns_header; |
119 | 119 | ||
@@ -124,6 +124,42 @@ struct RecordStoreResponseMessage | |||
124 | 124 | ||
125 | }; | 125 | }; |
126 | 126 | ||
127 | /** | ||
128 | * Response to RecordSetEditMessage. | ||
129 | */ | ||
130 | struct EditRecordSetResponseMessage | ||
131 | { | ||
132 | /** | ||
133 | * Type will be #GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_SET_EDIT_RESPONSE | ||
134 | */ | ||
135 | struct GNUNET_NAMESTORE_Header gns_header; | ||
136 | |||
137 | /** | ||
138 | * Length of the editor hint | ||
139 | */ | ||
140 | uint16_t editor_hint_len GNUNET_PACKED; | ||
141 | |||
142 | /** | ||
143 | * Reserved | ||
144 | */ | ||
145 | uint16_t ec GNUNET_PACKED; | ||
146 | |||
147 | /** | ||
148 | * Length of serialized record data | ||
149 | */ | ||
150 | uint16_t rd_len GNUNET_PACKED; | ||
151 | |||
152 | /** | ||
153 | * Number of records contained | ||
154 | */ | ||
155 | uint16_t rd_count GNUNET_PACKED; | ||
156 | |||
157 | /** | ||
158 | * Followed by editor hint | ||
159 | * Followed by record set | ||
160 | */ | ||
161 | }; | ||
162 | |||
127 | 163 | ||
128 | /** | 164 | /** |
129 | * Lookup a label | 165 | * Lookup a label |
@@ -141,9 +177,9 @@ struct LabelLookupMessage | |||
141 | uint16_t label_len GNUNET_PACKED; | 177 | uint16_t label_len GNUNET_PACKED; |
142 | 178 | ||
143 | /** | 179 | /** |
144 | * GNUNET_YES if this lookup corresponds to an edit request | 180 | * Unused |
145 | */ | 181 | */ |
146 | uint16_t is_edit_request GNUNET_PACKED; | 182 | uint16_t unused GNUNET_PACKED; |
147 | 183 | ||
148 | /** | 184 | /** |
149 | * The record filter | 185 | * The record filter |
@@ -161,6 +197,82 @@ struct LabelLookupMessage | |||
161 | */ | 197 | */ |
162 | }; | 198 | }; |
163 | 199 | ||
200 | /** | ||
201 | * Edit a record set and set editor hint/advisory lock. | ||
202 | */ | ||
203 | struct EditRecordSetMessage | ||
204 | { | ||
205 | /** | ||
206 | * Type will be #GNUNET_MESSAGE_TYPE_NAMESTORE_EDIT_RECORD_SET | ||
207 | */ | ||
208 | struct GNUNET_NAMESTORE_Header gns_header; | ||
209 | |||
210 | /** | ||
211 | * Length of the name | ||
212 | */ | ||
213 | uint16_t label_len GNUNET_PACKED; | ||
214 | |||
215 | /** | ||
216 | * Unused | ||
217 | */ | ||
218 | uint16_t editor_hint_len GNUNET_PACKED; | ||
219 | |||
220 | /** | ||
221 | * Unused | ||
222 | */ | ||
223 | uint16_t reserved GNUNET_PACKED; | ||
224 | |||
225 | /** | ||
226 | * Length of the zone key | ||
227 | */ | ||
228 | uint16_t key_len GNUNET_PACKED; | ||
229 | |||
230 | /* followed by: | ||
231 | * the private zone key | ||
232 | * label with length label_len | ||
233 | * editor hint with length editor_hint_len | ||
234 | */ | ||
235 | }; | ||
236 | |||
237 | |||
238 | /** | ||
239 | * Edit a record set and set editor hint/advisory lock. | ||
240 | */ | ||
241 | struct EditRecordSetCancelMessage | ||
242 | { | ||
243 | /** | ||
244 | * Type will be #GNUNET_MESSAGE_TYPE_NAMESTORE_EDIT_RECORD_SET_CANCEL | ||
245 | */ | ||
246 | struct GNUNET_NAMESTORE_Header gns_header; | ||
247 | |||
248 | /** | ||
249 | * Length of the name | ||
250 | */ | ||
251 | uint16_t label_len GNUNET_PACKED; | ||
252 | |||
253 | /** | ||
254 | * Unused | ||
255 | */ | ||
256 | uint16_t editor_hint_len GNUNET_PACKED; | ||
257 | |||
258 | /** | ||
259 | * Unused | ||
260 | */ | ||
261 | uint16_t editor_hint_replacement_len GNUNET_PACKED; | ||
262 | |||
263 | /** | ||
264 | * Length of the zone key | ||
265 | */ | ||
266 | uint16_t key_len GNUNET_PACKED; | ||
267 | |||
268 | /* followed by: | ||
269 | * the private zone key | ||
270 | * label with length label_len | ||
271 | * editor hint with length editor_hint_len | ||
272 | * replacement editor hint with length editor_hint_replacement_len | ||
273 | */ | ||
274 | }; | ||
275 | |||
164 | 276 | ||
165 | /** | 277 | /** |
166 | * Lookup a label | 278 | * Lookup a label |
diff --git a/src/service/namestore/namestore_api.c b/src/service/namestore/namestore_api.c index 7a4438e30..435c1622d 100644 --- a/src/service/namestore/namestore_api.c +++ b/src/service/namestore/namestore_api.c | |||
@@ -26,13 +26,9 @@ | |||
26 | * @author Christian Grothoff | 26 | * @author Christian Grothoff |
27 | */ | 27 | */ |
28 | 28 | ||
29 | #include "platform.h" | 29 | #include "gnunet_protocols.h" |
30 | #include "gnunet_error_codes.h" | 30 | #include "gnunet_error_codes.h" |
31 | #include "gnunet_util_lib.h" | 31 | #include "gnunet_util_lib.h" |
32 | #include "gnunet_constants.h" | ||
33 | #include "gnunet_arm_service.h" | ||
34 | #include "gnunet_signatures.h" | ||
35 | #include "gnunet_gns_service.h" | ||
36 | #include "gnunet_namestore_service.h" | 32 | #include "gnunet_namestore_service.h" |
37 | #include "namestore.h" | 33 | #include "namestore.h" |
38 | 34 | ||
@@ -87,6 +83,11 @@ struct GNUNET_NAMESTORE_QueueEntry | |||
87 | GNUNET_NAMESTORE_RecordSetMonitor proc2; | 83 | GNUNET_NAMESTORE_RecordSetMonitor proc2; |
88 | 84 | ||
89 | /** | 85 | /** |
86 | * Function to call with the records we get back including optional editor hint. | ||
87 | */ | ||
88 | GNUNET_NAMESTORE_EditRecordSetBeginCallback edit_proc; | ||
89 | |||
90 | /** | ||
90 | * Closure for @e proc. | 91 | * Closure for @e proc. |
91 | */ | 92 | */ |
92 | void *proc_cls; | 93 | void *proc_cls; |
@@ -355,16 +356,17 @@ check_rd (size_t rd_len, const void *rd_buf, unsigned int rd_count) | |||
355 | return GNUNET_OK; | 356 | return GNUNET_OK; |
356 | } | 357 | } |
357 | 358 | ||
359 | |||
358 | /** | 360 | /** |
359 | * Handle an incoming message of type | 361 | * Handle an incoming message of type |
360 | * #GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_STORE_RESPONSE | 362 | * #GNUNET_MESSAGE_TYPE_NAMESTORE_GENERIC_RESPONSE |
361 | * | 363 | * |
362 | * @param cls | 364 | * @param cls |
363 | * @param msg the message we received | 365 | * @param msg the message we received |
364 | */ | 366 | */ |
365 | static void | 367 | static void |
366 | handle_record_store_response (void *cls, | 368 | handle_generic_response (void *cls, |
367 | const struct RecordStoreResponseMessage *msg) | 369 | const struct NamestoreResponseMessage *msg) |
368 | { | 370 | { |
369 | struct GNUNET_NAMESTORE_Handle *h = cls; | 371 | struct GNUNET_NAMESTORE_Handle *h = cls; |
370 | struct GNUNET_NAMESTORE_QueueEntry *qe; | 372 | struct GNUNET_NAMESTORE_QueueEntry *qe; |
@@ -469,9 +471,9 @@ handle_lookup_result (void *cls, const struct LabelLookupResponseMessage *msg) | |||
469 | key_len = ntohs (msg->key_len); | 471 | key_len = ntohs (msg->key_len); |
470 | GNUNET_assert (GNUNET_SYSERR != | 472 | GNUNET_assert (GNUNET_SYSERR != |
471 | GNUNET_CRYPTO_read_private_key_from_buffer (&msg[1], | 473 | GNUNET_CRYPTO_read_private_key_from_buffer (&msg[1], |
472 | key_len, | 474 | key_len, |
473 | &private_key, | 475 | &private_key, |
474 | &kbytes_read)); | 476 | &kbytes_read)); |
475 | GNUNET_assert (kbytes_read == key_len); | 477 | GNUNET_assert (kbytes_read == key_len); |
476 | name = (const char *) &msg[1] + key_len; | 478 | name = (const char *) &msg[1] + key_len; |
477 | if (GNUNET_NO == found) | 479 | if (GNUNET_NO == found) |
@@ -512,6 +514,93 @@ handle_lookup_result (void *cls, const struct LabelLookupResponseMessage *msg) | |||
512 | 514 | ||
513 | /** | 515 | /** |
514 | * Handle an incoming message of type | 516 | * Handle an incoming message of type |
517 | * #GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_SET_EDIT_RESPONSE | ||
518 | * | ||
519 | * @param cls | ||
520 | * @param msg the message we received | ||
521 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | ||
522 | */ | ||
523 | static int | ||
524 | check_edit_record_set_response (void *cls, const struct | ||
525 | EditRecordSetResponseMessage *msg) | ||
526 | { | ||
527 | const char *editor_hint; | ||
528 | size_t msg_len; | ||
529 | size_t editor_hint_len; | ||
530 | size_t rd_len; | ||
531 | |||
532 | (void) cls; | ||
533 | rd_len = ntohs (msg->rd_len); | ||
534 | msg_len = ntohs (msg->gns_header.header.size); | ||
535 | editor_hint_len = ntohs (msg->editor_hint_len); | ||
536 | if (msg_len != sizeof(struct EditRecordSetResponseMessage) + editor_hint_len | ||
537 | + rd_len) | ||
538 | { | ||
539 | GNUNET_break (0); | ||
540 | return GNUNET_SYSERR; | ||
541 | } | ||
542 | editor_hint = (const char *) &msg[1]; | ||
543 | if ((0 == editor_hint_len) || ('\0' != editor_hint[editor_hint_len - 1])) | ||
544 | { | ||
545 | GNUNET_break (0); | ||
546 | return GNUNET_SYSERR; | ||
547 | } | ||
548 | return check_rd (rd_len, &editor_hint[editor_hint_len], ntohs ( | ||
549 | msg->rd_count)); | ||
550 | } | ||
551 | |||
552 | |||
553 | /** | ||
554 | * Handle an incoming message of type | ||
555 | * #GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_SET_EDIT_RESPONSE | ||
556 | * | ||
557 | * @param cls | ||
558 | * @param msg the message we received | ||
559 | */ | ||
560 | static void | ||
561 | handle_edit_record_set_response (void *cls, const struct | ||
562 | EditRecordSetResponseMessage *msg) | ||
563 | { | ||
564 | struct GNUNET_NAMESTORE_Handle *h = cls; | ||
565 | struct GNUNET_NAMESTORE_QueueEntry *qe; | ||
566 | const char *editor_hint; | ||
567 | const char *rd_tmp; | ||
568 | size_t rd_len; | ||
569 | size_t editor_hint_len; | ||
570 | unsigned int rd_count; | ||
571 | |||
572 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Received EDIT_RECORD_SET_RESPONSE\n"); | ||
573 | rd_len = ntohs (msg->rd_len); | ||
574 | rd_count = ntohs (msg->rd_count); | ||
575 | editor_hint_len = ntohs (msg->editor_hint_len); | ||
576 | qe = find_qe (h, ntohl (msg->gns_header.r_id)); | ||
577 | if (NULL == qe) | ||
578 | return; /* rid not found */ | ||
579 | editor_hint = (const char *) &msg[1]; | ||
580 | rd_tmp = &editor_hint[editor_hint_len]; | ||
581 | { | ||
582 | struct GNUNET_GNSRECORD_Data rd[rd_count]; | ||
583 | |||
584 | GNUNET_assert ( | ||
585 | GNUNET_OK == | ||
586 | GNUNET_GNSRECORD_records_deserialize (rd_len, rd_tmp, rd_count, rd)); | ||
587 | if (0 == editor_hint_len) | ||
588 | editor_hint = NULL; | ||
589 | if (NULL != qe->edit_proc) | ||
590 | qe->edit_proc (qe->proc_cls, | ||
591 | ntohs (msg->ec), | ||
592 | rd_count, | ||
593 | (rd_count > 0) ? rd : NULL, | ||
594 | editor_hint); | ||
595 | free_qe (qe); | ||
596 | return; | ||
597 | } | ||
598 | GNUNET_assert (0); | ||
599 | } | ||
600 | |||
601 | |||
602 | /** | ||
603 | * Handle an incoming message of type | ||
515 | * #GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_RESULT | 604 | * #GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_RESULT |
516 | * | 605 | * |
517 | * @param cls | 606 | * @param cls |
@@ -593,9 +682,9 @@ handle_record_result (void *cls, const struct RecordResultMessage *msg) | |||
593 | name = (const char *) &msg[1] + key_len; | 682 | name = (const char *) &msg[1] + key_len; |
594 | GNUNET_assert (GNUNET_SYSERR != | 683 | GNUNET_assert (GNUNET_SYSERR != |
595 | GNUNET_CRYPTO_read_private_key_from_buffer (&msg[1], | 684 | GNUNET_CRYPTO_read_private_key_from_buffer (&msg[1], |
596 | key_len, | 685 | key_len, |
597 | &private_key, | 686 | &private_key, |
598 | &kbytes_read)); | 687 | &kbytes_read)); |
599 | GNUNET_assert (kbytes_read == key_len); | 688 | GNUNET_assert (kbytes_read == key_len); |
600 | rd_tmp = &name[name_len]; | 689 | rd_tmp = &name[name_len]; |
601 | { | 690 | { |
@@ -674,25 +763,6 @@ handle_record_result_end (void *cls, const struct GNUNET_NAMESTORE_Header *msg) | |||
674 | free_ze (ze); | 763 | free_ze (ze); |
675 | } | 764 | } |
676 | 765 | ||
677 | static void | ||
678 | handle_tx_control_result (void *cls, | ||
679 | const struct TxControlResultMessage *msg) | ||
680 | { | ||
681 | struct GNUNET_NAMESTORE_Handle *h = cls; | ||
682 | struct GNUNET_NAMESTORE_QueueEntry *qe; | ||
683 | enum GNUNET_ErrorCode res; | ||
684 | |||
685 | qe = find_qe (h, ntohl (msg->gns_header.r_id)); | ||
686 | res = ntohs (msg->ec); | ||
687 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
688 | "Received TX_CONTROL_RESULT with result %d\n", | ||
689 | res); | ||
690 | if (NULL == qe) | ||
691 | return; | ||
692 | if (NULL != qe->cont) | ||
693 | qe->cont (qe->cont_cls, res); | ||
694 | free_qe (qe); | ||
695 | } | ||
696 | 766 | ||
697 | /** | 767 | /** |
698 | * Handle an incoming message of type | 768 | * Handle an incoming message of type |
@@ -769,9 +839,9 @@ handle_zone_to_name_response (void *cls, | |||
769 | key_len = ntohs (msg->key_len); | 839 | key_len = ntohs (msg->key_len); |
770 | GNUNET_assert (GNUNET_SYSERR != | 840 | GNUNET_assert (GNUNET_SYSERR != |
771 | GNUNET_CRYPTO_read_private_key_from_buffer (&msg[1], | 841 | GNUNET_CRYPTO_read_private_key_from_buffer (&msg[1], |
772 | key_len, | 842 | key_len, |
773 | &zone, | 843 | &zone, |
774 | &kbytes_read)); | 844 | &kbytes_read)); |
775 | GNUNET_assert (kbytes_read == key_len); | 845 | GNUNET_assert (kbytes_read == key_len); |
776 | switch (res) | 846 | switch (res) |
777 | { | 847 | { |
@@ -849,9 +919,9 @@ static void | |||
849 | reconnect (struct GNUNET_NAMESTORE_Handle *h) | 919 | reconnect (struct GNUNET_NAMESTORE_Handle *h) |
850 | { | 920 | { |
851 | struct GNUNET_MQ_MessageHandler handlers[] = | 921 | struct GNUNET_MQ_MessageHandler handlers[] = |
852 | { GNUNET_MQ_hd_fixed_size (record_store_response, | 922 | { GNUNET_MQ_hd_fixed_size (generic_response, |
853 | GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_STORE_RESPONSE, | 923 | GNUNET_MESSAGE_TYPE_NAMESTORE_GENERIC_RESPONSE, |
854 | struct RecordStoreResponseMessage, | 924 | struct NamestoreResponseMessage, |
855 | h), | 925 | h), |
856 | GNUNET_MQ_hd_var_size (zone_to_name_response, | 926 | GNUNET_MQ_hd_var_size (zone_to_name_response, |
857 | GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME_RESPONSE, | 927 | GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME_RESPONSE, |
@@ -869,10 +939,10 @@ reconnect (struct GNUNET_NAMESTORE_Handle *h) | |||
869 | GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_LOOKUP_RESPONSE, | 939 | GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_LOOKUP_RESPONSE, |
870 | struct LabelLookupResponseMessage, | 940 | struct LabelLookupResponseMessage, |
871 | h), | 941 | h), |
872 | GNUNET_MQ_hd_fixed_size (tx_control_result, | 942 | GNUNET_MQ_hd_var_size (edit_record_set_response, |
873 | GNUNET_MESSAGE_TYPE_NAMESTORE_TX_CONTROL_RESULT, | 943 | GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_SET_EDIT_RESPONSE, |
874 | struct TxControlResultMessage, | 944 | struct EditRecordSetResponseMessage, |
875 | h), | 945 | h), |
876 | GNUNET_MQ_handler_end () }; | 946 | GNUNET_MQ_handler_end () }; |
877 | struct GNUNET_NAMESTORE_ZoneIterator *it; | 947 | struct GNUNET_NAMESTORE_ZoneIterator *it; |
878 | struct GNUNET_NAMESTORE_QueueEntry *qe; | 948 | struct GNUNET_NAMESTORE_QueueEntry *qe; |
@@ -1048,7 +1118,7 @@ warn_delay (void *cls) | |||
1048 | 1118 | ||
1049 | 1119 | ||
1050 | struct GNUNET_NAMESTORE_QueueEntry * | 1120 | struct GNUNET_NAMESTORE_QueueEntry * |
1051 | GNUNET_NAMESTORE_records_store ( | 1121 | GNUNET_NAMESTORE_record_set_store ( |
1052 | struct GNUNET_NAMESTORE_Handle *h, | 1122 | struct GNUNET_NAMESTORE_Handle *h, |
1053 | const struct GNUNET_CRYPTO_PrivateKey *pkey, | 1123 | const struct GNUNET_CRYPTO_PrivateKey *pkey, |
1054 | const char *label, | 1124 | const char *label, |
@@ -1062,12 +1132,13 @@ GNUNET_NAMESTORE_records_store ( | |||
1062 | ri.a_label = label; | 1132 | ri.a_label = label; |
1063 | ri.a_rd_count = rd_count; | 1133 | ri.a_rd_count = rd_count; |
1064 | ri.a_rd = (struct GNUNET_GNSRECORD_Data *) rd; | 1134 | ri.a_rd = (struct GNUNET_GNSRECORD_Data *) rd; |
1065 | return GNUNET_NAMESTORE_records_store2 (h, pkey, 1, &ri, &rds_sent, | 1135 | return GNUNET_NAMESTORE_records_store (h, pkey, 1, &ri, &rds_sent, |
1066 | cont, cont_cls); | 1136 | cont, cont_cls); |
1067 | } | 1137 | } |
1068 | 1138 | ||
1139 | |||
1069 | struct GNUNET_NAMESTORE_QueueEntry * | 1140 | struct GNUNET_NAMESTORE_QueueEntry * |
1070 | GNUNET_NAMESTORE_records_store2 ( | 1141 | GNUNET_NAMESTORE_records_store ( |
1071 | struct GNUNET_NAMESTORE_Handle *h, | 1142 | struct GNUNET_NAMESTORE_Handle *h, |
1072 | const struct GNUNET_CRYPTO_PrivateKey *pkey, | 1143 | const struct GNUNET_CRYPTO_PrivateKey *pkey, |
1073 | unsigned int rd_set_count, | 1144 | unsigned int rd_set_count, |
@@ -1147,8 +1218,8 @@ GNUNET_NAMESTORE_records_store2 ( | |||
1147 | msg->key_len = htons (key_len); | 1218 | msg->key_len = htons (key_len); |
1148 | msg->rd_set_count = htons ((uint16_t) (*rds_sent)); | 1219 | msg->rd_set_count = htons ((uint16_t) (*rds_sent)); |
1149 | GNUNET_CRYPTO_write_private_key_to_buffer (pkey, | 1220 | GNUNET_CRYPTO_write_private_key_to_buffer (pkey, |
1150 | &msg[1], | 1221 | &msg[1], |
1151 | key_len); | 1222 | key_len); |
1152 | rd_set = (struct RecordSet*) (((char*) &msg[1]) + key_len); | 1223 | rd_set = (struct RecordSet*) (((char*) &msg[1]) + key_len); |
1153 | for (int i = 0; i < *rds_sent; i++) | 1224 | for (int i = 0; i < *rds_sent; i++) |
1154 | { | 1225 | { |
@@ -1201,7 +1272,6 @@ records_lookup ( | |||
1201 | void *error_cb_cls, | 1272 | void *error_cb_cls, |
1202 | GNUNET_NAMESTORE_RecordMonitor rm, | 1273 | GNUNET_NAMESTORE_RecordMonitor rm, |
1203 | void *rm_cls, | 1274 | void *rm_cls, |
1204 | int is_edit_request, | ||
1205 | enum GNUNET_GNSRECORD_Filter filter) | 1275 | enum GNUNET_GNSRECORD_Filter filter) |
1206 | { | 1276 | { |
1207 | struct GNUNET_NAMESTORE_QueueEntry *qe; | 1277 | struct GNUNET_NAMESTORE_QueueEntry *qe; |
@@ -1231,11 +1301,10 @@ records_lookup ( | |||
1231 | GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_LOOKUP); | 1301 | GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_LOOKUP); |
1232 | msg->gns_header.r_id = htonl (qe->op_id); | 1302 | msg->gns_header.r_id = htonl (qe->op_id); |
1233 | GNUNET_CRYPTO_write_private_key_to_buffer (pkey, | 1303 | GNUNET_CRYPTO_write_private_key_to_buffer (pkey, |
1234 | &msg[1], | 1304 | &msg[1], |
1235 | key_len); | 1305 | key_len); |
1236 | 1306 | ||
1237 | msg->key_len = htons (key_len); | 1307 | msg->key_len = htons (key_len); |
1238 | msg->is_edit_request = htons (is_edit_request); | ||
1239 | msg->label_len = htons (label_len); | 1308 | msg->label_len = htons (label_len); |
1240 | msg->filter = htons (filter); | 1309 | msg->filter = htons (filter); |
1241 | GNUNET_memcpy (((char*) &msg[1]) + key_len, label, label_len); | 1310 | GNUNET_memcpy (((char*) &msg[1]) + key_len, label, label_len); |
@@ -1246,6 +1315,7 @@ records_lookup ( | |||
1246 | return qe; | 1315 | return qe; |
1247 | } | 1316 | } |
1248 | 1317 | ||
1318 | |||
1249 | struct GNUNET_NAMESTORE_QueueEntry * | 1319 | struct GNUNET_NAMESTORE_QueueEntry * |
1250 | GNUNET_NAMESTORE_records_lookup ( | 1320 | GNUNET_NAMESTORE_records_lookup ( |
1251 | struct GNUNET_NAMESTORE_Handle *h, | 1321 | struct GNUNET_NAMESTORE_Handle *h, |
@@ -1258,10 +1328,11 @@ GNUNET_NAMESTORE_records_lookup ( | |||
1258 | { | 1328 | { |
1259 | return records_lookup (h, pkey, label, | 1329 | return records_lookup (h, pkey, label, |
1260 | error_cb, error_cb_cls, | 1330 | error_cb, error_cb_cls, |
1261 | rm, rm_cls, GNUNET_NO, GNUNET_GNSRECORD_FILTER_NONE); | 1331 | rm, rm_cls, GNUNET_GNSRECORD_FILTER_NONE); |
1262 | 1332 | ||
1263 | } | 1333 | } |
1264 | 1334 | ||
1335 | |||
1265 | struct GNUNET_NAMESTORE_QueueEntry * | 1336 | struct GNUNET_NAMESTORE_QueueEntry * |
1266 | GNUNET_NAMESTORE_records_lookup2 ( | 1337 | GNUNET_NAMESTORE_records_lookup2 ( |
1267 | struct GNUNET_NAMESTORE_Handle *h, | 1338 | struct GNUNET_NAMESTORE_Handle *h, |
@@ -1275,27 +1346,12 @@ GNUNET_NAMESTORE_records_lookup2 ( | |||
1275 | { | 1346 | { |
1276 | return records_lookup (h, pkey, label, | 1347 | return records_lookup (h, pkey, label, |
1277 | error_cb, error_cb_cls, | 1348 | error_cb, error_cb_cls, |
1278 | rm, rm_cls, GNUNET_NO, filter); | 1349 | rm, rm_cls, filter); |
1279 | 1350 | ||
1280 | } | 1351 | } |
1281 | 1352 | ||
1282 | 1353 | ||
1283 | struct GNUNET_NAMESTORE_QueueEntry * | 1354 | struct GNUNET_NAMESTORE_QueueEntry * |
1284 | GNUNET_NAMESTORE_records_edit ( | ||
1285 | struct GNUNET_NAMESTORE_Handle *h, | ||
1286 | const struct GNUNET_CRYPTO_PrivateKey *pkey, | ||
1287 | const char *label, | ||
1288 | GNUNET_SCHEDULER_TaskCallback error_cb, | ||
1289 | void *error_cb_cls, | ||
1290 | GNUNET_NAMESTORE_RecordMonitor rm, | ||
1291 | void *rm_cls) | ||
1292 | { | ||
1293 | return records_lookup (h, pkey, label, | ||
1294 | error_cb, error_cb_cls, | ||
1295 | rm, rm_cls, GNUNET_YES, GNUNET_GNSRECORD_FILTER_NONE); | ||
1296 | } | ||
1297 | |||
1298 | struct GNUNET_NAMESTORE_QueueEntry * | ||
1299 | GNUNET_NAMESTORE_zone_to_name ( | 1355 | GNUNET_NAMESTORE_zone_to_name ( |
1300 | struct GNUNET_NAMESTORE_Handle *h, | 1356 | struct GNUNET_NAMESTORE_Handle *h, |
1301 | const struct GNUNET_CRYPTO_PrivateKey *zone, | 1357 | const struct GNUNET_CRYPTO_PrivateKey *zone, |
@@ -1331,8 +1387,8 @@ GNUNET_NAMESTORE_zone_to_name ( | |||
1331 | msg->pkey_len = htons (pkey_len); | 1387 | msg->pkey_len = htons (pkey_len); |
1332 | GNUNET_CRYPTO_write_private_key_to_buffer (zone, &msg[1], key_len); | 1388 | GNUNET_CRYPTO_write_private_key_to_buffer (zone, &msg[1], key_len); |
1333 | GNUNET_CRYPTO_write_public_key_to_buffer (value_zone, | 1389 | GNUNET_CRYPTO_write_public_key_to_buffer (value_zone, |
1334 | (char*) &msg[1] + key_len, | 1390 | (char*) &msg[1] + key_len, |
1335 | pkey_len); | 1391 | pkey_len); |
1336 | if (NULL == h->mq) | 1392 | if (NULL == h->mq) |
1337 | qe->env = env; | 1393 | qe->env = env; |
1338 | else | 1394 | else |
@@ -1389,6 +1445,7 @@ GNUNET_NAMESTORE_zone_iteration_start ( | |||
1389 | return it; | 1445 | return it; |
1390 | } | 1446 | } |
1391 | 1447 | ||
1448 | |||
1392 | struct GNUNET_NAMESTORE_ZoneIterator * | 1449 | struct GNUNET_NAMESTORE_ZoneIterator * |
1393 | GNUNET_NAMESTORE_zone_iteration_start2 ( | 1450 | GNUNET_NAMESTORE_zone_iteration_start2 ( |
1394 | struct GNUNET_NAMESTORE_Handle *h, | 1451 | struct GNUNET_NAMESTORE_Handle *h, |
@@ -1494,69 +1551,123 @@ GNUNET_NAMESTORE_cancel (struct GNUNET_NAMESTORE_QueueEntry *qe) | |||
1494 | free_qe (qe); | 1551 | free_qe (qe); |
1495 | } | 1552 | } |
1496 | 1553 | ||
1554 | |||
1497 | /** | 1555 | /** |
1498 | * New API draft. Experimental | 1556 | * New API draft. Experimental |
1499 | */ | 1557 | */ |
1500 | 1558 | ||
1501 | static struct GNUNET_NAMESTORE_QueueEntry * | 1559 | struct GNUNET_NAMESTORE_QueueEntry * |
1502 | send_transaction_control_msg (struct GNUNET_NAMESTORE_Handle *h, | 1560 | GNUNET_NAMESTORE_record_set_edit_begin (struct GNUNET_NAMESTORE_Handle *h, |
1503 | GNUNET_NAMESTORE_ContinuationWithStatus cont, | 1561 | const struct |
1504 | void *cont_cls, | 1562 | GNUNET_CRYPTO_PrivateKey *pkey, |
1505 | enum GNUNET_NAMESTORE_TxControl ctrl) | 1563 | const char *label, |
1564 | const char *editor_hint, | ||
1565 | GNUNET_NAMESTORE_EditRecordSetBeginCallback | ||
1566 | edit_cb, | ||
1567 | void *edit_cb_cls) | ||
1506 | { | 1568 | { |
1507 | struct GNUNET_NAMESTORE_QueueEntry *qe; | 1569 | struct GNUNET_NAMESTORE_QueueEntry *qe; |
1508 | struct GNUNET_MQ_Envelope *env; | 1570 | struct GNUNET_MQ_Envelope *env; |
1509 | struct TxControlMessage *msg; | 1571 | struct EditRecordSetMessage *msg; |
1510 | uint32_t rid; | 1572 | size_t label_len; |
1573 | size_t key_len; | ||
1574 | size_t editor_hint_len; | ||
1511 | 1575 | ||
1512 | rid = get_op_id (h); | 1576 | if (1 == (label_len = strlen (label) + 1)) |
1577 | { | ||
1578 | GNUNET_break (0); | ||
1579 | return NULL; | ||
1580 | } | ||
1581 | GNUNET_assert (editor_hint != NULL); | ||
1582 | editor_hint_len = strlen (editor_hint) + 1; | ||
1513 | qe = GNUNET_new (struct GNUNET_NAMESTORE_QueueEntry); | 1583 | qe = GNUNET_new (struct GNUNET_NAMESTORE_QueueEntry); |
1514 | qe->h = h; | 1584 | qe->h = h; |
1515 | qe->cont = cont; | 1585 | qe->edit_proc = edit_cb; |
1516 | qe->cont_cls = cont_cls; | 1586 | qe->proc_cls = edit_cb_cls; |
1517 | qe->op_id = rid; | 1587 | qe->op_id = get_op_id (h); |
1518 | GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, qe); | 1588 | GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, qe); |
1519 | 1589 | ||
1520 | env = GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_NAMESTORE_TX_CONTROL); | 1590 | key_len = GNUNET_CRYPTO_private_key_get_length (pkey); |
1521 | msg->gns_header.r_id = htonl (rid); | 1591 | env = GNUNET_MQ_msg_extra (msg, |
1522 | msg->control = htons (ctrl); | 1592 | label_len + key_len + editor_hint_len, |
1593 | GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_SET_EDIT); | ||
1594 | msg->gns_header.r_id = htonl (qe->op_id); | ||
1595 | GNUNET_CRYPTO_write_private_key_to_buffer (pkey, | ||
1596 | &msg[1], | ||
1597 | key_len); | ||
1598 | |||
1599 | msg->key_len = htons (key_len); | ||
1600 | msg->label_len = htons (label_len); | ||
1601 | msg->editor_hint_len = htons (editor_hint_len); | ||
1602 | GNUNET_memcpy (((char*) &msg[1]) + key_len, label, label_len); | ||
1603 | GNUNET_memcpy (((char*) &msg[1]) + key_len + label_len, editor_hint, | ||
1604 | editor_hint_len); | ||
1523 | if (NULL == h->mq) | 1605 | if (NULL == h->mq) |
1524 | qe->env = env; | 1606 | qe->env = env; |
1525 | else | 1607 | else |
1526 | GNUNET_MQ_send (h->mq, env); | 1608 | GNUNET_MQ_send (h->mq, env); |
1527 | return qe; | 1609 | return qe; |
1528 | GNUNET_break (0); | ||
1529 | return NULL; | ||
1530 | } | 1610 | } |
1531 | 1611 | ||
1532 | struct GNUNET_NAMESTORE_QueueEntry * | ||
1533 | GNUNET_NAMESTORE_transaction_begin (struct GNUNET_NAMESTORE_Handle *h, | ||
1534 | GNUNET_NAMESTORE_ContinuationWithStatus cont, | ||
1535 | void *cont_cls) | ||
1536 | { | ||
1537 | return send_transaction_control_msg (h, cont, cont_cls, | ||
1538 | GNUNET_NAMESTORE_TX_BEGIN); | ||
1539 | } | ||
1540 | 1612 | ||
1541 | struct GNUNET_NAMESTORE_QueueEntry * | 1613 | struct GNUNET_NAMESTORE_QueueEntry * |
1542 | GNUNET_NAMESTORE_transaction_commit (struct GNUNET_NAMESTORE_Handle *h, | 1614 | GNUNET_NAMESTORE_record_set_edit_cancel (struct GNUNET_NAMESTORE_Handle *h, |
1543 | GNUNET_NAMESTORE_ContinuationWithStatus | 1615 | const struct |
1544 | cont, | 1616 | GNUNET_CRYPTO_PrivateKey *pkey, |
1545 | void *cont_cls) | 1617 | const char *label, |
1618 | const char *editor_hint, | ||
1619 | const char *editor_hint_replacement, | ||
1620 | GNUNET_SCHEDULER_TaskCallback | ||
1621 | finished_cb, | ||
1622 | void *finished_cls) | ||
1546 | { | 1623 | { |
1547 | return send_transaction_control_msg (h, cont, cont_cls, | 1624 | struct GNUNET_NAMESTORE_QueueEntry *qe; |
1548 | GNUNET_NAMESTORE_TX_COMMIT); | 1625 | struct GNUNET_MQ_Envelope *env; |
1549 | } | 1626 | struct EditRecordSetCancelMessage *msg; |
1627 | size_t label_len; | ||
1628 | size_t key_len; | ||
1629 | size_t editor_hint_len; | ||
1630 | size_t editor_hint_replacement_len; | ||
1550 | 1631 | ||
1632 | if (1 == (label_len = strlen (label) + 1)) | ||
1633 | { | ||
1634 | GNUNET_break (0); | ||
1635 | return NULL; | ||
1636 | } | ||
1637 | GNUNET_assert (editor_hint != NULL); | ||
1638 | editor_hint_len = strlen (editor_hint) + 1; | ||
1639 | GNUNET_assert (editor_hint != NULL); | ||
1640 | editor_hint_replacement_len = strlen (editor_hint_replacement) + 1; | ||
1641 | qe = GNUNET_new (struct GNUNET_NAMESTORE_QueueEntry); | ||
1642 | qe->h = h; | ||
1643 | qe->op_id = get_op_id (h); | ||
1644 | GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, qe); | ||
1551 | 1645 | ||
1552 | struct GNUNET_NAMESTORE_QueueEntry * | 1646 | key_len = GNUNET_CRYPTO_private_key_get_length (pkey); |
1553 | GNUNET_NAMESTORE_transaction_rollback (struct GNUNET_NAMESTORE_Handle *h, | 1647 | env = GNUNET_MQ_msg_extra (msg, |
1554 | GNUNET_NAMESTORE_ContinuationWithStatus | 1648 | label_len + key_len + editor_hint_len |
1555 | cont, | 1649 | + editor_hint_replacement_len, |
1556 | void *cont_cls) | 1650 | GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_SET_EDIT_CANCEL); |
1557 | { | 1651 | msg->gns_header.r_id = htonl (qe->op_id); |
1558 | return send_transaction_control_msg (h, cont, cont_cls, | 1652 | GNUNET_CRYPTO_write_private_key_to_buffer (pkey, |
1559 | GNUNET_NAMESTORE_TX_ROLLBACK); | 1653 | &msg[1], |
1654 | key_len); | ||
1655 | |||
1656 | msg->key_len = htons (key_len); | ||
1657 | msg->label_len = htons (label_len); | ||
1658 | msg->editor_hint_len = htons (editor_hint_len); | ||
1659 | msg->editor_hint_replacement_len = htons (editor_hint_replacement_len); | ||
1660 | GNUNET_memcpy (((char*) &msg[1]) + key_len, label, label_len); | ||
1661 | GNUNET_memcpy (((char*) &msg[1]) + key_len + label_len, editor_hint, | ||
1662 | editor_hint_len); | ||
1663 | GNUNET_memcpy (((char*) &msg[1]) + key_len + label_len + editor_hint_len, | ||
1664 | editor_hint_replacement, | ||
1665 | editor_hint_replacement_len); | ||
1666 | if (NULL == h->mq) | ||
1667 | qe->env = env; | ||
1668 | else | ||
1669 | GNUNET_MQ_send (h->mq, env); | ||
1670 | return qe; | ||
1560 | } | 1671 | } |
1561 | 1672 | ||
1562 | 1673 | ||
diff --git a/src/service/namestore/perf_namestore_api_import.c b/src/service/namestore/perf_namestore_api_import.c index bf8093f43..faa75b5ab 100644 --- a/src/service/namestore/perf_namestore_api_import.c +++ b/src/service/namestore/perf_namestore_api_import.c | |||
@@ -22,10 +22,8 @@ | |||
22 | * @brief testcase for namestore: Import a lot of records | 22 | * @brief testcase for namestore: Import a lot of records |
23 | * @author Martin Schanzenbach | 23 | * @author Martin Schanzenbach |
24 | */ | 24 | */ |
25 | #include "platform.h" | ||
26 | #include "gnunet_namestore_service.h" | 25 | #include "gnunet_namestore_service.h" |
27 | #include "gnunet_testing_lib.h" | 26 | #include "gnunet_testing_lib.h" |
28 | #include "../service/namestore/namestore.h" | ||
29 | 27 | ||
30 | #define TEST_RECORD_TYPE GNUNET_DNSPARSER_TYPE_TXT | 28 | #define TEST_RECORD_TYPE GNUNET_DNSPARSER_TYPE_TXT |
31 | 29 | ||
@@ -149,31 +147,6 @@ static void | |||
149 | publish_records_single (void *cls); | 147 | publish_records_single (void *cls); |
150 | 148 | ||
151 | static void | 149 | static void |
152 | commit_cont (void *cls, | ||
153 | enum GNUNET_ErrorCode ec) | ||
154 | { | ||
155 | struct GNUNET_TIME_Relative delay; | ||
156 | |||
157 | (void) cls; | ||
158 | qe = NULL; | ||
159 | if (GNUNET_EC_NONE != ec) | ||
160 | { | ||
161 | GNUNET_break (0); | ||
162 | GNUNET_SCHEDULER_shutdown (); | ||
163 | return; | ||
164 | } | ||
165 | single_put_pos++; | ||
166 | delay = GNUNET_TIME_absolute_get_duration (start); | ||
167 | fprintf (stdout, | ||
168 | "BULK-TX: Publishing %u records took %s\n", | ||
169 | TEST_RECORD_COUNT, | ||
170 | GNUNET_STRINGS_relative_time_to_string (delay, | ||
171 | GNUNET_YES)); | ||
172 | res = 0; | ||
173 | GNUNET_SCHEDULER_shutdown (); | ||
174 | } | ||
175 | |||
176 | static void | ||
177 | publish_records_bulk_tx (void *cls); | 150 | publish_records_bulk_tx (void *cls); |
178 | 151 | ||
179 | 152 | ||
@@ -181,6 +154,7 @@ static void | |||
181 | put_cont_bulk_tx (void *cls, | 154 | put_cont_bulk_tx (void *cls, |
182 | enum GNUNET_ErrorCode ec) | 155 | enum GNUNET_ErrorCode ec) |
183 | { | 156 | { |
157 | struct GNUNET_TIME_Relative delay; | ||
184 | qe = NULL; | 158 | qe = NULL; |
185 | if (GNUNET_EC_NONE != ec) | 159 | if (GNUNET_EC_NONE != ec) |
186 | { | 160 | { |
@@ -190,7 +164,15 @@ put_cont_bulk_tx (void *cls, | |||
190 | } | 164 | } |
191 | if (bulk_count == TEST_RECORD_COUNT) | 165 | if (bulk_count == TEST_RECORD_COUNT) |
192 | { | 166 | { |
193 | qe = GNUNET_NAMESTORE_transaction_commit (nsh, commit_cont, NULL); | 167 | single_put_pos++; |
168 | delay = GNUNET_TIME_absolute_get_duration (start); | ||
169 | fprintf (stdout, | ||
170 | "BULK-TX: Publishing %u records took %s\n", | ||
171 | TEST_RECORD_COUNT, | ||
172 | GNUNET_STRINGS_relative_time_to_string (delay, | ||
173 | GNUNET_YES)); | ||
174 | res = 0; | ||
175 | GNUNET_SCHEDULER_shutdown (); | ||
194 | return; | 176 | return; |
195 | } | 177 | } |
196 | t = GNUNET_SCHEDULER_add_now (&publish_records_bulk_tx, NULL); | 178 | t = GNUNET_SCHEDULER_add_now (&publish_records_bulk_tx, NULL); |
@@ -202,35 +184,19 @@ publish_records_bulk_tx (void *cls) | |||
202 | { | 184 | { |
203 | unsigned int sent_rds; | 185 | unsigned int sent_rds; |
204 | t = NULL; | 186 | t = NULL; |
205 | qe = GNUNET_NAMESTORE_records_store2 (nsh, | 187 | qe = GNUNET_NAMESTORE_records_store (nsh, |
206 | &privkey, | 188 | &privkey, |
207 | TEST_RECORD_COUNT - bulk_count, | 189 | TEST_RECORD_COUNT - bulk_count, |
208 | &ri[bulk_count], | 190 | &ri[bulk_count], |
209 | &sent_rds, | 191 | &sent_rds, |
210 | &put_cont_bulk_tx, | 192 | &put_cont_bulk_tx, |
211 | NULL); | 193 | NULL); |
212 | bulk_count += sent_rds; | 194 | bulk_count += sent_rds; |
213 | GNUNET_assert (sent_rds != 0); | 195 | GNUNET_assert (sent_rds != 0); |
214 | } | 196 | } |
215 | 197 | ||
216 | 198 | ||
217 | static void | 199 | static void |
218 | begin_cont (void *cls, | ||
219 | enum GNUNET_ErrorCode ec) | ||
220 | { | ||
221 | unsigned int sent_rds; | ||
222 | qe = GNUNET_NAMESTORE_records_store2 (nsh, | ||
223 | &privkey, | ||
224 | TEST_RECORD_COUNT - bulk_count, | ||
225 | &ri[bulk_count], | ||
226 | &sent_rds, | ||
227 | &put_cont_bulk_tx, | ||
228 | NULL); | ||
229 | bulk_count += sent_rds; | ||
230 | GNUNET_assert (sent_rds != 0); | ||
231 | } | ||
232 | |||
233 | static void | ||
234 | publish_records_bulk (void *cls); | 200 | publish_records_bulk (void *cls); |
235 | 201 | ||
236 | static void | 202 | static void |
@@ -238,6 +204,7 @@ put_cont_bulk (void *cls, | |||
238 | enum GNUNET_ErrorCode ec) | 204 | enum GNUNET_ErrorCode ec) |
239 | { | 205 | { |
240 | struct GNUNET_TIME_Relative delay; | 206 | struct GNUNET_TIME_Relative delay; |
207 | unsigned int sent_rds; | ||
241 | 208 | ||
242 | (void) cls; | 209 | (void) cls; |
243 | qe = NULL; | 210 | qe = NULL; |
@@ -258,7 +225,15 @@ put_cont_bulk (void *cls, | |||
258 | GNUNET_YES)); | 225 | GNUNET_YES)); |
259 | start = GNUNET_TIME_absolute_get (); | 226 | start = GNUNET_TIME_absolute_get (); |
260 | bulk_count = 0; | 227 | bulk_count = 0; |
261 | qe = GNUNET_NAMESTORE_transaction_begin (nsh, begin_cont, NULL); | 228 | qe = GNUNET_NAMESTORE_records_store (nsh, |
229 | &privkey, | ||
230 | TEST_RECORD_COUNT - bulk_count, | ||
231 | &ri[bulk_count], | ||
232 | &sent_rds, | ||
233 | &put_cont_bulk_tx, | ||
234 | NULL); | ||
235 | bulk_count += sent_rds; | ||
236 | GNUNET_assert (sent_rds != 0); | ||
262 | return; | 237 | return; |
263 | } | 238 | } |
264 | (void) cls; | 239 | (void) cls; |
@@ -272,19 +247,20 @@ put_cont_bulk (void *cls, | |||
272 | t = GNUNET_SCHEDULER_add_now (&publish_records_bulk, NULL); | 247 | t = GNUNET_SCHEDULER_add_now (&publish_records_bulk, NULL); |
273 | } | 248 | } |
274 | 249 | ||
250 | |||
275 | static void | 251 | static void |
276 | publish_records_bulk (void *cls) | 252 | publish_records_bulk (void *cls) |
277 | { | 253 | { |
278 | static unsigned int sent_rds = 0; | 254 | static unsigned int sent_rds = 0; |
279 | (void) cls; | 255 | (void) cls; |
280 | t = NULL; | 256 | t = NULL; |
281 | qe = GNUNET_NAMESTORE_records_store2 (nsh, | 257 | qe = GNUNET_NAMESTORE_records_store (nsh, |
282 | &privkey, | 258 | &privkey, |
283 | TEST_RECORD_COUNT - bulk_count, | 259 | TEST_RECORD_COUNT - bulk_count, |
284 | &ri[bulk_count], | 260 | &ri[bulk_count], |
285 | &sent_rds, | 261 | &sent_rds, |
286 | &put_cont_bulk, | 262 | &put_cont_bulk, |
287 | NULL); | 263 | NULL); |
288 | bulk_count += sent_rds; | 264 | bulk_count += sent_rds; |
289 | GNUNET_assert (sent_rds != 0); | 265 | GNUNET_assert (sent_rds != 0); |
290 | } | 266 | } |
@@ -338,13 +314,13 @@ publish_records_single (void *cls) | |||
338 | GNUNET_YES)); | 314 | GNUNET_YES)); |
339 | GNUNET_SCHEDULER_add_now (&publish_records_bulk, NULL); | 315 | GNUNET_SCHEDULER_add_now (&publish_records_bulk, NULL); |
340 | } | 316 | } |
341 | qe = GNUNET_NAMESTORE_records_store (nsh, | 317 | qe = GNUNET_NAMESTORE_record_set_store (nsh, |
342 | &privkey, | 318 | &privkey, |
343 | ri[single_put_pos].a_label, | 319 | ri[single_put_pos].a_label, |
344 | ri[single_put_pos].a_rd_count, | 320 | ri[single_put_pos].a_rd_count, |
345 | ri[single_put_pos].a_rd, | 321 | ri[single_put_pos].a_rd, |
346 | &put_cont_single, | 322 | &put_cont_single, |
347 | NULL); | 323 | NULL); |
348 | } | 324 | } |
349 | 325 | ||
350 | 326 | ||
diff --git a/src/service/namestore/perf_namestore_api_zone_iteration.c b/src/service/namestore/perf_namestore_api_zone_iteration.c index 1b669fdac..cc59ff4c7 100644 --- a/src/service/namestore/perf_namestore_api_zone_iteration.c +++ b/src/service/namestore/perf_namestore_api_zone_iteration.c | |||
@@ -22,10 +22,8 @@ | |||
22 | * @brief testcase for zone iteration functionality: iterate all zones | 22 | * @brief testcase for zone iteration functionality: iterate all zones |
23 | * @author Christian Grothoff | 23 | * @author Christian Grothoff |
24 | */ | 24 | */ |
25 | #include "platform.h" | ||
26 | #include "gnunet_namestore_service.h" | 25 | #include "gnunet_namestore_service.h" |
27 | #include "gnunet_testing_lib.h" | 26 | #include "gnunet_testing_lib.h" |
28 | #include "../service/namestore/namestore.h" | ||
29 | 27 | ||
30 | #define TEST_RECORD_TYPE GNUNET_DNSPARSER_TYPE_TXT | 28 | #define TEST_RECORD_TYPE GNUNET_DNSPARSER_TYPE_TXT |
31 | 29 | ||
@@ -316,12 +314,12 @@ publish_record (void *cls) | |||
316 | GNUNET_asprintf (&label, | 314 | GNUNET_asprintf (&label, |
317 | "l%u", | 315 | "l%u", |
318 | off); | 316 | off); |
319 | qe = GNUNET_NAMESTORE_records_store (nsh, | 317 | qe = GNUNET_NAMESTORE_record_set_store (nsh, |
320 | &privkey, | 318 | &privkey, |
321 | label, | 319 | label, |
322 | 1, rd, | 320 | 1, rd, |
323 | &put_cont, | 321 | &put_cont, |
324 | NULL); | 322 | NULL); |
325 | GNUNET_free (label); | 323 | GNUNET_free (label); |
326 | GNUNET_free (rd); | 324 | GNUNET_free (rd); |
327 | } | 325 | } |
diff --git a/src/service/namestore/test_namestore_api_edit_records.c b/src/service/namestore/test_namestore_api_edit_records.c index 94b4f4fc1..9dce13e33 100644 --- a/src/service/namestore/test_namestore_api_edit_records.c +++ b/src/service/namestore/test_namestore_api_edit_records.c | |||
@@ -21,7 +21,6 @@ | |||
21 | * @file namestore/test_namestore_api_edit_records.c | 21 | * @file namestore/test_namestore_api_edit_records.c |
22 | * @brief testcase for namestore_api.c: Multiple clients work with record set. | 22 | * @brief testcase for namestore_api.c: Multiple clients work with record set. |
23 | */ | 23 | */ |
24 | #include "platform.h" | ||
25 | #include "gnunet_namestore_service.h" | 24 | #include "gnunet_namestore_service.h" |
26 | #include "gnunet_testing_lib.h" | 25 | #include "gnunet_testing_lib.h" |
27 | 26 | ||
@@ -50,8 +49,6 @@ static int removed; | |||
50 | 49 | ||
51 | static struct GNUNET_NAMESTORE_QueueEntry *nsqe; | 50 | static struct GNUNET_NAMESTORE_QueueEntry *nsqe; |
52 | 51 | ||
53 | static int nonce = 0; | ||
54 | |||
55 | static void | 52 | static void |
56 | cleanup () | 53 | cleanup () |
57 | { | 54 | { |
@@ -60,6 +57,11 @@ cleanup () | |||
60 | GNUNET_NAMESTORE_disconnect (nsh); | 57 | GNUNET_NAMESTORE_disconnect (nsh); |
61 | nsh = NULL; | 58 | nsh = NULL; |
62 | } | 59 | } |
60 | if (NULL != nsh2) | ||
61 | { | ||
62 | GNUNET_NAMESTORE_disconnect (nsh2); | ||
63 | nsh2 = NULL; | ||
64 | } | ||
63 | GNUNET_SCHEDULER_shutdown (); | 65 | GNUNET_SCHEDULER_shutdown (); |
64 | } | 66 | } |
65 | 67 | ||
@@ -85,195 +87,50 @@ endbadly (void *cls) | |||
85 | static void | 87 | static void |
86 | end (void *cls) | 88 | end (void *cls) |
87 | { | 89 | { |
88 | cleanup (); | ||
89 | res = 0; | ||
90 | } | ||
91 | |||
92 | static void | ||
93 | lookup_it (void *cls, | ||
94 | const struct GNUNET_CRYPTO_PrivateKey *zone, | ||
95 | const char *label, | ||
96 | unsigned int rd_count, | ||
97 | const struct GNUNET_GNSRECORD_Data *rd) | ||
98 | { | ||
99 | GNUNET_assert (0 == rd_count); | ||
100 | GNUNET_SCHEDULER_add_now (&end, NULL); | ||
101 | } | ||
102 | |||
103 | static void | ||
104 | fail_cb (void *cls) | ||
105 | { | ||
106 | if (endbadly_task != NULL) | 90 | if (endbadly_task != NULL) |
107 | GNUNET_SCHEDULER_cancel (endbadly_task); | 91 | GNUNET_SCHEDULER_cancel (endbadly_task); |
108 | endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly, NULL); | 92 | cleanup (); |
109 | return; | 93 | res = 0; |
110 | } | ||
111 | |||
112 | static void | ||
113 | remove_cont (void *cls, | ||
114 | enum GNUNET_ErrorCode ec) | ||
115 | { | ||
116 | nsqe = NULL; | ||
117 | if (GNUNET_EC_NONE != ec) | ||
118 | { | ||
119 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
120 | _ ("Unable to roll back: `%s'\n"), | ||
121 | GNUNET_ErrorCode_get_hint (ec)); | ||
122 | if (NULL != endbadly_task) | ||
123 | GNUNET_SCHEDULER_cancel (endbadly_task); | ||
124 | endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly, | ||
125 | NULL); | ||
126 | return; | ||
127 | } | ||
128 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
129 | "Rolled back, perform lookup\n"); | ||
130 | removed = GNUNET_YES; | ||
131 | if (NULL != endbadly_task) | ||
132 | GNUNET_SCHEDULER_cancel (endbadly_task); | ||
133 | GNUNET_SCHEDULER_add_now (&end, NULL); | ||
134 | } | ||
135 | |||
136 | static void | ||
137 | fail_cb_lock (void *cls); | ||
138 | |||
139 | static void | ||
140 | edit_cont_b (void *cls, | ||
141 | const struct GNUNET_CRYPTO_PrivateKey *zone, | ||
142 | const char *label, | ||
143 | unsigned int rd_count, | ||
144 | const struct GNUNET_GNSRECORD_Data *rd) | ||
145 | { | ||
146 | const char *name = cls; | ||
147 | /** | ||
148 | * We should probably never get here right at first. | ||
149 | * We may want to change the blocking of nsh2 so that we do get this | ||
150 | * eventually instead of the error callback above when locked. | ||
151 | */ | ||
152 | if (0 == nonce) | ||
153 | { | ||
154 | if (endbadly_task != NULL) | ||
155 | GNUNET_SCHEDULER_cancel (endbadly_task); | ||
156 | endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly, NULL); | ||
157 | return; | ||
158 | |||
159 | } | ||
160 | /* Abort transaction for B */ | ||
161 | nsqe = GNUNET_NAMESTORE_transaction_rollback (nsh2, remove_cont, | ||
162 | (void *) name); | ||
163 | } | ||
164 | |||
165 | |||
166 | static void | ||
167 | commit_cont_a (void *cls, | ||
168 | enum GNUNET_ErrorCode ec) | ||
169 | { | ||
170 | const char *name = cls; | ||
171 | |||
172 | GNUNET_assert (NULL != cls); | ||
173 | nsqe = NULL; | ||
174 | if (GNUNET_EC_NONE != ec) | ||
175 | { | ||
176 | GNUNET_break (0); | ||
177 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
178 | "Namestore could not store record: `%s'\n", | ||
179 | GNUNET_ErrorCode_get_hint (ec)); | ||
180 | if (endbadly_task != NULL) | ||
181 | GNUNET_SCHEDULER_cancel (endbadly_task); | ||
182 | endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly, NULL); | ||
183 | return; | ||
184 | } | ||
185 | |||
186 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
187 | "Name store added record for `%s': %s\n", | ||
188 | name, | ||
189 | (GNUNET_EC_NONE == ec) ? "SUCCESS" : "FAIL"); | ||
190 | /** | ||
191 | * Try again for B | ||
192 | */ | ||
193 | nsqe = GNUNET_NAMESTORE_records_edit (nsh2, | ||
194 | &privkey, | ||
195 | name, | ||
196 | &fail_cb_lock, | ||
197 | (void *) name, | ||
198 | &edit_cont_b, | ||
199 | (void *) name); | ||
200 | |||
201 | GNUNET_assert (NULL != nsqe); | ||
202 | } | ||
203 | |||
204 | static void | ||
205 | fail_cb_lock (void *cls) | ||
206 | { | ||
207 | const char *name = cls; | ||
208 | if (1 == nonce) | ||
209 | { | ||
210 | if (endbadly_task != NULL) | ||
211 | GNUNET_SCHEDULER_cancel (endbadly_task); | ||
212 | endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly, NULL); | ||
213 | return; | ||
214 | } | ||
215 | nonce = 1; | ||
216 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
217 | "Failed to aquire additional lock\n"); | ||
218 | /* Now, we stop the transaction for B */ | ||
219 | nsqe = GNUNET_NAMESTORE_transaction_commit (nsh, commit_cont_a, | ||
220 | (void *) name); | ||
221 | } | 94 | } |
222 | 95 | ||
223 | 96 | ||
224 | static void | 97 | static void |
225 | begin_cont_b (void *cls, | 98 | begin_cont_b (void *cls, |
226 | enum GNUNET_ErrorCode ec) | 99 | enum GNUNET_ErrorCode ec, |
100 | unsigned int rd_count, | ||
101 | const struct | ||
102 | GNUNET_GNSRECORD_Data *rd, | ||
103 | const char *editor_hint) | ||
227 | { | 104 | { |
228 | const char *name = cls; | 105 | const char *name = cls; |
229 | 106 | ||
230 | GNUNET_assert (GNUNET_EC_NONE == ec); | 107 | GNUNET_assert (GNUNET_EC_NONE == ec); |
231 | /** Now, we expect this to "hang" let's see how this behaves in practice. */ | 108 | GNUNET_assert (0 != strcmp (editor_hint, "B")); |
232 | nsqe = GNUNET_NAMESTORE_records_edit (nsh2, | 109 | GNUNET_SCHEDULER_add_now (&end, NULL); |
233 | &privkey, | ||
234 | name, | ||
235 | &fail_cb_lock, | ||
236 | (void *) name, | ||
237 | &edit_cont_b, | ||
238 | (void *) name); | ||
239 | |||
240 | GNUNET_assert (NULL != nsqe); | ||
241 | } | ||
242 | |||
243 | |||
244 | static void | ||
245 | edit_cont (void *cls, | ||
246 | const struct GNUNET_CRYPTO_PrivateKey *zone, | ||
247 | const char *label, | ||
248 | unsigned int rd_count, | ||
249 | const struct GNUNET_GNSRECORD_Data *rd) | ||
250 | { | ||
251 | const char *name = cls; | ||
252 | |||
253 | GNUNET_assert (1 == rd_count); | ||
254 | /* Now, we start a transaction for B */ | ||
255 | nsqe = GNUNET_NAMESTORE_transaction_begin (nsh2, begin_cont_b, (void *) name); | ||
256 | } | 110 | } |
257 | 111 | ||
258 | 112 | ||
259 | static void | 113 | static void |
260 | begin_cont (void *cls, | 114 | begin_cont (void *cls, |
261 | enum GNUNET_ErrorCode ec) | 115 | enum GNUNET_ErrorCode ec, |
116 | unsigned int rd_count, | ||
117 | const struct | ||
118 | GNUNET_GNSRECORD_Data *rd, | ||
119 | const char *editor_hint) | ||
262 | { | 120 | { |
263 | const char *name = cls; | 121 | const char *name = cls; |
264 | 122 | ||
265 | GNUNET_assert (GNUNET_EC_NONE == ec); | 123 | GNUNET_assert (GNUNET_EC_NONE == ec); |
266 | nsqe = GNUNET_NAMESTORE_records_edit (nsh, | 124 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
267 | &privkey, | 125 | "records: `%u'\n", |
268 | name, | 126 | rd_count); |
269 | &fail_cb, | 127 | GNUNET_assert (1 == rd_count); |
270 | (void *) name, | 128 | nsqe = GNUNET_NAMESTORE_record_set_edit_begin (nsh2, &privkey, name, "B", |
271 | &edit_cont, | 129 | &begin_cont_b, name); |
272 | (void *) name); | ||
273 | |||
274 | GNUNET_assert (NULL != nsqe); | 130 | GNUNET_assert (NULL != nsqe); |
275 | } | 131 | } |
276 | 132 | ||
133 | |||
277 | static void | 134 | static void |
278 | preload_cont (void *cls, | 135 | preload_cont (void *cls, |
279 | enum GNUNET_ErrorCode ec) | 136 | enum GNUNET_ErrorCode ec) |
@@ -299,7 +156,8 @@ preload_cont (void *cls, | |||
299 | name, | 156 | name, |
300 | (GNUNET_EC_NONE == ec) ? "SUCCESS" : "FAIL"); | 157 | (GNUNET_EC_NONE == ec) ? "SUCCESS" : "FAIL"); |
301 | /* We start transaction for A */ | 158 | /* We start transaction for A */ |
302 | nsqe = GNUNET_NAMESTORE_transaction_begin (nsh, begin_cont, (void *) name); | 159 | nsqe = GNUNET_NAMESTORE_record_set_edit_begin (nsh, &privkey, name, "A", |
160 | &begin_cont, name); | ||
303 | 161 | ||
304 | } | 162 | } |
305 | 163 | ||
@@ -323,11 +181,12 @@ run (void *cls, | |||
323 | privkey.type = htonl (GNUNET_GNSRECORD_TYPE_PKEY); | 181 | privkey.type = htonl (GNUNET_GNSRECORD_TYPE_PKEY); |
324 | GNUNET_CRYPTO_ecdsa_key_create (&privkey.ecdsa_key); | 182 | GNUNET_CRYPTO_ecdsa_key_create (&privkey.ecdsa_key); |
325 | GNUNET_CRYPTO_key_get_public (&privkey, | 183 | GNUNET_CRYPTO_key_get_public (&privkey, |
326 | &pubkey); | 184 | &pubkey); |
327 | 185 | ||
328 | removed = GNUNET_NO; | 186 | removed = GNUNET_NO; |
329 | 187 | ||
330 | rd.expiration_time = GNUNET_TIME_absolute_get ().abs_value_us; | 188 | rd.expiration_time = GNUNET_TIME_absolute_get ().abs_value_us |
189 | + GNUNET_TIME_UNIT_DAYS.rel_value_us; | ||
331 | rd.record_type = TEST_RECORD_TYPE; | 190 | rd.record_type = TEST_RECORD_TYPE; |
332 | rd.data_size = TEST_RECORD_DATALEN; | 191 | rd.data_size = TEST_RECORD_DATALEN; |
333 | rd.data = GNUNET_malloc (TEST_RECORD_DATALEN); | 192 | rd.data = GNUNET_malloc (TEST_RECORD_DATALEN); |
@@ -335,36 +194,15 @@ run (void *cls, | |||
335 | memset ((char *) rd.data, | 194 | memset ((char *) rd.data, |
336 | 'a', | 195 | 'a', |
337 | TEST_RECORD_DATALEN); | 196 | TEST_RECORD_DATALEN); |
338 | nsqe = GNUNET_NAMESTORE_records_store (nsh, | 197 | nsqe = GNUNET_NAMESTORE_record_set_store (nsh, |
339 | &privkey, | 198 | &privkey, |
340 | name, | 199 | name, |
341 | 1, | 200 | 1, |
342 | &rd, | 201 | &rd, |
343 | &preload_cont, | 202 | &preload_cont, |
344 | (void *) name); | 203 | (void *) name); |
345 | GNUNET_assert (NULL != nsqe); | 204 | GNUNET_assert (NULL != nsqe); |
346 | GNUNET_free_nz ((void *) rd.data); | 205 | GNUNET_free_nz ((void *) rd.data); |
347 | |||
348 | /*nsqe = GNUNET_NAMESTORE_transaction_commit (nsh, commit_cont); | ||
349 | nsqe = GNUNET_NAMESTORE_transaction_rollback (nsh, rollback_cont); Must also happen on disconnect | ||
350 | nsqe = GNUNET_NAMESTORE_records_edit (nsh, | ||
351 | &privkey, | ||
352 | name, | ||
353 | 1, | ||
354 | &rd, | ||
355 | &edit_cont, | ||
356 | (void *) name); | ||
357 | nsqe = GNUNET_NAMESTORE_records_insert_bulk (nsh, | ||
358 | count, | ||
359 | &rd, | ||
360 | & | ||
361 | nsqe = GNUNET_NAMESTORE_records_store (nsh, | ||
362 | &privkey, | ||
363 | name, | ||
364 | 1, | ||
365 | &rd, | ||
366 | &put_cont, | ||
367 | (void *) name);*/ | ||
368 | GNUNET_assert (NULL != nsqe); | 206 | GNUNET_assert (NULL != nsqe); |
369 | } | 207 | } |
370 | 208 | ||
diff --git a/src/service/namestore/test_namestore_api_lookup_nick.c b/src/service/namestore/test_namestore_api_lookup_nick.c index 22734baab..8b4799363 100644 --- a/src/service/namestore/test_namestore_api_lookup_nick.c +++ b/src/service/namestore/test_namestore_api_lookup_nick.c | |||
@@ -23,7 +23,6 @@ | |||
23 | */ | 23 | */ |
24 | #include "platform.h" | 24 | #include "platform.h" |
25 | #include "gnunet_namestore_service.h" | 25 | #include "gnunet_namestore_service.h" |
26 | #include "gnunet_gns_service.h" | ||
27 | #include "gnunet_testing_lib.h" | 26 | #include "gnunet_testing_lib.h" |
28 | 27 | ||
29 | #define TEST_RECORD_TYPE GNUNET_DNSPARSER_TYPE_TXT | 28 | #define TEST_RECORD_TYPE GNUNET_DNSPARSER_TYPE_TXT |
@@ -269,11 +268,11 @@ nick_cont (void *cls, enum GNUNET_ErrorCode ec) | |||
269 | rd_orig.flags = GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION; | 268 | rd_orig.flags = GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION; |
270 | memset ((char *) rd_orig.data, 'a', TEST_RECORD_DATALEN); | 269 | memset ((char *) rd_orig.data, 'a', TEST_RECORD_DATALEN); |
271 | 270 | ||
272 | nsqe = GNUNET_NAMESTORE_records_store (nsh, &privkey, | 271 | nsqe = GNUNET_NAMESTORE_record_set_store (nsh, &privkey, |
273 | name, | 272 | name, |
274 | 1, | 273 | 1, |
275 | &rd_orig, | 274 | &rd_orig, |
276 | &put_cont, (void *) name); | 275 | &put_cont, (void *) name); |
277 | } | 276 | } |
278 | 277 | ||
279 | 278 | ||
@@ -290,7 +289,7 @@ run (void *cls, | |||
290 | privkey.type = htonl (GNUNET_GNSRECORD_TYPE_PKEY); | 289 | privkey.type = htonl (GNUNET_GNSRECORD_TYPE_PKEY); |
291 | GNUNET_CRYPTO_ecdsa_key_create (&privkey.ecdsa_key); | 290 | GNUNET_CRYPTO_ecdsa_key_create (&privkey.ecdsa_key); |
292 | GNUNET_CRYPTO_key_get_public (&privkey, | 291 | GNUNET_CRYPTO_key_get_public (&privkey, |
293 | &pubkey); | 292 | &pubkey); |
294 | 293 | ||
295 | nsh = GNUNET_NAMESTORE_connect (cfg); | 294 | nsh = GNUNET_NAMESTORE_connect (cfg); |
296 | GNUNET_break (NULL != nsh); | 295 | GNUNET_break (NULL != nsh); |
@@ -301,13 +300,13 @@ run (void *cls, | |||
301 | rd.record_type = GNUNET_GNSRECORD_TYPE_NICK; | 300 | rd.record_type = GNUNET_GNSRECORD_TYPE_NICK; |
302 | rd.expiration_time = GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us; | 301 | rd.expiration_time = GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us; |
303 | rd.flags |= GNUNET_GNSRECORD_RF_PRIVATE; | 302 | rd.flags |= GNUNET_GNSRECORD_RF_PRIVATE; |
304 | nsqe = GNUNET_NAMESTORE_records_store (nsh, | 303 | nsqe = GNUNET_NAMESTORE_record_set_store (nsh, |
305 | &privkey, | 304 | &privkey, |
306 | GNUNET_GNS_EMPTY_LABEL_AT, | 305 | GNUNET_GNS_EMPTY_LABEL_AT, |
307 | 1, | 306 | 1, |
308 | &rd, | 307 | &rd, |
309 | &nick_cont, | 308 | &nick_cont, |
310 | (void *) name); | 309 | (void *) name); |
311 | 310 | ||
312 | if (NULL == nsqe) | 311 | if (NULL == nsqe) |
313 | { | 312 | { |
diff --git a/src/service/namestore/test_namestore_api_monitoring.c b/src/service/namestore/test_namestore_api_monitoring.c index 0b879786c..016313148 100644 --- a/src/service/namestore/test_namestore_api_monitoring.c +++ b/src/service/namestore/test_namestore_api_monitoring.c | |||
@@ -21,10 +21,8 @@ | |||
21 | * @file namestore/test_namestore_api_monitoring.c | 21 | * @file namestore/test_namestore_api_monitoring.c |
22 | * @brief testcase for zone monitoring functionality: monitor first, then add records | 22 | * @brief testcase for zone monitoring functionality: monitor first, then add records |
23 | */ | 23 | */ |
24 | #include "platform.h" | ||
25 | #include "gnunet_namestore_service.h" | 24 | #include "gnunet_namestore_service.h" |
26 | #include "gnunet_testing_lib.h" | 25 | #include "gnunet_testing_lib.h" |
27 | #include "../service/namestore/namestore.h" | ||
28 | 26 | ||
29 | #define TEST_RECORD_TYPE GNUNET_DNSPARSER_TYPE_TXT | 27 | #define TEST_RECORD_TYPE GNUNET_DNSPARSER_TYPE_TXT |
30 | 28 | ||
@@ -312,38 +310,38 @@ run (void *cls, | |||
312 | GNUNET_asprintf (&s_name_3, "dummy3"); | 310 | GNUNET_asprintf (&s_name_3, "dummy3"); |
313 | s_rd_3 = create_record (1); | 311 | s_rd_3 = create_record (1); |
314 | GNUNET_assert (NULL != (ns_ops[2] = | 312 | GNUNET_assert (NULL != (ns_ops[2] = |
315 | GNUNET_NAMESTORE_records_store (nsh, | 313 | GNUNET_NAMESTORE_record_set_store (nsh, |
316 | &privkey2, | 314 | &privkey2, |
317 | s_name_3, | 315 | s_name_3, |
318 | 1, | 316 | 1, |
319 | s_rd_3, | 317 | s_rd_3, |
320 | &put_cont, | 318 | &put_cont, |
321 | s_name_3))); | 319 | s_name_3))); |
322 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 320 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
323 | "Created record 1\n"); | 321 | "Created record 1\n"); |
324 | GNUNET_asprintf (&s_name_1, "dummy1"); | 322 | GNUNET_asprintf (&s_name_1, "dummy1"); |
325 | s_rd_1 = create_record (1); | 323 | s_rd_1 = create_record (1); |
326 | GNUNET_assert (NULL != (ns_ops[0] = | 324 | GNUNET_assert (NULL != (ns_ops[0] = |
327 | GNUNET_NAMESTORE_records_store (nsh, | 325 | GNUNET_NAMESTORE_record_set_store (nsh, |
328 | &privkey, | 326 | &privkey, |
329 | s_name_1, | 327 | s_name_1, |
330 | 1, | 328 | 1, |
331 | s_rd_1, | 329 | s_rd_1, |
332 | &put_cont, | 330 | &put_cont, |
333 | s_name_1))); | 331 | s_name_1))); |
334 | 332 | ||
335 | 333 | ||
336 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created record 2 \n"); | 334 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created record 2 \n"); |
337 | GNUNET_asprintf (&s_name_2, "dummy2"); | 335 | GNUNET_asprintf (&s_name_2, "dummy2"); |
338 | s_rd_2 = create_record (1); | 336 | s_rd_2 = create_record (1); |
339 | GNUNET_assert (NULL != (ns_ops[1] = | 337 | GNUNET_assert (NULL != (ns_ops[1] = |
340 | GNUNET_NAMESTORE_records_store (nsh, | 338 | GNUNET_NAMESTORE_record_set_store (nsh, |
341 | &privkey, | 339 | &privkey, |
342 | s_name_2, | 340 | s_name_2, |
343 | 1, | 341 | 1, |
344 | s_rd_2, | 342 | s_rd_2, |
345 | &put_cont, | 343 | &put_cont, |
346 | s_name_2))); | 344 | s_name_2))); |
347 | } | 345 | } |
348 | 346 | ||
349 | 347 | ||
diff --git a/src/service/namestore/test_namestore_api_monitoring_existing.c b/src/service/namestore/test_namestore_api_monitoring_existing.c index ff7e39504..84cdaaa70 100644 --- a/src/service/namestore/test_namestore_api_monitoring_existing.c +++ b/src/service/namestore/test_namestore_api_monitoring_existing.c | |||
@@ -21,10 +21,8 @@ | |||
21 | * @file namestore/test_namestore_api_monitoring_existing.c | 21 | * @file namestore/test_namestore_api_monitoring_existing.c |
22 | * @brief testcase for zone monitoring functionality: add records first, then monitor | 22 | * @brief testcase for zone monitoring functionality: add records first, then monitor |
23 | */ | 23 | */ |
24 | #include "platform.h" | ||
25 | #include "gnunet_namestore_service.h" | 24 | #include "gnunet_namestore_service.h" |
26 | #include "gnunet_testing_lib.h" | 25 | #include "gnunet_testing_lib.h" |
27 | #include "../service/namestore/namestore.h" | ||
28 | 26 | ||
29 | #define TEST_RECORD_TYPE GNUNET_DNSPARSER_TYPE_TXT | 27 | #define TEST_RECORD_TYPE GNUNET_DNSPARSER_TYPE_TXT |
30 | 28 | ||
@@ -326,38 +324,38 @@ run (void *cls, | |||
326 | s_name_3 = "dummy3"; | 324 | s_name_3 = "dummy3"; |
327 | s_rd_3 = create_record (1); | 325 | s_rd_3 = create_record (1); |
328 | GNUNET_assert (NULL != (ns_ops[2] = | 326 | GNUNET_assert (NULL != (ns_ops[2] = |
329 | GNUNET_NAMESTORE_records_store (nsh, | 327 | GNUNET_NAMESTORE_record_set_store (nsh, |
330 | &privkey2, | 328 | &privkey2, |
331 | s_name_3, | 329 | s_name_3, |
332 | 1, | 330 | 1, |
333 | s_rd_3, | 331 | s_rd_3, |
334 | &put_cont, | 332 | &put_cont, |
335 | (void *) s_name_3))); | 333 | (void *) s_name_3))); |
336 | 334 | ||
337 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 335 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
338 | "Created record 1\n"); | 336 | "Created record 1\n"); |
339 | s_name_1 = "dummy1"; | 337 | s_name_1 = "dummy1"; |
340 | s_rd_1 = create_record (1); | 338 | s_rd_1 = create_record (1); |
341 | GNUNET_assert (NULL != (ns_ops[0] = | 339 | GNUNET_assert (NULL != (ns_ops[0] = |
342 | GNUNET_NAMESTORE_records_store (nsh, | 340 | GNUNET_NAMESTORE_record_set_store (nsh, |
343 | &privkey, | 341 | &privkey, |
344 | s_name_1, | 342 | s_name_1, |
345 | 1, | 343 | 1, |
346 | s_rd_1, | 344 | s_rd_1, |
347 | &put_cont, | 345 | &put_cont, |
348 | (void *) s_name_1))); | 346 | (void *) s_name_1))); |
349 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 347 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
350 | "Created record 2 \n"); | 348 | "Created record 2 \n"); |
351 | s_name_2 = "dummy2"; | 349 | s_name_2 = "dummy2"; |
352 | s_rd_2 = create_record (1); | 350 | s_rd_2 = create_record (1); |
353 | GNUNET_assert (NULL != (ns_ops[1] = | 351 | GNUNET_assert (NULL != (ns_ops[1] = |
354 | GNUNET_NAMESTORE_records_store (nsh, | 352 | GNUNET_NAMESTORE_record_set_store (nsh, |
355 | &privkey, | 353 | &privkey, |
356 | s_name_2, | 354 | s_name_2, |
357 | 1, | 355 | 1, |
358 | s_rd_2, | 356 | s_rd_2, |
359 | &put_cont, | 357 | &put_cont, |
360 | (void *) s_name_2))); | 358 | (void *) s_name_2))); |
361 | } | 359 | } |
362 | 360 | ||
363 | 361 | ||
diff --git a/src/service/namestore/test_namestore_api_remove.c b/src/service/namestore/test_namestore_api_remove.c index 4efdb7efa..f096c6310 100644 --- a/src/service/namestore/test_namestore_api_remove.c +++ b/src/service/namestore/test_namestore_api_remove.c | |||
@@ -136,11 +136,11 @@ put_cont (void *cls, | |||
136 | "Name store added record for `%s': %s\n", | 136 | "Name store added record for `%s': %s\n", |
137 | name, | 137 | name, |
138 | (GNUNET_EC_NONE == ec) ? "SUCCESS" : "FAIL"); | 138 | (GNUNET_EC_NONE == ec) ? "SUCCESS" : "FAIL"); |
139 | nsqe = GNUNET_NAMESTORE_records_store (nsh, | 139 | nsqe = GNUNET_NAMESTORE_record_set_store (nsh, |
140 | &privkey, | 140 | &privkey, |
141 | name, | 141 | name, |
142 | 0, NULL, | 142 | 0, NULL, |
143 | &remove_cont, (void *) name); | 143 | &remove_cont, (void *) name); |
144 | } | 144 | } |
145 | 145 | ||
146 | 146 | ||
@@ -158,7 +158,7 @@ run (void *cls, | |||
158 | privkey.type = htonl (GNUNET_GNSRECORD_TYPE_PKEY); | 158 | privkey.type = htonl (GNUNET_GNSRECORD_TYPE_PKEY); |
159 | GNUNET_CRYPTO_ecdsa_key_create (&privkey.ecdsa_key); | 159 | GNUNET_CRYPTO_ecdsa_key_create (&privkey.ecdsa_key); |
160 | GNUNET_CRYPTO_key_get_public (&privkey, | 160 | GNUNET_CRYPTO_key_get_public (&privkey, |
161 | &pubkey); | 161 | &pubkey); |
162 | 162 | ||
163 | removed = GNUNET_NO; | 163 | removed = GNUNET_NO; |
164 | 164 | ||
@@ -173,13 +173,13 @@ run (void *cls, | |||
173 | 173 | ||
174 | nsh = GNUNET_NAMESTORE_connect (cfg); | 174 | nsh = GNUNET_NAMESTORE_connect (cfg); |
175 | GNUNET_break (NULL != nsh); | 175 | GNUNET_break (NULL != nsh); |
176 | nsqe = GNUNET_NAMESTORE_records_store (nsh, | 176 | nsqe = GNUNET_NAMESTORE_record_set_store (nsh, |
177 | &privkey, | 177 | &privkey, |
178 | name, | 178 | name, |
179 | 1, | 179 | 1, |
180 | &rd, | 180 | &rd, |
181 | &put_cont, | 181 | &put_cont, |
182 | (void *) name); | 182 | (void *) name); |
183 | if (NULL == nsqe) | 183 | if (NULL == nsqe) |
184 | { | 184 | { |
185 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 185 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
diff --git a/src/service/namestore/test_namestore_api_remove_not_existing_record.c b/src/service/namestore/test_namestore_api_remove_not_existing_record.c index 4a21b0ff9..e6ddd8892 100644 --- a/src/service/namestore/test_namestore_api_remove_not_existing_record.c +++ b/src/service/namestore/test_namestore_api_remove_not_existing_record.c | |||
@@ -136,11 +136,11 @@ run (void *cls, | |||
136 | 136 | ||
137 | nsh = GNUNET_NAMESTORE_connect (cfg); | 137 | nsh = GNUNET_NAMESTORE_connect (cfg); |
138 | GNUNET_break (NULL != nsh); | 138 | GNUNET_break (NULL != nsh); |
139 | nsqe = GNUNET_NAMESTORE_records_store (nsh, | 139 | nsqe = GNUNET_NAMESTORE_record_set_store (nsh, |
140 | &privkey, | 140 | &privkey, |
141 | name, | 141 | name, |
142 | 0, NULL, | 142 | 0, NULL, |
143 | &put_cont, (void *) name); | 143 | &put_cont, (void *) name); |
144 | if (NULL == nsqe) | 144 | if (NULL == nsqe) |
145 | { | 145 | { |
146 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 146 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
diff --git a/src/service/namestore/test_namestore_api_store.c b/src/service/namestore/test_namestore_api_store.c index e7b87c28b..7e19fb79f 100644 --- a/src/service/namestore/test_namestore_api_store.c +++ b/src/service/namestore/test_namestore_api_store.c | |||
@@ -108,7 +108,7 @@ run (void *cls, | |||
108 | struct GNUNET_TESTING_Peer *peer) | 108 | struct GNUNET_TESTING_Peer *peer) |
109 | { | 109 | { |
110 | struct GNUNET_GNSRECORD_Data rd; | 110 | struct GNUNET_GNSRECORD_Data rd; |
111 | const char *name = "dummy.dummy.gnunet"; | 111 | const char *name = "dummy"; |
112 | 112 | ||
113 | endbadly_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, | 113 | endbadly_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, |
114 | &endbadly, NULL); | 114 | &endbadly, NULL); |
@@ -126,13 +126,13 @@ run (void *cls, | |||
126 | 126 | ||
127 | nsh = GNUNET_NAMESTORE_connect (cfg); | 127 | nsh = GNUNET_NAMESTORE_connect (cfg); |
128 | GNUNET_break (NULL != nsh); | 128 | GNUNET_break (NULL != nsh); |
129 | nsqe = GNUNET_NAMESTORE_records_store (nsh, | 129 | nsqe = GNUNET_NAMESTORE_record_set_store (nsh, |
130 | &privkey, | 130 | &privkey, |
131 | name, | 131 | name, |
132 | 1, | 132 | 1, |
133 | &rd, | 133 | &rd, |
134 | &put_cont, | 134 | &put_cont, |
135 | (void *) name); | 135 | (void *) name); |
136 | if (NULL == nsqe) | 136 | if (NULL == nsqe) |
137 | { | 137 | { |
138 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 138 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
diff --git a/src/service/namestore/test_namestore_api_store_update.c b/src/service/namestore/test_namestore_api_store_update.c index f2af41841..99bec23f9 100644 --- a/src/service/namestore/test_namestore_api_store_update.c +++ b/src/service/namestore/test_namestore_api_store_update.c | |||
@@ -101,7 +101,7 @@ put_cont (void *cls, | |||
101 | static void | 101 | static void |
102 | lookup_success (void *cls, | 102 | lookup_success (void *cls, |
103 | const struct GNUNET_CRYPTO_PrivateKey *zone, | 103 | const struct GNUNET_CRYPTO_PrivateKey *zone, |
104 | const char* label, | 104 | const char*label, |
105 | unsigned int rd_count, | 105 | unsigned int rd_count, |
106 | const struct GNUNET_GNSRECORD_Data *rd) | 106 | const struct GNUNET_GNSRECORD_Data *rd) |
107 | { | 107 | { |
@@ -136,13 +136,13 @@ lookup_success (void *cls, | |||
136 | TEST_RECORD_DATA2, | 136 | TEST_RECORD_DATA2, |
137 | TEST_RECORD_DATALEN2); | 137 | TEST_RECORD_DATALEN2); |
138 | 138 | ||
139 | nsqe = GNUNET_NAMESTORE_records_store (nsh, | 139 | nsqe = GNUNET_NAMESTORE_record_set_store (nsh, |
140 | &privkey, | 140 | &privkey, |
141 | name, | 141 | name, |
142 | 1, | 142 | 1, |
143 | &rd_new, | 143 | &rd_new, |
144 | &put_cont, | 144 | &put_cont, |
145 | (void *) name); | 145 | (void *) name); |
146 | GNUNET_free_nz ((void*) rd_new.data); | 146 | GNUNET_free_nz ((void*) rd_new.data); |
147 | update_performed = GNUNET_YES; | 147 | update_performed = GNUNET_YES; |
148 | } | 148 | } |
@@ -179,7 +179,7 @@ put_cont (void *cls, | |||
179 | name, | 179 | name, |
180 | &endbadly, | 180 | &endbadly, |
181 | (void *) name, | 181 | (void *) name, |
182 | & lookup_success, | 182 | &lookup_success, |
183 | (void *) name); | 183 | (void *) name); |
184 | } | 184 | } |
185 | 185 | ||
@@ -213,13 +213,13 @@ run (void *cls, | |||
213 | nsh = GNUNET_NAMESTORE_connect (cfg); | 213 | nsh = GNUNET_NAMESTORE_connect (cfg); |
214 | GNUNET_break (NULL != nsh); | 214 | GNUNET_break (NULL != nsh); |
215 | 215 | ||
216 | nsqe = GNUNET_NAMESTORE_records_store (nsh, | 216 | nsqe = GNUNET_NAMESTORE_record_set_store (nsh, |
217 | &privkey, | 217 | &privkey, |
218 | name, | 218 | name, |
219 | 1, | 219 | 1, |
220 | &rd, | 220 | &rd, |
221 | &put_cont, | 221 | &put_cont, |
222 | (void *) name); | 222 | (void *) name); |
223 | if (NULL == nsqe) | 223 | if (NULL == nsqe) |
224 | { | 224 | { |
225 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 225 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
diff --git a/src/service/namestore/test_namestore_api_tx_rollback.c b/src/service/namestore/test_namestore_api_tx_rollback.c deleted file mode 100644 index 0c334d374..000000000 --- a/src/service/namestore/test_namestore_api_tx_rollback.c +++ /dev/null | |||
@@ -1,264 +0,0 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | Copyright (C) 2022 GNUnet e.V. | ||
4 | |||
5 | GNUnet is free software: you can redistribute it and/or modify it | ||
6 | under the terms of the GNU Affero General Public License as published | ||
7 | by the Free Software Foundation, either version 3 of the License, | ||
8 | or (at your option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Affero General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Affero General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | ||
19 | */ | ||
20 | /** | ||
21 | * @file namestore/test_namestore_api_tx_rollback.c | ||
22 | * @brief testcase for namestore_api_tx_rollback.c to: rollback changes in TX | ||
23 | */ | ||
24 | #include "platform.h" | ||
25 | #include "gnunet_namestore_service.h" | ||
26 | #include "gnunet_testing_lib.h" | ||
27 | |||
28 | #define TEST_RECORD_TYPE GNUNET_DNSPARSER_TYPE_TXT | ||
29 | |||
30 | #define TEST_RECORD_DATALEN 123 | ||
31 | |||
32 | #define TEST_RECORD_DATA 'a' | ||
33 | |||
34 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 100) | ||
35 | |||
36 | |||
37 | static struct GNUNET_NAMESTORE_Handle *nsh; | ||
38 | |||
39 | static struct GNUNET_SCHEDULER_Task *endbadly_task; | ||
40 | |||
41 | static struct GNUNET_CRYPTO_PrivateKey privkey; | ||
42 | |||
43 | static struct GNUNET_CRYPTO_PublicKey pubkey; | ||
44 | |||
45 | static int res; | ||
46 | |||
47 | static int removed; | ||
48 | |||
49 | static struct GNUNET_NAMESTORE_QueueEntry *nsqe; | ||
50 | |||
51 | |||
52 | static void | ||
53 | cleanup () | ||
54 | { | ||
55 | if (NULL != nsh) | ||
56 | { | ||
57 | GNUNET_NAMESTORE_disconnect (nsh); | ||
58 | nsh = NULL; | ||
59 | } | ||
60 | GNUNET_SCHEDULER_shutdown (); | ||
61 | } | ||
62 | |||
63 | |||
64 | /** | ||
65 | * Re-establish the connection to the service. | ||
66 | * | ||
67 | * @param cls handle to use to re-connect. | ||
68 | */ | ||
69 | static void | ||
70 | endbadly (void *cls) | ||
71 | { | ||
72 | if (NULL != nsqe) | ||
73 | { | ||
74 | GNUNET_NAMESTORE_cancel (nsqe); | ||
75 | nsqe = NULL; | ||
76 | } | ||
77 | cleanup (); | ||
78 | res = 1; | ||
79 | } | ||
80 | |||
81 | |||
82 | static void | ||
83 | end (void *cls) | ||
84 | { | ||
85 | cleanup (); | ||
86 | res = 0; | ||
87 | } | ||
88 | |||
89 | static void | ||
90 | lookup_it (void *cls, | ||
91 | const struct GNUNET_CRYPTO_PrivateKey *zone, | ||
92 | const char *label, | ||
93 | unsigned int rd_count, | ||
94 | const struct GNUNET_GNSRECORD_Data *rd) | ||
95 | { | ||
96 | GNUNET_assert (0 == rd_count); | ||
97 | GNUNET_SCHEDULER_add_now (&end, NULL); | ||
98 | } | ||
99 | |||
100 | static void | ||
101 | fail_cb (void *cls) | ||
102 | { | ||
103 | GNUNET_assert (0); | ||
104 | } | ||
105 | |||
106 | static void | ||
107 | remove_cont (void *cls, | ||
108 | enum GNUNET_ErrorCode ec) | ||
109 | { | ||
110 | nsqe = NULL; | ||
111 | if (GNUNET_EC_NONE != ec) | ||
112 | { | ||
113 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
114 | _ ("Unable to roll back: `%s'\n"), | ||
115 | GNUNET_ErrorCode_get_hint (ec)); | ||
116 | if (NULL != endbadly_task) | ||
117 | GNUNET_SCHEDULER_cancel (endbadly_task); | ||
118 | endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly, | ||
119 | NULL); | ||
120 | return; | ||
121 | } | ||
122 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
123 | "Rolled back, perform lookup\n"); | ||
124 | removed = GNUNET_YES; | ||
125 | if (NULL != endbadly_task) | ||
126 | GNUNET_SCHEDULER_cancel (endbadly_task); | ||
127 | /* FIXME not actually doing lookup here */ | ||
128 | nsqe = GNUNET_NAMESTORE_records_lookup (nsh, | ||
129 | &privkey, | ||
130 | (char*) cls, | ||
131 | &fail_cb, | ||
132 | NULL, | ||
133 | &lookup_it, | ||
134 | NULL); | ||
135 | } | ||
136 | |||
137 | |||
138 | static void | ||
139 | put_cont (void *cls, | ||
140 | enum GNUNET_ErrorCode ec) | ||
141 | { | ||
142 | const char *name = cls; | ||
143 | |||
144 | GNUNET_assert (NULL != cls); | ||
145 | nsqe = NULL; | ||
146 | if (GNUNET_EC_NONE != ec) | ||
147 | { | ||
148 | GNUNET_break (0); | ||
149 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
150 | "Namestore could not store record: `%s'\n", | ||
151 | GNUNET_ErrorCode_get_hint (ec)); | ||
152 | if (endbadly_task != NULL) | ||
153 | GNUNET_SCHEDULER_cancel (endbadly_task); | ||
154 | endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly, NULL); | ||
155 | return; | ||
156 | } | ||
157 | |||
158 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
159 | "Name store added record for `%s': %s\n", | ||
160 | name, | ||
161 | (GNUNET_EC_NONE == ec) ? "SUCCESS" : "FAIL"); | ||
162 | nsqe = GNUNET_NAMESTORE_transaction_rollback (nsh, remove_cont, | ||
163 | (void *) name); | ||
164 | } | ||
165 | |||
166 | static void | ||
167 | begin_cont (void *cls, | ||
168 | enum GNUNET_ErrorCode ec) | ||
169 | { | ||
170 | struct GNUNET_GNSRECORD_Data rd; | ||
171 | const char *name = cls; | ||
172 | |||
173 | GNUNET_assert (GNUNET_EC_NONE == ec); | ||
174 | privkey.type = htonl (GNUNET_GNSRECORD_TYPE_PKEY); | ||
175 | GNUNET_CRYPTO_ecdsa_key_create (&privkey.ecdsa_key); | ||
176 | GNUNET_CRYPTO_key_get_public (&privkey, | ||
177 | &pubkey); | ||
178 | |||
179 | removed = GNUNET_NO; | ||
180 | |||
181 | rd.expiration_time = GNUNET_TIME_absolute_get ().abs_value_us; | ||
182 | rd.record_type = TEST_RECORD_TYPE; | ||
183 | rd.data_size = TEST_RECORD_DATALEN; | ||
184 | rd.data = GNUNET_malloc (TEST_RECORD_DATALEN); | ||
185 | rd.flags = 0; | ||
186 | memset ((char *) rd.data, | ||
187 | 'a', | ||
188 | TEST_RECORD_DATALEN); | ||
189 | nsqe = GNUNET_NAMESTORE_records_store (nsh, | ||
190 | &privkey, | ||
191 | name, | ||
192 | 1, | ||
193 | &rd, | ||
194 | &put_cont, | ||
195 | (void *) name); | ||
196 | GNUNET_assert (NULL != nsqe); | ||
197 | GNUNET_free_nz ((void *) rd.data); | ||
198 | } | ||
199 | |||
200 | static void | ||
201 | run (void *cls, | ||
202 | const struct GNUNET_CONFIGURATION_Handle *cfg, | ||
203 | struct GNUNET_TESTING_Peer *peer) | ||
204 | { | ||
205 | const char *name = "dummy"; | ||
206 | |||
207 | endbadly_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, | ||
208 | &endbadly, | ||
209 | NULL); | ||
210 | nsh = GNUNET_NAMESTORE_connect (cfg); | ||
211 | GNUNET_break (NULL != nsh); | ||
212 | nsqe = GNUNET_NAMESTORE_transaction_begin (nsh, begin_cont, (void *) name); | ||
213 | /*nsqe = GNUNET_NAMESTORE_transaction_commit (nsh, commit_cont); | ||
214 | nsqe = GNUNET_NAMESTORE_transaction_rollback (nsh, rollback_cont); Must also happen on disconnect | ||
215 | nsqe = GNUNET_NAMESTORE_records_edit (nsh, | ||
216 | &privkey, | ||
217 | name, | ||
218 | 1, | ||
219 | &rd, | ||
220 | &edit_cont, | ||
221 | (void *) name); | ||
222 | nsqe = GNUNET_NAMESTORE_records_insert_bulk (nsh, | ||
223 | count, | ||
224 | &rd, | ||
225 | & | ||
226 | nsqe = GNUNET_NAMESTORE_records_store (nsh, | ||
227 | &privkey, | ||
228 | name, | ||
229 | 1, | ||
230 | &rd, | ||
231 | &put_cont, | ||
232 | (void *) name);*/ | ||
233 | GNUNET_assert (NULL != nsqe); | ||
234 | } | ||
235 | |||
236 | |||
237 | #include "test_common.c" | ||
238 | |||
239 | |||
240 | int | ||
241 | main (int argc, char *argv[]) | ||
242 | { | ||
243 | char *plugin_name; | ||
244 | char *cfg_name; | ||
245 | |||
246 | SETUP_CFG (plugin_name, cfg_name); | ||
247 | res = 1; | ||
248 | if (0 != | ||
249 | GNUNET_TESTING_peer_run ("test-namestore-api-remove", | ||
250 | cfg_name, | ||
251 | &run, | ||
252 | NULL)) | ||
253 | { | ||
254 | res = 1; | ||
255 | } | ||
256 | GNUNET_DISK_purge_cfg_dir (cfg_name, | ||
257 | "GNUNET_TEST_HOME"); | ||
258 | GNUNET_free (plugin_name); | ||
259 | GNUNET_free (cfg_name); | ||
260 | return res; | ||
261 | } | ||
262 | |||
263 | |||
264 | /* end of test_namestore_api_remove.c */ | ||
diff --git a/src/service/namestore/test_namestore_api_zone_iteration.c b/src/service/namestore/test_namestore_api_zone_iteration.c index 403a49a23..3147661a7 100644 --- a/src/service/namestore/test_namestore_api_zone_iteration.c +++ b/src/service/namestore/test_namestore_api_zone_iteration.c | |||
@@ -370,34 +370,34 @@ empty_zone_end (void *cls) | |||
370 | 370 | ||
371 | GNUNET_asprintf (&s_name_1, "dummy1"); | 371 | GNUNET_asprintf (&s_name_1, "dummy1"); |
372 | s_rd_1 = create_record (1); | 372 | s_rd_1 = create_record (1); |
373 | GNUNET_NAMESTORE_records_store (nsh, | 373 | GNUNET_NAMESTORE_record_set_store (nsh, |
374 | &privkey, | 374 | &privkey, |
375 | s_name_1, | 375 | s_name_1, |
376 | 1, s_rd_1, | 376 | 1, s_rd_1, |
377 | &put_cont, | 377 | &put_cont, |
378 | NULL); | 378 | NULL); |
379 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 379 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
380 | "Created record 2 \n"); | 380 | "Created record 2 \n"); |
381 | GNUNET_asprintf (&s_name_2, "dummy2"); | 381 | GNUNET_asprintf (&s_name_2, "dummy2"); |
382 | s_rd_2 = create_record (1); | 382 | s_rd_2 = create_record (1); |
383 | GNUNET_NAMESTORE_records_store (nsh, | 383 | GNUNET_NAMESTORE_record_set_store (nsh, |
384 | &privkey, | 384 | &privkey, |
385 | s_name_2, | 385 | s_name_2, |
386 | 1, s_rd_2, | 386 | 1, s_rd_2, |
387 | &put_cont, | 387 | &put_cont, |
388 | NULL); | 388 | NULL); |
389 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 389 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
390 | "Created record 3\n"); | 390 | "Created record 3\n"); |
391 | /* name in different zone */ | 391 | /* name in different zone */ |
392 | GNUNET_asprintf (&s_name_3, "dummy3"); | 392 | GNUNET_asprintf (&s_name_3, "dummy3"); |
393 | s_rd_3 = create_record (1); | 393 | s_rd_3 = create_record (1); |
394 | GNUNET_NAMESTORE_records_store (nsh, | 394 | GNUNET_NAMESTORE_record_set_store (nsh, |
395 | &privkey2, | 395 | &privkey2, |
396 | s_name_3, | 396 | s_name_3, |
397 | 1, | 397 | 1, |
398 | s_rd_3, | 398 | s_rd_3, |
399 | &put_cont, | 399 | &put_cont, |
400 | NULL); | 400 | NULL); |
401 | } | 401 | } |
402 | 402 | ||
403 | 403 | ||
diff --git a/src/service/namestore/test_namestore_api_zone_iteration_nick.c b/src/service/namestore/test_namestore_api_zone_iteration_nick.c index 1ca7b3559..29c5ee70f 100644 --- a/src/service/namestore/test_namestore_api_zone_iteration_nick.c +++ b/src/service/namestore/test_namestore_api_zone_iteration_nick.c | |||
@@ -23,7 +23,6 @@ | |||
23 | */ | 23 | */ |
24 | #include "platform.h" | 24 | #include "platform.h" |
25 | #include "gnunet_namestore_service.h" | 25 | #include "gnunet_namestore_service.h" |
26 | #include "gnunet_gns_service.h" | ||
27 | #include "gnunet_testing_lib.h" | 26 | #include "gnunet_testing_lib.h" |
28 | #include "../service/namestore/namestore.h" | 27 | #include "../service/namestore/namestore.h" |
29 | 28 | ||
@@ -282,16 +281,16 @@ nick_2_cont (void *cls, | |||
282 | 281 | ||
283 | GNUNET_asprintf (&s_name_1, "dummy1"); | 282 | GNUNET_asprintf (&s_name_1, "dummy1"); |
284 | s_rd_1 = create_record (1); | 283 | s_rd_1 = create_record (1); |
285 | GNUNET_NAMESTORE_records_store (nsh, &privkey, s_name_1, | 284 | GNUNET_NAMESTORE_record_set_store (nsh, &privkey, s_name_1, |
286 | 1, s_rd_1, | 285 | 1, s_rd_1, |
287 | &put_cont, NULL); | 286 | &put_cont, NULL); |
288 | 287 | ||
289 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 288 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
290 | "Created record 2 \n"); | 289 | "Created record 2 \n"); |
291 | GNUNET_asprintf (&s_name_2, "dummy2"); | 290 | GNUNET_asprintf (&s_name_2, "dummy2"); |
292 | s_rd_2 = create_record (1); | 291 | s_rd_2 = create_record (1); |
293 | GNUNET_NAMESTORE_records_store (nsh, &privkey, s_name_2, | 292 | GNUNET_NAMESTORE_record_set_store (nsh, &privkey, s_name_2, |
294 | 1, s_rd_2, &put_cont, NULL); | 293 | 1, s_rd_2, &put_cont, NULL); |
295 | 294 | ||
296 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 295 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
297 | "Created record 3\n"); | 296 | "Created record 3\n"); |
@@ -299,9 +298,9 @@ nick_2_cont (void *cls, | |||
299 | /* name in different zone */ | 298 | /* name in different zone */ |
300 | GNUNET_asprintf (&s_name_3, "dummy3"); | 299 | GNUNET_asprintf (&s_name_3, "dummy3"); |
301 | s_rd_3 = create_record (1); | 300 | s_rd_3 = create_record (1); |
302 | GNUNET_NAMESTORE_records_store (nsh, &privkey2, s_name_3, | 301 | GNUNET_NAMESTORE_record_set_store (nsh, &privkey2, s_name_3, |
303 | 1, s_rd_3, | 302 | 1, s_rd_3, |
304 | &put_cont, NULL); | 303 | &put_cont, NULL); |
305 | } | 304 | } |
306 | 305 | ||
307 | 306 | ||
@@ -319,13 +318,13 @@ nick_1_cont (void *cls, enum GNUNET_ErrorCode ec) | |||
319 | rd.record_type = GNUNET_GNSRECORD_TYPE_NICK; | 318 | rd.record_type = GNUNET_GNSRECORD_TYPE_NICK; |
320 | rd.expiration_time = GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us; | 319 | rd.expiration_time = GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us; |
321 | rd.flags |= GNUNET_GNSRECORD_RF_PRIVATE; | 320 | rd.flags |= GNUNET_GNSRECORD_RF_PRIVATE; |
322 | nsqe = GNUNET_NAMESTORE_records_store (nsh, | 321 | nsqe = GNUNET_NAMESTORE_record_set_store (nsh, |
323 | &privkey2, | 322 | &privkey2, |
324 | GNUNET_GNS_EMPTY_LABEL_AT, | 323 | GNUNET_GNS_EMPTY_LABEL_AT, |
325 | 1, | 324 | 1, |
326 | &rd, | 325 | &rd, |
327 | &nick_2_cont, | 326 | &nick_2_cont, |
328 | &privkey2); | 327 | &privkey2); |
329 | 328 | ||
330 | if (NULL == nsqe) | 329 | if (NULL == nsqe) |
331 | { | 330 | { |
@@ -387,13 +386,13 @@ empty_zone_end (void *cls) | |||
387 | rd.record_type = GNUNET_GNSRECORD_TYPE_NICK; | 386 | rd.record_type = GNUNET_GNSRECORD_TYPE_NICK; |
388 | rd.expiration_time = GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us; | 387 | rd.expiration_time = GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us; |
389 | rd.flags |= GNUNET_GNSRECORD_RF_PRIVATE; | 388 | rd.flags |= GNUNET_GNSRECORD_RF_PRIVATE; |
390 | nsqe = GNUNET_NAMESTORE_records_store (nsh, | 389 | nsqe = GNUNET_NAMESTORE_record_set_store (nsh, |
391 | &privkey, | 390 | &privkey, |
392 | GNUNET_GNS_EMPTY_LABEL_AT, | 391 | GNUNET_GNS_EMPTY_LABEL_AT, |
393 | 1, | 392 | 1, |
394 | &rd, | 393 | &rd, |
395 | &nick_1_cont, | 394 | &nick_1_cont, |
396 | NULL); | 395 | NULL); |
397 | if (NULL == nsqe) | 396 | if (NULL == nsqe) |
398 | { | 397 | { |
399 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 398 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
diff --git a/src/service/namestore/test_namestore_api_zone_iteration_specific_zone.c b/src/service/namestore/test_namestore_api_zone_iteration_specific_zone.c index 753e550ad..8189b7e7e 100644 --- a/src/service/namestore/test_namestore_api_zone_iteration_specific_zone.c +++ b/src/service/namestore/test_namestore_api_zone_iteration_specific_zone.c | |||
@@ -25,7 +25,6 @@ | |||
25 | #include "platform.h" | 25 | #include "platform.h" |
26 | #include "gnunet_namestore_service.h" | 26 | #include "gnunet_namestore_service.h" |
27 | #include "gnunet_testing_lib.h" | 27 | #include "gnunet_testing_lib.h" |
28 | #include "../service/namestore/namestore.h" | ||
29 | 28 | ||
30 | #define TEST_RECORD_TYPE GNUNET_DNSPARSER_TYPE_TXT | 29 | #define TEST_RECORD_TYPE GNUNET_DNSPARSER_TYPE_TXT |
31 | 30 | ||
@@ -348,26 +347,26 @@ empty_zone_proc_end (void *cls) | |||
348 | GNUNET_asprintf (&s_name_1, | 347 | GNUNET_asprintf (&s_name_1, |
349 | "dummy1"); | 348 | "dummy1"); |
350 | s_rd_1 = create_record (1); | 349 | s_rd_1 = create_record (1); |
351 | GNUNET_NAMESTORE_records_store (nsh, | 350 | GNUNET_NAMESTORE_record_set_store (nsh, |
352 | &privkey, | 351 | &privkey, |
353 | s_name_1, | 352 | s_name_1, |
354 | 1, | 353 | 1, |
355 | s_rd_1, | 354 | s_rd_1, |
356 | &put_cont, | 355 | &put_cont, |
357 | NULL); | 356 | NULL); |
358 | 357 | ||
359 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 358 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
360 | "Created record 2 \n"); | 359 | "Created record 2 \n"); |
361 | GNUNET_asprintf (&s_name_2, | 360 | GNUNET_asprintf (&s_name_2, |
362 | "dummy2"); | 361 | "dummy2"); |
363 | s_rd_2 = create_record (1); | 362 | s_rd_2 = create_record (1); |
364 | GNUNET_NAMESTORE_records_store (nsh, | 363 | GNUNET_NAMESTORE_record_set_store (nsh, |
365 | &privkey, | 364 | &privkey, |
366 | s_name_2, | 365 | s_name_2, |
367 | 1, | 366 | 1, |
368 | s_rd_2, | 367 | s_rd_2, |
369 | &put_cont, | 368 | &put_cont, |
370 | NULL); | 369 | NULL); |
371 | 370 | ||
372 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 371 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
373 | "Created record 3\n"); | 372 | "Created record 3\n"); |
@@ -376,12 +375,12 @@ empty_zone_proc_end (void *cls) | |||
376 | GNUNET_asprintf (&s_name_3, | 375 | GNUNET_asprintf (&s_name_3, |
377 | "dummy3"); | 376 | "dummy3"); |
378 | s_rd_3 = create_record (1); | 377 | s_rd_3 = create_record (1); |
379 | GNUNET_NAMESTORE_records_store (nsh, | 378 | GNUNET_NAMESTORE_record_set_store (nsh, |
380 | &privkey2, | 379 | &privkey2, |
381 | s_name_3, | 380 | s_name_3, |
382 | 1, s_rd_3, | 381 | 1, s_rd_3, |
383 | &put_cont, | 382 | &put_cont, |
384 | NULL); | 383 | NULL); |
385 | } | 384 | } |
386 | 385 | ||
387 | 386 | ||
diff --git a/src/service/namestore/test_namestore_api_zone_iteration_stop.c b/src/service/namestore/test_namestore_api_zone_iteration_stop.c index dd63837ce..e578c50d7 100644 --- a/src/service/namestore/test_namestore_api_zone_iteration_stop.c +++ b/src/service/namestore/test_namestore_api_zone_iteration_stop.c | |||
@@ -24,7 +24,6 @@ | |||
24 | #include "platform.h" | 24 | #include "platform.h" |
25 | #include "gnunet_namestore_service.h" | 25 | #include "gnunet_namestore_service.h" |
26 | #include "gnunet_testing_lib.h" | 26 | #include "gnunet_testing_lib.h" |
27 | #include "../service/namestore/namestore.h" | ||
28 | 27 | ||
29 | #define TEST_RECORD_TYPE GNUNET_DNSPARSER_TYPE_TXT | 28 | #define TEST_RECORD_TYPE GNUNET_DNSPARSER_TYPE_TXT |
30 | 29 | ||
@@ -359,21 +358,21 @@ empty_zone_proc_end (void *cls) | |||
359 | GNUNET_asprintf (&s_name_1, | 358 | GNUNET_asprintf (&s_name_1, |
360 | "dummy1"); | 359 | "dummy1"); |
361 | s_rd_1 = create_record (1); | 360 | s_rd_1 = create_record (1); |
362 | GNUNET_NAMESTORE_records_store (nsh, | 361 | GNUNET_NAMESTORE_record_set_store (nsh, |
363 | &privkey, s_name_1, | 362 | &privkey, s_name_1, |
364 | 1, s_rd_1, &put_cont, NULL); | 363 | 1, s_rd_1, &put_cont, NULL); |
365 | 364 | ||
366 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 365 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
367 | "Created record 2 \n"); | 366 | "Created record 2 \n"); |
368 | GNUNET_asprintf (&s_name_2, | 367 | GNUNET_asprintf (&s_name_2, |
369 | "dummy2"); | 368 | "dummy2"); |
370 | s_rd_2 = create_record (1); | 369 | s_rd_2 = create_record (1); |
371 | GNUNET_NAMESTORE_records_store (nsh, | 370 | GNUNET_NAMESTORE_record_set_store (nsh, |
372 | &privkey, | 371 | &privkey, |
373 | s_name_2, | 372 | s_name_2, |
374 | 1, | 373 | 1, |
375 | s_rd_2, | 374 | s_rd_2, |
376 | &put_cont, NULL); | 375 | &put_cont, NULL); |
377 | 376 | ||
378 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 377 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
379 | "Created record 3\n"); | 378 | "Created record 3\n"); |
@@ -381,12 +380,12 @@ empty_zone_proc_end (void *cls) | |||
381 | /* name in different zone */ | 380 | /* name in different zone */ |
382 | GNUNET_asprintf (&s_name_3, "dummy3"); | 381 | GNUNET_asprintf (&s_name_3, "dummy3"); |
383 | s_rd_3 = create_record (1); | 382 | s_rd_3 = create_record (1); |
384 | GNUNET_NAMESTORE_records_store (nsh, | 383 | GNUNET_NAMESTORE_record_set_store (nsh, |
385 | &privkey2, | 384 | &privkey2, |
386 | s_name_3, | 385 | s_name_3, |
387 | 1, | 386 | 1, |
388 | s_rd_3, | 387 | s_rd_3, |
389 | &put_cont, NULL); | 388 | &put_cont, NULL); |
390 | } | 389 | } |
391 | 390 | ||
392 | 391 | ||
diff --git a/src/service/namestore/test_namestore_api_zone_to_name.c b/src/service/namestore/test_namestore_api_zone_to_name.c index f41b41642..c05a9173f 100644 --- a/src/service/namestore/test_namestore_api_zone_to_name.c +++ b/src/service/namestore/test_namestore_api_zone_to_name.c | |||
@@ -21,10 +21,8 @@ | |||
21 | * @file namestore/test_namestore_api_zone_to_name.c | 21 | * @file namestore/test_namestore_api_zone_to_name.c |
22 | * @brief testcase for zone to name translation | 22 | * @brief testcase for zone to name translation |
23 | */ | 23 | */ |
24 | #include "platform.h" | ||
25 | #include "gnunet_namestore_service.h" | 24 | #include "gnunet_namestore_service.h" |
26 | #include "gnunet_testing_lib.h" | 25 | #include "gnunet_testing_lib.h" |
27 | #include "../service/namestore/namestore.h" | ||
28 | 26 | ||
29 | #define TEST_RECORD_TYPE GNUNET_DNSPARSER_TYPE_TXT | 27 | #define TEST_RECORD_TYPE GNUNET_DNSPARSER_TYPE_TXT |
30 | 28 | ||
@@ -206,7 +204,7 @@ run (void *cls, | |||
206 | GNUNET_CRYPTO_ecdsa_key_create (&privkey.ecdsa_key); | 204 | GNUNET_CRYPTO_ecdsa_key_create (&privkey.ecdsa_key); |
207 | /* get public key */ | 205 | /* get public key */ |
208 | GNUNET_CRYPTO_key_get_public (&privkey, | 206 | GNUNET_CRYPTO_key_get_public (&privkey, |
209 | &pubkey); | 207 | &pubkey); |
210 | 208 | ||
211 | GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK, | 209 | GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK, |
212 | &s_zone_value, | 210 | &s_zone_value, |
@@ -223,13 +221,13 @@ run (void *cls, | |||
223 | 221 | ||
224 | nsh = GNUNET_NAMESTORE_connect (cfg); | 222 | nsh = GNUNET_NAMESTORE_connect (cfg); |
225 | GNUNET_break (NULL != nsh); | 223 | GNUNET_break (NULL != nsh); |
226 | GNUNET_NAMESTORE_records_store (nsh, | 224 | GNUNET_NAMESTORE_record_set_store (nsh, |
227 | &privkey, | 225 | &privkey, |
228 | s_name, | 226 | s_name, |
229 | 1, | 227 | 1, |
230 | &rd, | 228 | &rd, |
231 | &put_cont, | 229 | &put_cont, |
232 | s_name); | 230 | s_name); |
233 | } | 231 | } |
234 | } | 232 | } |
235 | 233 | ||
diff --git a/src/service/reclaim/did_core.c b/src/service/reclaim/did_core.c index ce3336b91..5804a0d7e 100644 --- a/src/service/reclaim/did_core.c +++ b/src/service/reclaim/did_core.c | |||
@@ -27,7 +27,6 @@ | |||
27 | // TODO: DID documents do not have an expiration date. Still we add one | 27 | // TODO: DID documents do not have an expiration date. Still we add one |
28 | // TODO: Store DID document with empty label and own type (maybe DID-Document or JSON??) | 28 | // TODO: Store DID document with empty label and own type (maybe DID-Document or JSON??) |
29 | 29 | ||
30 | #include "platform.h" | ||
31 | #include "did_core.h" | 30 | #include "did_core.h" |
32 | 31 | ||
33 | struct DID_resolve_return | 32 | struct DID_resolve_return |
@@ -66,7 +65,8 @@ DID_resolve_gns_lookup_cb ( | |||
66 | void *cls_did_resolve_cb = ((struct DID_resolve_return *) cls)->cls; | 65 | void *cls_did_resolve_cb = ((struct DID_resolve_return *) cls)->cls; |
67 | free (cls); | 66 | free (cls); |
68 | 67 | ||
69 | for (int i = 0; i < rd_count; i++) { | 68 | for (int i = 0; i < rd_count; i++) |
69 | { | ||
70 | if (rd[i].record_type != GNUNET_GNSRECORD_TYPE_DID_DOCUMENT) | 70 | if (rd[i].record_type != GNUNET_GNSRECORD_TYPE_DID_DOCUMENT) |
71 | continue; | 71 | continue; |
72 | did_document = (char *) rd[i].data; | 72 | did_document = (char *) rd[i].data; |
@@ -77,6 +77,7 @@ DID_resolve_gns_lookup_cb ( | |||
77 | cls_did_resolve_cb); | 77 | cls_did_resolve_cb); |
78 | } | 78 | } |
79 | 79 | ||
80 | |||
80 | /** | 81 | /** |
81 | * @brief Resolve a DID. | 82 | * @brief Resolve a DID. |
82 | * Calls the given callback function with the resolved DID Document and the given closure. | 83 | * Calls the given callback function with the resolved DID Document and the given closure. |
@@ -116,6 +117,7 @@ DID_resolve (const char *did, | |||
116 | return GNUNET_OK; | 117 | return GNUNET_OK; |
117 | } | 118 | } |
118 | 119 | ||
120 | |||
119 | // ------------------------------------------------ // | 121 | // ------------------------------------------------ // |
120 | // -------------------- Create -------------------- // | 122 | // -------------------- Create -------------------- // |
121 | // ------------------------------------------------ // | 123 | // ------------------------------------------------ // |
@@ -140,6 +142,7 @@ DID_create_did_store_cb (void *cls, | |||
140 | } | 142 | } |
141 | } | 143 | } |
142 | 144 | ||
145 | |||
143 | struct DID_create_namestore_lookup_closure | 146 | struct DID_create_namestore_lookup_closure |
144 | { | 147 | { |
145 | const char *did_document; | 148 | const char *did_document; |
@@ -178,7 +181,8 @@ DID_create_namestore_lookup_cb (void *cls, | |||
178 | printf ("Ego already has a DID Document. Abort.\n"); | 181 | printf ("Ego already has a DID Document. Abort.\n"); |
179 | cls_record_store_cb->cb (GNUNET_NO, cls_record_store_cb->cls); | 182 | cls_record_store_cb->cb (GNUNET_NO, cls_record_store_cb->cls); |
180 | } | 183 | } |
181 | else { | 184 | else |
185 | { | ||
182 | // Get public key | 186 | // Get public key |
183 | GNUNET_CRYPTO_key_get_public (zone, &pkey); | 187 | GNUNET_CRYPTO_key_get_public (zone, &pkey); |
184 | 188 | ||
@@ -197,16 +201,17 @@ DID_create_namestore_lookup_cb (void *cls, | |||
197 | record_data.flags = GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION; | 201 | record_data.flags = GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION; |
198 | 202 | ||
199 | // Store record | 203 | // Store record |
200 | GNUNET_NAMESTORE_records_store (namestore_handle, | 204 | GNUNET_NAMESTORE_record_set_store (namestore_handle, |
201 | zone, | 205 | zone, |
202 | DID_DOCUMENT_LABEL, | 206 | DID_DOCUMENT_LABEL, |
203 | 1, // FIXME what if GNUNET_GNS_EMPTY_LABEL_AT has records | 207 | 1, // FIXME what if GNUNET_GNS_EMPTY_LABEL_AT has records |
204 | &record_data, | 208 | &record_data, |
205 | &DID_create_did_store_cb, | 209 | &DID_create_did_store_cb, |
206 | (void *) cls_record_store_cb); | 210 | (void *) cls_record_store_cb); |
207 | } | 211 | } |
208 | } | 212 | } |
209 | 213 | ||
214 | |||
210 | /** | 215 | /** |
211 | * @brief Creates a DID and saves DID Document in Namestore. | 216 | * @brief Creates a DID and saves DID Document in Namestore. |
212 | * | 217 | * |
diff --git a/src/service/reclaim/gnunet-service-reclaim.c b/src/service/reclaim/gnunet-service-reclaim.c index 47a86a3e8..2e45324c0 100644 --- a/src/service/reclaim/gnunet-service-reclaim.c +++ b/src/service/reclaim/gnunet-service-reclaim.c | |||
@@ -23,15 +23,12 @@ | |||
23 | * @brief reclaim Service | 23 | * @brief reclaim Service |
24 | * | 24 | * |
25 | */ | 25 | */ |
26 | #include "platform.h" | ||
27 | #include "gnunet_util_lib.h" | 26 | #include "gnunet_util_lib.h" |
28 | #include "gnunet-service-reclaim_tickets.h" | 27 | #include "gnunet-service-reclaim_tickets.h" |
29 | #include "gnunet_constants.h" | ||
30 | #include "gnunet_gnsrecord_lib.h" | 28 | #include "gnunet_gnsrecord_lib.h" |
31 | #include "gnunet_protocols.h" | 29 | #include "gnunet_protocols.h" |
32 | #include "gnunet_reclaim_lib.h" | 30 | #include "gnunet_reclaim_lib.h" |
33 | #include "gnunet_reclaim_service.h" | 31 | #include "gnunet_reclaim_service.h" |
34 | #include "gnunet_signatures.h" | ||
35 | #include "reclaim.h" | 32 | #include "reclaim.h" |
36 | 33 | ||
37 | 34 | ||
@@ -784,7 +781,7 @@ handle_issue_ticket_message (void *cls, const struct IssueTicketMessage *im) | |||
784 | buf = (char *) &im[1]; | 781 | buf = (char *) &im[1]; |
785 | if ((GNUNET_SYSERR == | 782 | if ((GNUNET_SYSERR == |
786 | GNUNET_CRYPTO_read_private_key_from_buffer (buf, key_len, | 783 | GNUNET_CRYPTO_read_private_key_from_buffer (buf, key_len, |
787 | &identity, &read)) || | 784 | &identity, &read)) || |
788 | (read != key_len)) | 785 | (read != key_len)) |
789 | { | 786 | { |
790 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 787 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
@@ -796,7 +793,7 @@ handle_issue_ticket_message (void *cls, const struct IssueTicketMessage *im) | |||
796 | pkey_len = ntohs (im->pkey_len); | 793 | pkey_len = ntohs (im->pkey_len); |
797 | if ((GNUNET_SYSERR == | 794 | if ((GNUNET_SYSERR == |
798 | GNUNET_CRYPTO_read_public_key_from_buffer (buf, pkey_len, | 795 | GNUNET_CRYPTO_read_public_key_from_buffer (buf, pkey_len, |
799 | &rp, &read)) || | 796 | &rp, &read)) || |
800 | (read != pkey_len)) | 797 | (read != pkey_len)) |
801 | { | 798 | { |
802 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 799 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
@@ -902,7 +899,7 @@ handle_revoke_ticket_message (void *cls, const struct RevokeTicketMessage *rm) | |||
902 | buf = (char *) &rm[1]; | 899 | buf = (char *) &rm[1]; |
903 | if ((GNUNET_SYSERR == | 900 | if ((GNUNET_SYSERR == |
904 | GNUNET_CRYPTO_read_private_key_from_buffer (buf, key_len, | 901 | GNUNET_CRYPTO_read_private_key_from_buffer (buf, key_len, |
905 | &identity, &read)) || | 902 | &identity, &read)) || |
906 | (read != key_len)) | 903 | (read != key_len)) |
907 | { | 904 | { |
908 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 905 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
@@ -978,8 +975,8 @@ consume_result_cb (void *cls, | |||
978 | crm->result = htons (success); | 975 | crm->result = htons (success); |
979 | data_tmp = (char *) &crm[1]; | 976 | data_tmp = (char *) &crm[1]; |
980 | written = GNUNET_CRYPTO_write_public_key_to_buffer (identity, | 977 | written = GNUNET_CRYPTO_write_public_key_to_buffer (identity, |
981 | data_tmp, | 978 | data_tmp, |
982 | key_len); | 979 | key_len); |
983 | GNUNET_assert (0 <= written); | 980 | GNUNET_assert (0 <= written); |
984 | data_tmp += written; | 981 | data_tmp += written; |
985 | GNUNET_RECLAIM_attribute_list_serialize (attrs, data_tmp); | 982 | GNUNET_RECLAIM_attribute_list_serialize (attrs, data_tmp); |
@@ -1037,7 +1034,7 @@ handle_consume_ticket_message (void *cls, const struct ConsumeTicketMessage *cm) | |||
1037 | buf = (char *) &cm[1]; | 1034 | buf = (char *) &cm[1]; |
1038 | if ((GNUNET_SYSERR == | 1035 | if ((GNUNET_SYSERR == |
1039 | GNUNET_CRYPTO_read_private_key_from_buffer (buf, key_len, | 1036 | GNUNET_CRYPTO_read_private_key_from_buffer (buf, key_len, |
1040 | &identity, &read)) || | 1037 | &identity, &read)) || |
1041 | (read != key_len)) | 1038 | (read != key_len)) |
1042 | { | 1039 | { |
1043 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1040 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
@@ -1142,13 +1139,13 @@ attr_store_task (void *cls) | |||
1142 | rd[0].record_type = GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE; | 1139 | rd[0].record_type = GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE; |
1143 | rd[0].flags = GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION; | 1140 | rd[0].flags = GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION; |
1144 | rd[0].expiration_time = ash->exp.rel_value_us; | 1141 | rd[0].expiration_time = ash->exp.rel_value_us; |
1145 | ash->ns_qe = GNUNET_NAMESTORE_records_store (nsh, | 1142 | ash->ns_qe = GNUNET_NAMESTORE_record_set_store (nsh, |
1146 | &ash->identity, | 1143 | &ash->identity, |
1147 | label, | 1144 | label, |
1148 | 1, | 1145 | 1, |
1149 | rd, | 1146 | rd, |
1150 | &attr_store_cont, | 1147 | &attr_store_cont, |
1151 | ash); | 1148 | ash); |
1152 | GNUNET_free (buf); | 1149 | GNUNET_free (buf); |
1153 | GNUNET_free (label); | 1150 | GNUNET_free (label); |
1154 | } | 1151 | } |
@@ -1201,7 +1198,7 @@ handle_attribute_store_message (void *cls, | |||
1201 | buf = (char *) &sam[1]; | 1198 | buf = (char *) &sam[1]; |
1202 | if ((GNUNET_SYSERR == | 1199 | if ((GNUNET_SYSERR == |
1203 | GNUNET_CRYPTO_read_private_key_from_buffer (buf, key_len, | 1200 | GNUNET_CRYPTO_read_private_key_from_buffer (buf, key_len, |
1204 | &identity, &read)) || | 1201 | &identity, &read)) || |
1205 | (read != key_len)) | 1202 | (read != key_len)) |
1206 | { | 1203 | { |
1207 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1204 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
@@ -1314,13 +1311,13 @@ cred_add_cb (void *cls, | |||
1314 | rd_new[0].record_type = GNUNET_GNSRECORD_TYPE_RECLAIM_CREDENTIAL; | 1311 | rd_new[0].record_type = GNUNET_GNSRECORD_TYPE_RECLAIM_CREDENTIAL; |
1315 | rd_new[0].flags = GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION; | 1312 | rd_new[0].flags = GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION; |
1316 | rd_new[0].expiration_time = ash->exp.rel_value_us; | 1313 | rd_new[0].expiration_time = ash->exp.rel_value_us; |
1317 | ash->ns_qe = GNUNET_NAMESTORE_records_store (nsh, | 1314 | ash->ns_qe = GNUNET_NAMESTORE_record_set_store (nsh, |
1318 | &ash->identity, | 1315 | &ash->identity, |
1319 | label, | 1316 | label, |
1320 | 1, | 1317 | 1, |
1321 | rd_new, | 1318 | rd_new, |
1322 | &cred_store_cont, | 1319 | &cred_store_cont, |
1323 | ash); | 1320 | ash); |
1324 | GNUNET_free (buf); | 1321 | GNUNET_free (buf); |
1325 | return; | 1322 | return; |
1326 | } | 1323 | } |
@@ -1402,7 +1399,7 @@ handle_credential_store_message (void *cls, | |||
1402 | buf = (char *) &sam[1]; | 1399 | buf = (char *) &sam[1]; |
1403 | if ((GNUNET_SYSERR == | 1400 | if ((GNUNET_SYSERR == |
1404 | GNUNET_CRYPTO_read_private_key_from_buffer (buf, key_len, | 1401 | GNUNET_CRYPTO_read_private_key_from_buffer (buf, key_len, |
1405 | &identity, &read)) || | 1402 | &identity, &read)) || |
1406 | (read != key_len)) | 1403 | (read != key_len)) |
1407 | { | 1404 | { |
1408 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1405 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
@@ -1641,13 +1638,13 @@ update_tickets (void *cls) | |||
1641 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1638 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1642 | "Updating ticket with %d entries (%d before)...\n", | 1639 | "Updating ticket with %d entries (%d before)...\n", |
1643 | j, i); | 1640 | j, i); |
1644 | adh->ns_qe = GNUNET_NAMESTORE_records_store (nsh, | 1641 | adh->ns_qe = GNUNET_NAMESTORE_record_set_store (nsh, |
1645 | &adh->identity, | 1642 | &adh->identity, |
1646 | le->label, | 1643 | le->label, |
1647 | j, | 1644 | j, |
1648 | rd_new, | 1645 | rd_new, |
1649 | &ticket_updated, | 1646 | &ticket_updated, |
1650 | adh); | 1647 | adh); |
1651 | GNUNET_free (le->label); | 1648 | GNUNET_free (le->label); |
1652 | GNUNET_free (le->data); | 1649 | GNUNET_free (le->data); |
1653 | GNUNET_free (le); | 1650 | GNUNET_free (le); |
@@ -1727,13 +1724,13 @@ purge_attributes (void *cls) | |||
1727 | = GNUNET_STRINGS_data_to_string_alloc (&ale->attribute->id, | 1724 | = GNUNET_STRINGS_data_to_string_alloc (&ale->attribute->id, |
1728 | sizeof(ale->attribute->id)); | 1725 | sizeof(ale->attribute->id)); |
1729 | 1726 | ||
1730 | adh->ns_qe = GNUNET_NAMESTORE_records_store (nsh, | 1727 | adh->ns_qe = GNUNET_NAMESTORE_record_set_store (nsh, |
1731 | &adh->identity, | 1728 | &adh->identity, |
1732 | label, | 1729 | label, |
1733 | 0, | 1730 | 0, |
1734 | NULL, | 1731 | NULL, |
1735 | &offending_attr_delete_cont, | 1732 | &offending_attr_delete_cont, |
1736 | adh); | 1733 | adh); |
1737 | GNUNET_CONTAINER_DLL_remove (adh->existing_attributes->list_head, | 1734 | GNUNET_CONTAINER_DLL_remove (adh->existing_attributes->list_head, |
1738 | adh->existing_attributes->list_tail, | 1735 | adh->existing_attributes->list_tail, |
1739 | ale); | 1736 | ale); |
@@ -1873,7 +1870,7 @@ handle_attribute_delete_message (void *cls, | |||
1873 | buf = (char *) &dam[1]; | 1870 | buf = (char *) &dam[1]; |
1874 | if ((GNUNET_SYSERR == | 1871 | if ((GNUNET_SYSERR == |
1875 | GNUNET_CRYPTO_read_private_key_from_buffer (buf, key_len, | 1872 | GNUNET_CRYPTO_read_private_key_from_buffer (buf, key_len, |
1876 | &identity, &read)) || | 1873 | &identity, &read)) || |
1877 | (read != key_len)) | 1874 | (read != key_len)) |
1878 | { | 1875 | { |
1879 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1876 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
@@ -1896,13 +1893,13 @@ handle_attribute_delete_message (void *cls, | |||
1896 | GNUNET_SERVICE_client_continue (idp->client); | 1893 | GNUNET_SERVICE_client_continue (idp->client); |
1897 | adh->client = idp; | 1894 | adh->client = idp; |
1898 | GNUNET_CONTAINER_DLL_insert (idp->delete_op_head, idp->delete_op_tail, adh); | 1895 | GNUNET_CONTAINER_DLL_insert (idp->delete_op_head, idp->delete_op_tail, adh); |
1899 | adh->ns_qe = GNUNET_NAMESTORE_records_store (nsh, | 1896 | adh->ns_qe = GNUNET_NAMESTORE_record_set_store (nsh, |
1900 | &adh->identity, | 1897 | &adh->identity, |
1901 | adh->label, | 1898 | adh->label, |
1902 | 0, | 1899 | 0, |
1903 | NULL, | 1900 | NULL, |
1904 | &attr_delete_cont, | 1901 | &attr_delete_cont, |
1905 | adh); | 1902 | adh); |
1906 | } | 1903 | } |
1907 | 1904 | ||
1908 | 1905 | ||
@@ -1980,7 +1977,7 @@ handle_credential_delete_message (void *cls, | |||
1980 | buf = (char *) &dam[1]; | 1977 | buf = (char *) &dam[1]; |
1981 | if ((GNUNET_SYSERR == | 1978 | if ((GNUNET_SYSERR == |
1982 | GNUNET_CRYPTO_read_private_key_from_buffer (buf, key_len, | 1979 | GNUNET_CRYPTO_read_private_key_from_buffer (buf, key_len, |
1983 | &identity, &read)) || | 1980 | &identity, &read)) || |
1984 | (read != key_len)) | 1981 | (read != key_len)) |
1985 | { | 1982 | { |
1986 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1983 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
@@ -2002,13 +1999,13 @@ handle_credential_delete_message (void *cls, | |||
2002 | GNUNET_SERVICE_client_continue (idp->client); | 1999 | GNUNET_SERVICE_client_continue (idp->client); |
2003 | adh->client = idp; | 2000 | adh->client = idp; |
2004 | GNUNET_CONTAINER_DLL_insert (idp->delete_op_head, idp->delete_op_tail, adh); | 2001 | GNUNET_CONTAINER_DLL_insert (idp->delete_op_head, idp->delete_op_tail, adh); |
2005 | adh->ns_qe = GNUNET_NAMESTORE_records_store (nsh, | 2002 | adh->ns_qe = GNUNET_NAMESTORE_record_set_store (nsh, |
2006 | &adh->identity, | 2003 | &adh->identity, |
2007 | adh->label, | 2004 | adh->label, |
2008 | 0, | 2005 | 0, |
2009 | NULL, | 2006 | NULL, |
2010 | &cred_delete_cont, | 2007 | &cred_delete_cont, |
2011 | adh); | 2008 | adh); |
2012 | } | 2009 | } |
2013 | 2010 | ||
2014 | 2011 | ||
@@ -2101,8 +2098,8 @@ attr_iter_cb (void *cls, | |||
2101 | data_tmp = (char *) &arm[1]; | 2098 | data_tmp = (char *) &arm[1]; |
2102 | arm->pkey_len = htons (key_len); | 2099 | arm->pkey_len = htons (key_len); |
2103 | written = GNUNET_CRYPTO_write_public_key_to_buffer (&identity, | 2100 | written = GNUNET_CRYPTO_write_public_key_to_buffer (&identity, |
2104 | data_tmp, | 2101 | data_tmp, |
2105 | key_len); | 2102 | key_len); |
2106 | GNUNET_assert (0 <= written); | 2103 | GNUNET_assert (0 <= written); |
2107 | data_tmp += written; | 2104 | data_tmp += written; |
2108 | GNUNET_memcpy (data_tmp, rd->data, rd->data_size); | 2105 | GNUNET_memcpy (data_tmp, rd->data, rd->data_size); |
@@ -2129,6 +2126,7 @@ check_iteration_start ( | |||
2129 | return GNUNET_OK; | 2126 | return GNUNET_OK; |
2130 | } | 2127 | } |
2131 | 2128 | ||
2129 | |||
2132 | /** | 2130 | /** |
2133 | * Iterate over zone to get attributes | 2131 | * Iterate over zone to get attributes |
2134 | * | 2132 | * |
@@ -2150,9 +2148,9 @@ handle_iteration_start (void *cls, | |||
2150 | key_len = ntohs (ais_msg->key_len); | 2148 | key_len = ntohs (ais_msg->key_len); |
2151 | if ((GNUNET_SYSERR == | 2149 | if ((GNUNET_SYSERR == |
2152 | GNUNET_CRYPTO_read_private_key_from_buffer (&ais_msg[1], | 2150 | GNUNET_CRYPTO_read_private_key_from_buffer (&ais_msg[1], |
2153 | key_len, | 2151 | key_len, |
2154 | &identity, | 2152 | &identity, |
2155 | &read)) || | 2153 | &read)) || |
2156 | (read != key_len)) | 2154 | (read != key_len)) |
2157 | { | 2155 | { |
2158 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 2156 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
@@ -2331,14 +2329,15 @@ cred_iter_cb (void *cls, | |||
2331 | arm->key_len = htons (key_len); | 2329 | arm->key_len = htons (key_len); |
2332 | data_tmp = (char *) &arm[1]; | 2330 | data_tmp = (char *) &arm[1]; |
2333 | written = GNUNET_CRYPTO_write_public_key_to_buffer (&identity, | 2331 | written = GNUNET_CRYPTO_write_public_key_to_buffer (&identity, |
2334 | data_tmp, | 2332 | data_tmp, |
2335 | key_len); | 2333 | key_len); |
2336 | GNUNET_assert (written >= 0); | 2334 | GNUNET_assert (written >= 0); |
2337 | data_tmp += written; | 2335 | data_tmp += written; |
2338 | GNUNET_memcpy (data_tmp, rd->data, rd->data_size); | 2336 | GNUNET_memcpy (data_tmp, rd->data, rd->data_size); |
2339 | GNUNET_MQ_send (ai->client->mq, env); | 2337 | GNUNET_MQ_send (ai->client->mq, env); |
2340 | } | 2338 | } |
2341 | 2339 | ||
2340 | |||
2342 | static enum GNUNET_GenericReturnValue | 2341 | static enum GNUNET_GenericReturnValue |
2343 | check_credential_iteration_start ( | 2342 | check_credential_iteration_start ( |
2344 | void *cls, | 2343 | void *cls, |
@@ -2381,9 +2380,9 @@ handle_credential_iteration_start (void *cls, | |||
2381 | key_len = ntohs (ais_msg->key_len); | 2380 | key_len = ntohs (ais_msg->key_len); |
2382 | if ((GNUNET_SYSERR == | 2381 | if ((GNUNET_SYSERR == |
2383 | GNUNET_CRYPTO_read_private_key_from_buffer (&ais_msg[1], | 2382 | GNUNET_CRYPTO_read_private_key_from_buffer (&ais_msg[1], |
2384 | key_len, | 2383 | key_len, |
2385 | &identity, | 2384 | &identity, |
2386 | &read)) || | 2385 | &read)) || |
2387 | (read != key_len)) | 2386 | (read != key_len)) |
2388 | { | 2387 | { |
2389 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 2388 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
@@ -2524,6 +2523,7 @@ ticket_iter_cb (void *cls, struct GNUNET_RECLAIM_Ticket *ticket) | |||
2524 | GNUNET_free (ti); | 2523 | GNUNET_free (ti); |
2525 | } | 2524 | } |
2526 | 2525 | ||
2526 | |||
2527 | static enum GNUNET_GenericReturnValue | 2527 | static enum GNUNET_GenericReturnValue |
2528 | check_ticket_iteration_start ( | 2528 | check_ticket_iteration_start ( |
2529 | void *cls, | 2529 | void *cls, |
@@ -2543,6 +2543,7 @@ check_ticket_iteration_start ( | |||
2543 | return GNUNET_OK; | 2543 | return GNUNET_OK; |
2544 | } | 2544 | } |
2545 | 2545 | ||
2546 | |||
2546 | /** | 2547 | /** |
2547 | * Client requests a ticket iteration | 2548 | * Client requests a ticket iteration |
2548 | * | 2549 | * |
@@ -2565,9 +2566,9 @@ handle_ticket_iteration_start ( | |||
2565 | key_len = ntohs (tis_msg->key_len); | 2566 | key_len = ntohs (tis_msg->key_len); |
2566 | if ((GNUNET_SYSERR == | 2567 | if ((GNUNET_SYSERR == |
2567 | GNUNET_CRYPTO_read_private_key_from_buffer (&tis_msg[1], | 2568 | GNUNET_CRYPTO_read_private_key_from_buffer (&tis_msg[1], |
2568 | key_len, | 2569 | key_len, |
2569 | &identity, | 2570 | &identity, |
2570 | &read)) || | 2571 | &read)) || |
2571 | (read != key_len)) | 2572 | (read != key_len)) |
2572 | { | 2573 | { |
2573 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 2574 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
diff --git a/src/service/reclaim/gnunet-service-reclaim_tickets.c b/src/service/reclaim/gnunet-service-reclaim_tickets.c index 689fbc429..acd2b6859 100644 --- a/src/service/reclaim/gnunet-service-reclaim_tickets.c +++ b/src/service/reclaim/gnunet-service-reclaim_tickets.c | |||
@@ -24,8 +24,6 @@ | |||
24 | * @brief reclaim tickets | 24 | * @brief reclaim tickets |
25 | * | 25 | * |
26 | */ | 26 | */ |
27 | #include "platform.h" | ||
28 | #include <inttypes.h> | ||
29 | #include "gnunet-service-reclaim_tickets.h" | 27 | #include "gnunet-service-reclaim_tickets.h" |
30 | 28 | ||
31 | 29 | ||
@@ -451,13 +449,13 @@ process_tickets (void *cls) | |||
451 | rd[i].data = &ae->new_id; | 449 | rd[i].data = &ae->new_id; |
452 | } | 450 | } |
453 | } | 451 | } |
454 | rvk->ns_qe = GNUNET_NAMESTORE_records_store (nsh, | 452 | rvk->ns_qe = GNUNET_NAMESTORE_record_set_store (nsh, |
455 | &rvk->identity, | 453 | &rvk->identity, |
456 | le->label, | 454 | le->label, |
457 | le->rd_count, | 455 | le->rd_count, |
458 | rd, | 456 | rd, |
459 | &ticket_processed, | 457 | &ticket_processed, |
460 | rvk); | 458 | rvk); |
461 | GNUNET_free (le->label); | 459 | GNUNET_free (le->label); |
462 | GNUNET_free (le->data); | 460 | GNUNET_free (le->data); |
463 | GNUNET_free (le); | 461 | GNUNET_free (le); |
@@ -645,13 +643,13 @@ move_attr_finished (void *cls, enum GNUNET_ErrorCode ec) | |||
645 | sizeof(rvk->move_attr->old_id)); | 643 | sizeof(rvk->move_attr->old_id)); |
646 | GNUNET_assert (NULL != label); | 644 | GNUNET_assert (NULL != label); |
647 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Removing attribute %s\n", label); | 645 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Removing attribute %s\n", label); |
648 | rvk->ns_qe = GNUNET_NAMESTORE_records_store (nsh, | 646 | rvk->ns_qe = GNUNET_NAMESTORE_record_set_store (nsh, |
649 | &rvk->identity, | 647 | &rvk->identity, |
650 | label, | 648 | label, |
651 | 0, | 649 | 0, |
652 | NULL, | 650 | NULL, |
653 | &del_attr_finished, | 651 | &del_attr_finished, |
654 | rvk); | 652 | rvk); |
655 | GNUNET_free (label); | 653 | GNUNET_free (label); |
656 | } | 654 | } |
657 | 655 | ||
@@ -744,17 +742,18 @@ rvk_move_attr_cb (void *cls, | |||
744 | new_label); | 742 | new_label); |
745 | GNUNET_free (credential); | 743 | GNUNET_free (credential); |
746 | } | 744 | } |
747 | else { | 745 | else |
746 | { | ||
748 | memcpy (&new_rd[i], &rd[i], sizeof (struct GNUNET_GNSRECORD_Data)); | 747 | memcpy (&new_rd[i], &rd[i], sizeof (struct GNUNET_GNSRECORD_Data)); |
749 | } | 748 | } |
750 | } | 749 | } |
751 | rvk->ns_qe = GNUNET_NAMESTORE_records_store (nsh, | 750 | rvk->ns_qe = GNUNET_NAMESTORE_record_set_store (nsh, |
752 | &rvk->identity, | 751 | &rvk->identity, |
753 | new_label, | 752 | new_label, |
754 | rd_count, | 753 | rd_count, |
755 | new_rd, | 754 | new_rd, |
756 | &move_attr_finished, | 755 | &move_attr_finished, |
757 | rvk); | 756 | rvk); |
758 | GNUNET_free (new_label); | 757 | GNUNET_free (new_label); |
759 | GNUNET_free (attr_data); | 758 | GNUNET_free (attr_data); |
760 | } | 759 | } |
@@ -870,13 +869,13 @@ revoke_attrs_cb (void *cls, | |||
870 | } | 869 | } |
871 | 870 | ||
872 | /** Remove attribute references **/ | 871 | /** Remove attribute references **/ |
873 | rvk->ns_qe = GNUNET_NAMESTORE_records_store (nsh, | 872 | rvk->ns_qe = GNUNET_NAMESTORE_record_set_store (nsh, |
874 | &rvk->identity, | 873 | &rvk->identity, |
875 | label, | 874 | label, |
876 | 0, | 875 | 0, |
877 | NULL, | 876 | NULL, |
878 | &remove_ticket_cont, | 877 | &remove_ticket_cont, |
879 | rvk); | 878 | rvk); |
880 | } | 879 | } |
881 | 880 | ||
882 | 881 | ||
@@ -1399,19 +1398,19 @@ issue_ticket (struct TicketIssueHandle *ih) | |||
1399 | sizeof(ih->ticket.rnd)); | 1398 | sizeof(ih->ticket.rnd)); |
1400 | struct GNUNET_CRYPTO_PublicKey pub; | 1399 | struct GNUNET_CRYPTO_PublicKey pub; |
1401 | GNUNET_CRYPTO_key_get_public (&ih->identity, | 1400 | GNUNET_CRYPTO_key_get_public (&ih->identity, |
1402 | &pub); | 1401 | &pub); |
1403 | char *str = GNUNET_CRYPTO_public_key_to_string (&pub); | 1402 | char *str = GNUNET_CRYPTO_public_key_to_string (&pub); |
1404 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1403 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1405 | "Storing AuthZ information under %s in %s\n", label, str); | 1404 | "Storing AuthZ information under %s in %s\n", label, str); |
1406 | GNUNET_free (str); | 1405 | GNUNET_free (str); |
1407 | // Publish record | 1406 | // Publish record |
1408 | ih->ns_qe = GNUNET_NAMESTORE_records_store (nsh, | 1407 | ih->ns_qe = GNUNET_NAMESTORE_record_set_store (nsh, |
1409 | &ih->identity, | 1408 | &ih->identity, |
1410 | label, | 1409 | label, |
1411 | i, | 1410 | i, |
1412 | attrs_record, | 1411 | attrs_record, |
1413 | &store_ticket_issue_cont, | 1412 | &store_ticket_issue_cont, |
1414 | ih); | 1413 | ih); |
1415 | for (j = 0; j < i; j++) | 1414 | for (j = 0; j < i; j++) |
1416 | { | 1415 | { |
1417 | if (attrs_record[j].record_type | 1416 | if (attrs_record[j].record_type |
diff --git a/src/service/rest/namestore_plugin.c b/src/service/rest/namestore_plugin.c index 8c5b8b824..8ea2457f2 100644 --- a/src/service/rest/namestore_plugin.c +++ b/src/service/rest/namestore_plugin.c | |||
@@ -27,7 +27,6 @@ | |||
27 | #include "platform.h" | 27 | #include "platform.h" |
28 | #include "gnunet_error_codes.h" | 28 | #include "gnunet_error_codes.h" |
29 | #include "gnunet_rest_plugin.h" | 29 | #include "gnunet_rest_plugin.h" |
30 | #include "gnunet_gns_service.h" | ||
31 | #include "gnunet_namestore_service.h" | 30 | #include "gnunet_namestore_service.h" |
32 | #include "gnunet_identity_service.h" | 31 | #include "gnunet_identity_service.h" |
33 | #include "gnunet_rest_lib.h" | 32 | #include "gnunet_rest_lib.h" |
@@ -709,13 +708,13 @@ ns_lookup_cb (void *cls, | |||
709 | } | 708 | } |
710 | for (j = 0; j < handle->rd_count; j++) | 709 | for (j = 0; j < handle->rd_count; j++) |
711 | rd_new[i + j] = handle->rd[j]; | 710 | rd_new[i + j] = handle->rd[j]; |
712 | handle->ns_qe = GNUNET_NAMESTORE_records_store (ns_handle, | 711 | handle->ns_qe = GNUNET_NAMESTORE_record_set_store (ns_handle, |
713 | handle->zone_pkey, | 712 | handle->zone_pkey, |
714 | handle->record_name, | 713 | handle->record_name, |
715 | i + j, | 714 | i + j, |
716 | rd_new, | 715 | rd_new, |
717 | &create_finished, | 716 | &create_finished, |
718 | handle); | 717 | handle); |
719 | if (NULL == handle->ns_qe) | 718 | if (NULL == handle->ns_qe) |
720 | { | 719 | { |
721 | handle->ec = GNUNET_EC_NAMESTORE_UNKNOWN; | 720 | handle->ec = GNUNET_EC_NAMESTORE_UNKNOWN; |
@@ -726,27 +725,6 @@ ns_lookup_cb (void *cls, | |||
726 | 725 | ||
727 | 726 | ||
728 | static void | 727 | static void |
729 | bulk_tx_commit_cb (void *cls, enum GNUNET_ErrorCode ec) | ||
730 | { | ||
731 | struct RequestHandle *handle = cls; | ||
732 | struct MHD_Response *resp; | ||
733 | |||
734 | handle->ns_qe = NULL; | ||
735 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
736 | "Commit finished (%d)\n", ec); | ||
737 | handle->ec = ec; | ||
738 | if (GNUNET_EC_NONE != ec) | ||
739 | { | ||
740 | GNUNET_SCHEDULER_add_now (&do_error, handle); | ||
741 | return; | ||
742 | } | ||
743 | resp = GNUNET_REST_create_response (NULL); | ||
744 | handle->proc (handle->proc_cls, resp, MHD_HTTP_NO_CONTENT); | ||
745 | GNUNET_SCHEDULER_add_now (&cleanup_handle, handle); | ||
746 | } | ||
747 | |||
748 | |||
749 | static void | ||
750 | import_next_cb (void *cls, enum GNUNET_ErrorCode ec) | 728 | import_next_cb (void *cls, enum GNUNET_ErrorCode ec) |
751 | { | 729 | { |
752 | struct RequestHandle *handle = cls; | 730 | struct RequestHandle *handle = cls; |
@@ -763,22 +741,33 @@ import_next_cb (void *cls, enum GNUNET_ErrorCode ec) | |||
763 | unsigned int remaining = handle->rd_set_count - handle->rd_set_pos; | 741 | unsigned int remaining = handle->rd_set_count - handle->rd_set_pos; |
764 | if (0 == remaining) | 742 | if (0 == remaining) |
765 | { | 743 | { |
766 | handle->ns_qe = GNUNET_NAMESTORE_transaction_commit (handle->nc, | 744 | struct MHD_Response *resp; |
767 | &bulk_tx_commit_cb, | 745 | |
768 | handle); | 746 | handle->ns_qe = NULL; |
747 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
748 | "Commit finished (%d)\n", ec); | ||
749 | handle->ec = ec; | ||
750 | if (GNUNET_EC_NONE != ec) | ||
751 | { | ||
752 | GNUNET_SCHEDULER_add_now (&do_error, handle); | ||
753 | return; | ||
754 | } | ||
755 | resp = GNUNET_REST_create_response (NULL); | ||
756 | handle->proc (handle->proc_cls, resp, MHD_HTTP_NO_CONTENT); | ||
757 | GNUNET_SCHEDULER_add_now (&cleanup_handle, handle); | ||
769 | return; | 758 | return; |
770 | } | 759 | } |
771 | unsigned int sent_rds = 0; | 760 | unsigned int sent_rds = 0; |
772 | // Find the smallest set of records we can send with our message size | 761 | // Find the smallest set of records we can send with our message size |
773 | // restriction of 16 bit | 762 | // restriction of 16 bit |
774 | handle->ns_qe = GNUNET_NAMESTORE_records_store2 (handle->nc, | 763 | handle->ns_qe = GNUNET_NAMESTORE_records_store (handle->nc, |
775 | handle->zone_pkey, | 764 | handle->zone_pkey, |
776 | remaining, | 765 | remaining, |
777 | &handle->ri[handle-> | 766 | &handle->ri[handle-> |
778 | rd_set_pos], | 767 | rd_set_pos], |
779 | &sent_rds, | 768 | &sent_rds, |
780 | &import_next_cb, | 769 | &import_next_cb, |
781 | handle); | 770 | handle); |
782 | if ((NULL == handle->ns_qe) && (0 == sent_rds)) | 771 | if ((NULL == handle->ns_qe) && (0 == sent_rds)) |
783 | { | 772 | { |
784 | handle->ec = GNUNET_EC_NAMESTORE_UNKNOWN; | 773 | handle->ec = GNUNET_EC_NAMESTORE_UNKNOWN; |
@@ -790,20 +779,13 @@ import_next_cb (void *cls, enum GNUNET_ErrorCode ec) | |||
790 | 779 | ||
791 | 780 | ||
792 | static void | 781 | static void |
793 | bulk_tx_start (void *cls, enum GNUNET_ErrorCode ec) | 782 | bulk_tx_start (struct RequestHandle *handle) |
794 | { | 783 | { |
795 | struct RequestHandle *handle = cls; | ||
796 | json_t *data_js; | 784 | json_t *data_js; |
797 | json_error_t err; | 785 | json_error_t err; |
798 | 786 | ||
799 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 787 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
800 | "Transaction started...\n"); | 788 | "Transaction started...\n"); |
801 | handle->ec = ec; | ||
802 | if (GNUNET_EC_NONE != ec) | ||
803 | { | ||
804 | GNUNET_SCHEDULER_add_now (&do_error, handle); | ||
805 | return; | ||
806 | } | ||
807 | if (0 >= handle->rest_handle->data_size) | 789 | if (0 >= handle->rest_handle->data_size) |
808 | { | 790 | { |
809 | handle->ec = GNUNET_EC_NAMESTORE_NO_RECORDS_GIVEN; | 791 | handle->ec = GNUNET_EC_NAMESTORE_NO_RECORDS_GIVEN; |
@@ -866,13 +848,13 @@ bulk_tx_start (void *cls, enum GNUNET_ErrorCode ec) | |||
866 | unsigned int sent_rds = 0; | 848 | unsigned int sent_rds = 0; |
867 | // Find the smallest set of records we can send with our message size | 849 | // Find the smallest set of records we can send with our message size |
868 | // restriction of 16 bit | 850 | // restriction of 16 bit |
869 | handle->ns_qe = GNUNET_NAMESTORE_records_store2 (handle->nc, | 851 | handle->ns_qe = GNUNET_NAMESTORE_records_store (handle->nc, |
870 | handle->zone_pkey, | 852 | handle->zone_pkey, |
871 | handle->rd_set_count, | 853 | handle->rd_set_count, |
872 | handle->ri, | 854 | handle->ri, |
873 | &sent_rds, | 855 | &sent_rds, |
874 | &import_next_cb, | 856 | &import_next_cb, |
875 | handle); | 857 | handle); |
876 | if ((NULL == handle->ns_qe) && (0 == sent_rds)) | 858 | if ((NULL == handle->ns_qe) && (0 == sent_rds)) |
877 | { | 859 | { |
878 | handle->ec = GNUNET_EC_NAMESTORE_UNKNOWN; | 860 | handle->ec = GNUNET_EC_NAMESTORE_UNKNOWN; |
@@ -928,9 +910,7 @@ namestore_import (struct GNUNET_REST_RequestHandle *con_handle, | |||
928 | GNUNET_SCHEDULER_add_now (&do_error, handle); | 910 | GNUNET_SCHEDULER_add_now (&do_error, handle); |
929 | return; | 911 | return; |
930 | } | 912 | } |
931 | handle->ns_qe = GNUNET_NAMESTORE_transaction_begin (handle->nc, | 913 | bulk_tx_start (handle); |
932 | &bulk_tx_start, | ||
933 | handle); | ||
934 | } | 914 | } |
935 | 915 | ||
936 | 916 | ||
@@ -1104,13 +1084,13 @@ namestore_delete (struct GNUNET_REST_RequestHandle *con_handle, | |||
1104 | } | 1084 | } |
1105 | 1085 | ||
1106 | handle->record_name = GNUNET_strdup (labelname + 1); | 1086 | handle->record_name = GNUNET_strdup (labelname + 1); |
1107 | handle->ns_qe = GNUNET_NAMESTORE_records_store (ns_handle, | 1087 | handle->ns_qe = GNUNET_NAMESTORE_record_set_store (ns_handle, |
1108 | handle->zone_pkey, | 1088 | handle->zone_pkey, |
1109 | handle->record_name, | 1089 | handle->record_name, |
1110 | 0, | 1090 | 0, |
1111 | NULL, | 1091 | NULL, |
1112 | &del_finished, | 1092 | &del_finished, |
1113 | handle); | 1093 | handle); |
1114 | if (NULL == handle->ns_qe) | 1094 | if (NULL == handle->ns_qe) |
1115 | { | 1095 | { |
1116 | handle->ec = GNUNET_EC_NAMESTORE_UNKNOWN; | 1096 | handle->ec = GNUNET_EC_NAMESTORE_UNKNOWN; |
diff --git a/src/service/transport/meson.build b/src/service/transport/meson.build index 4dc6a9991..8b85a3258 100644 --- a/src/service/transport/meson.build +++ b/src/service/transport/meson.build | |||
@@ -81,6 +81,8 @@ libgnunettransporttesting2 = library('gnunettransporttesting2', | |||
81 | 'transport_api_cmd_backchannel_check.c', | 81 | 'transport_api_cmd_backchannel_check.c', |
82 | 'transport_api_cmd_start_peer.c', | 82 | 'transport_api_cmd_start_peer.c', |
83 | 'transport_api_cmd_stop_peer.c', | 83 | 'transport_api_cmd_stop_peer.c', |
84 | 'testing_api_cmd_start_peer.c', | ||
85 | 'testing_api_cmd_stop_peer.c', | ||
84 | 'transport_api_cmd_send_simple.c', | 86 | 'transport_api_cmd_send_simple.c', |
85 | 'transport_api_cmd_send_simple_performance.c', | 87 | 'transport_api_cmd_send_simple_performance.c', |
86 | 'transport-testing2.c', | 88 | 'transport-testing2.c', |