aboutsummaryrefslogtreecommitdiff
path: root/src/service/rest/namestore_plugin.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/service/rest/namestore_plugin.c')
-rw-r--r--src/service/rest/namestore_plugin.c110
1 files changed, 45 insertions, 65 deletions
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
728static void 727static void
729bulk_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
749static void
750import_next_cb (void *cls, enum GNUNET_ErrorCode ec) 728import_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
792static void 781static void
793bulk_tx_start (void *cls, enum GNUNET_ErrorCode ec) 782bulk_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;