aboutsummaryrefslogtreecommitdiff
path: root/src/dht/gnunet-service-dht_datacache.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/dht/gnunet-service-dht_datacache.c')
-rw-r--r--src/dht/gnunet-service-dht_datacache.c72
1 files changed, 24 insertions, 48 deletions
diff --git a/src/dht/gnunet-service-dht_datacache.c b/src/dht/gnunet-service-dht_datacache.c
index 7eded2152..8645ea069 100644
--- a/src/dht/gnunet-service-dht_datacache.c
+++ b/src/dht/gnunet-service-dht_datacache.c
@@ -158,7 +158,7 @@ struct GetRequestContext
158 * @return #GNUNET_OK to continue iteration, anything else 158 * @return #GNUNET_OK to continue iteration, anything else
159 * to stop iteration. 159 * to stop iteration.
160 */ 160 */
161static int 161static enum GNUNET_GenericReturnValue
162datacache_get_iterator (void *cls, 162datacache_get_iterator (void *cls,
163 const struct GNUNET_HashCode *key, 163 const struct GNUNET_HashCode *key,
164 size_t data_size, 164 size_t data_size,
@@ -170,7 +170,7 @@ datacache_get_iterator (void *cls,
170{ 170{
171 static char non_null; 171 static char non_null;
172 struct GetRequestContext *ctx = cls; 172 struct GetRequestContext *ctx = cls;
173 enum GNUNET_BLOCK_EvaluationResult eval; 173 enum GNUNET_BLOCK_ReplyEvaluationResult eval;
174 174
175 if (0 == GNUNET_TIME_absolute_get_remaining (exp).rel_value_us) 175 if (0 == GNUNET_TIME_absolute_get_remaining (exp).rel_value_us)
176 { 176 {
@@ -182,15 +182,14 @@ datacache_get_iterator (void *cls,
182 data = &non_null; /* point anywhere, but not to NULL */ 182 data = &non_null; /* point anywhere, but not to NULL */
183 183
184 eval 184 eval
185 = GNUNET_BLOCK_evaluate (GDS_block_context, 185 = GNUNET_BLOCK_check_reply (GDS_block_context,
186 type, 186 type,
187 ctx->bg, 187 ctx->bg,
188 GNUNET_BLOCK_EO_LOCAL_SKIP_CRYPTO, 188 key,
189 key, 189 ctx->xquery,
190 ctx->xquery, 190 ctx->xquery_size,
191 ctx->xquery_size, 191 data,
192 data, 192 data_size);
193 data_size);
194 LOG (GNUNET_ERROR_TYPE_DEBUG, 193 LOG (GNUNET_ERROR_TYPE_DEBUG,
195 "Found reply for query %s in datacache, evaluation result is %d\n", 194 "Found reply for query %s in datacache, evaluation result is %d\n",
196 GNUNET_h2s (key), 195 GNUNET_h2s (key),
@@ -198,12 +197,13 @@ datacache_get_iterator (void *cls,
198 ctx->eval = eval; 197 ctx->eval = eval;
199 switch (eval) 198 switch (eval)
200 { 199 {
201 case GNUNET_BLOCK_EVALUATION_OK_MORE: 200 case GNUNET_BLOCK_REPLY_OK_MORE:
202 case GNUNET_BLOCK_EVALUATION_OK_LAST: 201 case GNUNET_BLOCK_REPLY_OK_LAST:
203 /* forward to local clients */ 202 case GNUNET_BLOCK_REPLY_TYPE_NOT_SUPPORTED:
203 /* forward to initiator */
204 GNUNET_STATISTICS_update (GDS_stats, 204 GNUNET_STATISTICS_update (GDS_stats,
205 gettext_noop 205 "# Good RESULTS found in datacache",
206 ("# Good RESULTS found in datacache"), 1, 206 1,
207 GNUNET_NO); 207 GNUNET_NO);
208 ctx->gc (ctx->gc_cls, 208 ctx->gc (ctx->gc_cls,
209 type, 209 type,
@@ -213,51 +213,27 @@ datacache_get_iterator (void *cls,
213 0, NULL, 213 0, NULL,
214 data, data_size); 214 data, data_size);
215 break; 215 break;
216 216 case GNUNET_BLOCK_REPLY_OK_DUPLICATE:
217 case GNUNET_BLOCK_EVALUATION_OK_DUPLICATE:
218 GNUNET_STATISTICS_update (GDS_stats, 217 GNUNET_STATISTICS_update (GDS_stats,
219 gettext_noop ( 218 "# Duplicate RESULTS found in datacache",
220 "# Duplicate RESULTS found in datacache"),
221 1, 219 1,
222 GNUNET_NO); 220 GNUNET_NO);
223 break; 221 break;
224 222 case GNUNET_BLOCK_REPLY_INVALID:
225 case GNUNET_BLOCK_EVALUATION_RESULT_INVALID: 223 /* maybe it expired? */
226 GNUNET_STATISTICS_update (GDS_stats, 224 GNUNET_STATISTICS_update (GDS_stats,
227 gettext_noop ( 225 "# Invalid RESULTS found in datacache",
228 "# Invalid RESULTS found in datacache"),
229 1, 226 1,
230 GNUNET_NO); 227 GNUNET_NO);
231 break; 228 break;
232 229 case GNUNET_BLOCK_REPLY_IRRELEVANT:
233 case GNUNET_BLOCK_EVALUATION_RESULT_IRRELEVANT:
234 GNUNET_STATISTICS_update (GDS_stats, 230 GNUNET_STATISTICS_update (GDS_stats,
235 gettext_noop ( 231 "# Irrelevant RESULTS found in datacache",
236 "# Irrelevant RESULTS found in datacache"),
237 1, 232 1,
238 GNUNET_NO); 233 GNUNET_NO);
239 break; 234 break;
240
241 case GNUNET_BLOCK_EVALUATION_REQUEST_VALID:
242 GNUNET_break (0);
243 break;
244
245 case GNUNET_BLOCK_EVALUATION_REQUEST_INVALID:
246 GNUNET_break_op (0);
247 return GNUNET_SYSERR;
248
249 case GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED:
250 GNUNET_STATISTICS_update (GDS_stats,
251 gettext_noop (
252 "# Unsupported RESULTS found in datacache"),
253 1,
254 GNUNET_NO);
255 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
256 _ ("Unsupported block type (%u) in local response!\n"),
257 type);
258 break;
259 } 235 }
260 return (eval == GNUNET_BLOCK_EVALUATION_OK_LAST) ? GNUNET_NO : GNUNET_OK; 236 return (eval == GNUNET_BLOCK_REPLY_OK_LAST) ? GNUNET_NO : GNUNET_OK;
261} 237}
262 238
263 239