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/datastore.h | |
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/datastore.h')
-rw-r--r-- | src/datastore/datastore.h | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/src/datastore/datastore.h b/src/datastore/datastore.h index 9de72f064..5fd360161 100644 --- a/src/datastore/datastore.h +++ b/src/datastore/datastore.h | |||
@@ -119,9 +119,14 @@ struct GetKeyMessage | |||
119 | uint32_t type GNUNET_PACKED; | 119 | uint32_t type GNUNET_PACKED; |
120 | 120 | ||
121 | /** | 121 | /** |
122 | * Offset of the result. | 122 | * UID at which to start the search |
123 | */ | 123 | */ |
124 | uint64_t offset GNUNET_PACKED; | 124 | uint64_t next_uid GNUNET_PACKED; |
125 | |||
126 | /** | ||
127 | * If true return a random result | ||
128 | */ | ||
129 | uint32_t random GNUNET_PACKED; | ||
125 | 130 | ||
126 | /** | 131 | /** |
127 | * Desired key. | 132 | * Desired key. |
@@ -148,9 +153,14 @@ struct GetMessage | |||
148 | uint32_t type GNUNET_PACKED; | 153 | uint32_t type GNUNET_PACKED; |
149 | 154 | ||
150 | /** | 155 | /** |
151 | * Offset of the result. | 156 | * UID at which to start the search |
157 | */ | ||
158 | uint64_t next_uid GNUNET_PACKED; | ||
159 | |||
160 | /** | ||
161 | * If true return a random result | ||
152 | */ | 162 | */ |
153 | uint64_t offset GNUNET_PACKED; | 163 | uint32_t random GNUNET_PACKED; |
154 | 164 | ||
155 | }; | 165 | }; |
156 | 166 | ||
@@ -172,9 +182,9 @@ struct GetZeroAnonymityMessage | |||
172 | uint32_t type GNUNET_PACKED; | 182 | uint32_t type GNUNET_PACKED; |
173 | 183 | ||
174 | /** | 184 | /** |
175 | * Offset of the result. | 185 | * UID at which to start the search |
176 | */ | 186 | */ |
177 | uint64_t offset GNUNET_PACKED; | 187 | uint64_t next_uid GNUNET_PACKED; |
178 | 188 | ||
179 | }; | 189 | }; |
180 | 190 | ||