diff options
author | David Barksdale <amatus@amat.us> | 2017-03-19 15:55:32 -0500 |
---|---|---|
committer | David Barksdale <amatus@amat.us> | 2017-03-19 17:38:36 -0500 |
commit | 2dde0202c5590eeb051c1346f2b66293d83b87ce (patch) | |
tree | 7997191912ee4c70959934d6c9783a0c9f450fec /src/datastore/gnunet-service-datastore.c | |
parent | d17d833dfd93a81f3540d472d1be4dfb7e9cbd03 (diff) | |
download | gnunet-2dde0202c5590eeb051c1346f2b66293d83b87ce.tar.gz gnunet-2dde0202c5590eeb051c1346f2b66293d83b87ce.zip |
[datastore] Fix #3743
This change adds support for key == NULL to the datastore plugins
and replaces the offset argument with a next_uid and random arguments to
increase performance in the key == NULL case.
With the offset argument a datastore plugin would have to count all
matching keys before fetching the key at the right offset, which would
iterate over the entire database in the case of key == NULL.
The offset argument was used in two ways: to iterate over a set of
matching values and to start iteration at a random matching value. The new API
seperates these into two arguments: if random is true it will return a
random matching value, otherwise next_uid can be set to uid + 1 to return the
next matching value.
The random argument was not added to get_zero_anonymity. This function
is used to periodically insert zero anonymity values into the DHT. I
don't think it's necessary to randomize this.
Diffstat (limited to 'src/datastore/gnunet-service-datastore.c')
-rw-r--r-- | src/datastore/gnunet-service-datastore.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/src/datastore/gnunet-service-datastore.c b/src/datastore/gnunet-service-datastore.c index dabec3d6d..af33c4412 100644 --- a/src/datastore/gnunet-service-datastore.c +++ b/src/datastore/gnunet-service-datastore.c | |||
@@ -984,12 +984,13 @@ handle_put (void *cls, | |||
984 | size, | 984 | size, |
985 | &vhash); | 985 | &vhash); |
986 | plugin->api->get_key (plugin->api->cls, | 986 | plugin->api->get_key (plugin->api->cls, |
987 | 0, | 987 | 0, |
988 | &dm->key, | 988 | false, |
989 | &vhash, | 989 | &dm->key, |
990 | &vhash, | ||
990 | ntohl (dm->type), | 991 | ntohl (dm->type), |
991 | &check_present, | 992 | &check_present, |
992 | pc); | 993 | pc); |
993 | GNUNET_SERVICE_client_continue (client); | 994 | GNUNET_SERVICE_client_continue (client); |
994 | return; | 995 | return; |
995 | } | 996 | } |
@@ -1018,7 +1019,8 @@ handle_get (void *cls, | |||
1018 | 1, | 1019 | 1, |
1019 | GNUNET_NO); | 1020 | GNUNET_NO); |
1020 | plugin->api->get_key (plugin->api->cls, | 1021 | plugin->api->get_key (plugin->api->cls, |
1021 | GNUNET_ntohll (msg->offset), | 1022 | GNUNET_ntohll (msg->next_uid), |
1023 | msg->random, | ||
1022 | NULL, | 1024 | NULL, |
1023 | NULL, | 1025 | NULL, |
1024 | ntohl (msg->type), | 1026 | ntohl (msg->type), |
@@ -1069,7 +1071,8 @@ handle_get_key (void *cls, | |||
1069 | return; | 1071 | return; |
1070 | } | 1072 | } |
1071 | plugin->api->get_key (plugin->api->cls, | 1073 | plugin->api->get_key (plugin->api->cls, |
1072 | GNUNET_ntohll (msg->offset), | 1074 | GNUNET_ntohll (msg->next_uid), |
1075 | msg->random, | ||
1073 | &msg->key, | 1076 | &msg->key, |
1074 | NULL, | 1077 | NULL, |
1075 | ntohl (msg->type), | 1078 | ntohl (msg->type), |
@@ -1131,7 +1134,7 @@ handle_get_zero_anonymity (void *cls, | |||
1131 | 1, | 1134 | 1, |
1132 | GNUNET_NO); | 1135 | GNUNET_NO); |
1133 | plugin->api->get_zero_anonymity (plugin->api->cls, | 1136 | plugin->api->get_zero_anonymity (plugin->api->cls, |
1134 | GNUNET_ntohll (msg->offset), | 1137 | GNUNET_ntohll (msg->next_uid), |
1135 | type, | 1138 | type, |
1136 | &transmit_item, | 1139 | &transmit_item, |
1137 | client); | 1140 | client); |
@@ -1241,6 +1244,7 @@ handle_remove (void *cls, | |||
1241 | (uint32_t) ntohl (dm->type)); | 1244 | (uint32_t) ntohl (dm->type)); |
1242 | plugin->api->get_key (plugin->api->cls, | 1245 | plugin->api->get_key (plugin->api->cls, |
1243 | 0, | 1246 | 0, |
1247 | false, | ||
1244 | &dm->key, | 1248 | &dm->key, |
1245 | &vhash, | 1249 | &vhash, |
1246 | (enum GNUNET_BLOCK_Type) ntohl (dm->type), | 1250 | (enum GNUNET_BLOCK_Type) ntohl (dm->type), |