aboutsummaryrefslogtreecommitdiff
path: root/src/datastore/gnunet-service-datastore.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/datastore/gnunet-service-datastore.c')
-rw-r--r--src/datastore/gnunet-service-datastore.c57
1 files changed, 42 insertions, 15 deletions
diff --git a/src/datastore/gnunet-service-datastore.c b/src/datastore/gnunet-service-datastore.c
index f8012527a..77e96c94f 100644
--- a/src/datastore/gnunet-service-datastore.c
+++ b/src/datastore/gnunet-service-datastore.c
@@ -829,9 +829,21 @@ struct PutContext
829}; 829};
830 830
831 831
832/**
833 * Put continuation.
834 *
835 * @param cls closure
836 * @param key key for the item stored
837 * @param size size of the item stored
838 * @param status #GNUNET_OK or #GNUNET_SYSERROR
839 * @param msg error message on error
840 */
832static void 841static void
833put_continuation (void *cls, const struct GNUNET_HashCode *key, uint32_t size, 842put_continuation (void *cls,
834 int status, char *msg) 843 const struct GNUNET_HashCode *key,
844 uint32_t size,
845 int status,
846 const char *msg)
835{ 847{
836 struct GNUNET_SERVER_Client *client = cls; 848 struct GNUNET_SERVER_Client *client = cls;
837 849
@@ -877,7 +889,9 @@ execute_put (struct GNUNET_SERVER_Client *client, const struct DataMessage *dm)
877 889
878 890
879static void 891static void
880check_present_continuation (void *cls, int status, char *msg) 892check_present_continuation (void *cls,
893 int status,
894 const char *msg)
881{ 895{
882 struct GNUNET_SERVER_Client *client = cls; 896 struct GNUNET_SERVER_Client *client = cls;
883 897
@@ -890,7 +904,7 @@ check_present_continuation (void *cls, int status, char *msg)
890 * Function that will check if the given datastore entry 904 * Function that will check if the given datastore entry
891 * matches the put and if none match executes the put. 905 * matches the put and if none match executes the put.
892 * 906 *
893 * @param cls closure, pointer to the client (of type 'struct PutContext'). 907 * @param cls closure, pointer to the client (of type `struct PutContext`).
894 * @param key key for the content 908 * @param key key for the content
895 * @param size number of bytes in data 909 * @param size number of bytes in data
896 * @param data content stored 910 * @param data content stored
@@ -900,14 +914,18 @@ check_present_continuation (void *cls, int status, char *msg)
900 * @param expiration expiration time for the content 914 * @param expiration expiration time for the content
901 * @param uid unique identifier for the datum; 915 * @param uid unique identifier for the datum;
902 * maybe 0 if no unique identifier is available 916 * maybe 0 if no unique identifier is available
903 * 917 * @return #GNUNET_OK usually
904 * @return GNUNET_OK usually 918 * #GNUNET_NO to delete the item
905 * GNUNET_NO to delete the item
906 */ 919 */
907static int 920static int
908check_present (void *cls, const struct GNUNET_HashCode * key, uint32_t size, 921check_present (void *cls,
909 const void *data, enum GNUNET_BLOCK_Type type, uint32_t priority, 922 const struct GNUNET_HashCode *key,
910 uint32_t anonymity, struct GNUNET_TIME_Absolute expiration, 923 uint32_t size,
924 const void *data,
925 enum GNUNET_BLOCK_Type type,
926 uint32_t priority,
927 uint32_t anonymity,
928 struct GNUNET_TIME_Absolute expiration,
911 uint64_t uid) 929 uint64_t uid)
912{ 930{
913 struct PutContext *pc = cls; 931 struct PutContext *pc = cls;
@@ -932,10 +950,12 @@ check_present (void *cls, const struct GNUNET_HashCode * key, uint32_t size,
932 if ((ntohl (dm->priority) > 0) || 950 if ((ntohl (dm->priority) > 0) ||
933 (GNUNET_TIME_absolute_ntoh (dm->expiration).abs_value_us > 951 (GNUNET_TIME_absolute_ntoh (dm->expiration).abs_value_us >
934 expiration.abs_value_us)) 952 expiration.abs_value_us))
935 plugin->api->update (plugin->api->cls, uid, 953 plugin->api->update (plugin->api->cls,
954 uid,
936 (int32_t) ntohl (dm->priority), 955 (int32_t) ntohl (dm->priority),
937 GNUNET_TIME_absolute_ntoh (dm->expiration), 956 GNUNET_TIME_absolute_ntoh (dm->expiration),
938 check_present_continuation, pc->client); 957 &check_present_continuation,
958 pc->client);
939 else 959 else
940 { 960 {
941 transmit_status (pc->client, GNUNET_NO, NULL); 961 transmit_status (pc->client, GNUNET_NO, NULL);
@@ -1008,8 +1028,13 @@ handle_put (void *cls, struct GNUNET_SERVER_Client *client,
1008 pc->client = client; 1028 pc->client = client;
1009 GNUNET_SERVER_client_keep (client); 1029 GNUNET_SERVER_client_keep (client);
1010 memcpy (&pc[1], dm, size + sizeof (struct DataMessage)); 1030 memcpy (&pc[1], dm, size + sizeof (struct DataMessage));
1011 plugin->api->get_key (plugin->api->cls, 0, &dm->key, &vhash, 1031 plugin->api->get_key (plugin->api->cls,
1012 ntohl (dm->type), &check_present, pc); 1032 0,
1033 &dm->key,
1034 &vhash,
1035 ntohl (dm->type),
1036 &check_present,
1037 pc);
1013 return; 1038 return;
1014 } 1039 }
1015 execute_put (client, dm); 1040 execute_put (client, dm);
@@ -1069,7 +1094,9 @@ handle_get (void *cls, struct GNUNET_SERVER_Client *client,
1069 1094
1070 1095
1071static void 1096static void
1072update_continuation (void *cls, int status, char *msg) 1097update_continuation (void *cls,
1098 int status,
1099 const char *msg)
1073{ 1100{
1074 struct GNUNET_SERVER_Client *client = cls; 1101 struct GNUNET_SERVER_Client *client = cls;
1075 1102