aboutsummaryrefslogtreecommitdiff
path: root/src/datastore/gnunet-service-datastore.c
diff options
context:
space:
mode:
authorDavid Barksdale <amatus@amat.us>2017-03-22 22:17:05 -0500
committerDavid Barksdale <amatus@amat.us>2017-03-22 22:19:13 -0500
commit78ecfccd774a77ae3d7a51e3f5c7c7c86cf7985b (patch)
tree1dc23a2f6d78c8026e69181ac90055929d79bba8 /src/datastore/gnunet-service-datastore.c
parentaa98f144e6db0da5a0a4cad83fe64a80bbab6692 (diff)
downloadgnunet-78ecfccd774a77ae3d7a51e3f5c7c7c86cf7985b.tar.gz
gnunet-78ecfccd774a77ae3d7a51e3f5c7c7c86cf7985b.zip
[datastore] Return and update replication
This fixes a couple FIXMEs in the datastore code. The replication value is now returned from the datastore and the update function can increase the replication.
Diffstat (limited to 'src/datastore/gnunet-service-datastore.c')
-rw-r--r--src/datastore/gnunet-service-datastore.c38
1 files changed, 24 insertions, 14 deletions
diff --git a/src/datastore/gnunet-service-datastore.c b/src/datastore/gnunet-service-datastore.c
index af33c4412..277530843 100644
--- a/src/datastore/gnunet-service-datastore.c
+++ b/src/datastore/gnunet-service-datastore.c
@@ -286,6 +286,7 @@ delete_expired (void *cls);
286 * @param type type of the content 286 * @param type type of the content
287 * @param priority priority of the content 287 * @param priority priority of the content
288 * @param anonymity anonymity-level for the content 288 * @param anonymity anonymity-level for the content
289 * @param replication replication-level for the content
289 * @param expiration expiration time for the content 290 * @param expiration expiration time for the content
290 * @param uid unique identifier for the datum; 291 * @param uid unique identifier for the datum;
291 * maybe 0 if no unique identifier is available 292 * maybe 0 if no unique identifier is available
@@ -302,6 +303,7 @@ expired_processor (void *cls,
302 enum GNUNET_BLOCK_Type type, 303 enum GNUNET_BLOCK_Type type,
303 uint32_t priority, 304 uint32_t priority,
304 uint32_t anonymity, 305 uint32_t anonymity,
306 uint32_t replication,
305 struct GNUNET_TIME_Absolute expiration, 307 struct GNUNET_TIME_Absolute expiration,
306 uint64_t uid) 308 uint64_t uid)
307{ 309{
@@ -374,6 +376,7 @@ delete_expired (void *cls)
374 * @param type type of the content 376 * @param type type of the content
375 * @param priority priority of the content 377 * @param priority priority of the content
376 * @param anonymity anonymity-level for the content 378 * @param anonymity anonymity-level for the content
379 * @param replication replication-level for the content
377 * @param expiration expiration time for the content 380 * @param expiration expiration time for the content
378 * @param uid unique identifier for the datum; 381 * @param uid unique identifier for the datum;
379 * maybe 0 if no unique identifier is available 382 * maybe 0 if no unique identifier is available
@@ -389,6 +392,7 @@ quota_processor (void *cls,
389 enum GNUNET_BLOCK_Type type, 392 enum GNUNET_BLOCK_Type type,
390 uint32_t priority, 393 uint32_t priority,
391 uint32_t anonymity, 394 uint32_t anonymity,
395 uint32_t replication,
392 struct GNUNET_TIME_Absolute expiration, 396 struct GNUNET_TIME_Absolute expiration,
393 uint64_t uid) 397 uint64_t uid)
394{ 398{
@@ -495,6 +499,7 @@ transmit_status (struct GNUNET_SERVICE_Client *client,
495 * @param type type of the content 499 * @param type type of the content
496 * @param priority priority of the content 500 * @param priority priority of the content
497 * @param anonymity anonymity-level for the content 501 * @param anonymity anonymity-level for the content
502 * @param replication replication-level for the content
498 * @param expiration expiration time for the content 503 * @param expiration expiration time for the content
499 * @param uid unique identifier for the datum; 504 * @param uid unique identifier for the datum;
500 * maybe 0 if no unique identifier is available 505 * maybe 0 if no unique identifier is available
@@ -509,6 +514,7 @@ transmit_item (void *cls,
509 enum GNUNET_BLOCK_Type type, 514 enum GNUNET_BLOCK_Type type,
510 uint32_t priority, 515 uint32_t priority,
511 uint32_t anonymity, 516 uint32_t anonymity,
517 uint32_t replication,
512 struct GNUNET_TIME_Absolute expiration, 518 struct GNUNET_TIME_Absolute expiration,
513 uint64_t uid) 519 uint64_t uid)
514{ 520{
@@ -538,8 +544,7 @@ transmit_item (void *cls,
538 dm->type = htonl (type); 544 dm->type = htonl (type);
539 dm->priority = htonl (priority); 545 dm->priority = htonl (priority);
540 dm->anonymity = htonl (anonymity); 546 dm->anonymity = htonl (anonymity);
541 dm->replication = htonl (0); 547 dm->replication = htonl (replication);
542 dm->reserved = htonl (0);
543 dm->expiration = GNUNET_TIME_absolute_hton (expiration); 548 dm->expiration = GNUNET_TIME_absolute_hton (expiration);
544 dm->uid = GNUNET_htonll (uid); 549 dm->uid = GNUNET_htonll (uid);
545 dm->key = *key; 550 dm->key = *key;
@@ -848,6 +853,7 @@ check_present_continuation (void *cls,
848 * @param type type of the content 853 * @param type type of the content
849 * @param priority priority of the content 854 * @param priority priority of the content
850 * @param anonymity anonymity-level for the content 855 * @param anonymity anonymity-level for the content
856 * @param replication replication-level for the content
851 * @param expiration expiration time for the content 857 * @param expiration expiration time for the content
852 * @param uid unique identifier for the datum; 858 * @param uid unique identifier for the datum;
853 * maybe 0 if no unique identifier is available 859 * maybe 0 if no unique identifier is available
@@ -856,13 +862,14 @@ check_present_continuation (void *cls,
856 */ 862 */
857static int 863static int
858check_present (void *cls, 864check_present (void *cls,
859 const struct GNUNET_HashCode *key, 865 const struct GNUNET_HashCode *key,
860 uint32_t size, 866 uint32_t size,
861 const void *data, 867 const void *data,
862 enum GNUNET_BLOCK_Type type, 868 enum GNUNET_BLOCK_Type type,
863 uint32_t priority, 869 uint32_t priority,
864 uint32_t anonymity, 870 uint32_t anonymity,
865 struct GNUNET_TIME_Absolute expiration, 871 uint32_t replication,
872 struct GNUNET_TIME_Absolute expiration,
866 uint64_t uid) 873 uint64_t uid)
867{ 874{
868 struct PutContext *pc = cls; 875 struct PutContext *pc = cls;
@@ -883,16 +890,17 @@ check_present (void *cls,
883 { 890 {
884 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 891 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
885 "Result already present in datastore\n"); 892 "Result already present in datastore\n");
886 /* FIXME: change API to allow increasing 'replication' counter */ 893 if ( (ntohl (dm->priority) > 0) ||
887 if ((ntohl (dm->priority) > 0) || 894 (ntohl (dm->replication) > 0) ||
888 (GNUNET_TIME_absolute_ntoh (dm->expiration).abs_value_us > 895 (GNUNET_TIME_absolute_ntoh (dm->expiration).abs_value_us >
889 expiration.abs_value_us)) 896 expiration.abs_value_us) )
890 plugin->api->update (plugin->api->cls, 897 plugin->api->update (plugin->api->cls,
891 uid, 898 uid,
892 ntohl (dm->priority), 899 ntohl (dm->priority),
900 ntohl (dm->replication),
893 GNUNET_TIME_absolute_ntoh (dm->expiration), 901 GNUNET_TIME_absolute_ntoh (dm->expiration),
894 &check_present_continuation, 902 &check_present_continuation,
895 pc->client); 903 pc->client);
896 else 904 else
897 { 905 {
898 transmit_status (pc->client, 906 transmit_status (pc->client,
@@ -1064,7 +1072,7 @@ handle_get_key (void *cls,
1064 1, 1072 1,
1065 GNUNET_NO); 1073 GNUNET_NO);
1066 transmit_item (client, 1074 transmit_item (client,
1067 NULL, 0, NULL, 0, 0, 0, 1075 NULL, 0, NULL, 0, 0, 0, 0,
1068 GNUNET_TIME_UNIT_ZERO_ABS, 1076 GNUNET_TIME_UNIT_ZERO_ABS,
1069 0); 1077 0);
1070 GNUNET_SERVICE_client_continue (client); 1078 GNUNET_SERVICE_client_continue (client);
@@ -1153,6 +1161,7 @@ handle_get_zero_anonymity (void *cls,
1153 * @param type type of the content 1161 * @param type type of the content
1154 * @param priority priority of the content 1162 * @param priority priority of the content
1155 * @param anonymity anonymity-level for the content 1163 * @param anonymity anonymity-level for the content
1164 * @param replication replication-level for the content
1156 * @param expiration expiration time for the content 1165 * @param expiration expiration time for the content
1157 * @param uid unique identifier for the datum 1166 * @param uid unique identifier for the datum
1158 * @return #GNUNET_OK to keep the item 1167 * @return #GNUNET_OK to keep the item
@@ -1166,6 +1175,7 @@ remove_callback (void *cls,
1166 enum GNUNET_BLOCK_Type type, 1175 enum GNUNET_BLOCK_Type type,
1167 uint32_t priority, 1176 uint32_t priority,
1168 uint32_t anonymity, 1177 uint32_t anonymity,
1178 uint32_t replication,
1169 struct GNUNET_TIME_Absolute expiration, 1179 struct GNUNET_TIME_Absolute expiration,
1170 uint64_t uid) 1180 uint64_t uid)
1171{ 1181{