diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-09-27 13:23:19 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-09-27 13:23:19 +0000 |
commit | 087fa2688ea9aa9fe9e8b0b3bf4a59e1479b1dbe (patch) | |
tree | dce5c0dd40106b1ce88442094f9a6a41ec1cdc77 /src/dht/gnunet-service-dht_datacache.c | |
parent | 6ac27138723d4609749e38f84e0a06c96610a735 (diff) | |
download | gnunet-087fa2688ea9aa9fe9e8b0b3bf4a59e1479b1dbe.tar.gz gnunet-087fa2688ea9aa9fe9e8b0b3bf4a59e1479b1dbe.zip |
do not route requests that were perfectly satisfied
Diffstat (limited to 'src/dht/gnunet-service-dht_datacache.c')
-rw-r--r-- | src/dht/gnunet-service-dht_datacache.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/dht/gnunet-service-dht_datacache.c b/src/dht/gnunet-service-dht_datacache.c index fc1983419..4ac0a815b 100644 --- a/src/dht/gnunet-service-dht_datacache.c +++ b/src/dht/gnunet-service-dht_datacache.c | |||
@@ -142,6 +142,10 @@ struct GetRequestContext | |||
142 | */ | 142 | */ |
143 | uint32_t reply_bf_mutator; | 143 | uint32_t reply_bf_mutator; |
144 | 144 | ||
145 | /** | ||
146 | * Return value to give back. | ||
147 | */ | ||
148 | enum GNUNET_BLOCK_EvaluationResult eval; | ||
145 | }; | 149 | }; |
146 | 150 | ||
147 | 151 | ||
@@ -192,6 +196,7 @@ datacache_get_iterator (void *cls, struct GNUNET_TIME_Absolute exp, | |||
192 | ctx->xquery_size, | 196 | ctx->xquery_size, |
193 | rdata, | 197 | rdata, |
194 | rdata_size); | 198 | rdata_size); |
199 | ctx->eval = eval; | ||
195 | switch (eval) | 200 | switch (eval) |
196 | { | 201 | { |
197 | case GNUNET_BLOCK_EVALUATION_OK_LAST: | 202 | case GNUNET_BLOCK_EVALUATION_OK_LAST: |
@@ -223,7 +228,7 @@ datacache_get_iterator (void *cls, struct GNUNET_TIME_Absolute exp, | |||
223 | type); | 228 | type); |
224 | break; | 229 | break; |
225 | } | 230 | } |
226 | return GNUNET_OK; | 231 | return (eval == GNUNET_BLOCK_EVALUATION_OK_LAST) ? GNUNET_NO : GNUNET_OK; |
227 | } | 232 | } |
228 | 233 | ||
229 | 234 | ||
@@ -236,8 +241,9 @@ datacache_get_iterator (void *cls, struct GNUNET_TIME_Absolute exp, | |||
236 | * @param xquery_size number of bytes in xquery | 241 | * @param xquery_size number of bytes in xquery |
237 | * @param reply_bf where the reply bf is (to be) stored, possibly updated, can be NULL | 242 | * @param reply_bf where the reply bf is (to be) stored, possibly updated, can be NULL |
238 | * @param reply_bf_mutator mutation value for reply_bf | 243 | * @param reply_bf_mutator mutation value for reply_bf |
244 | * @return evaluation result for the local replies | ||
239 | */ | 245 | */ |
240 | void | 246 | enum GNUNET_BLOCK_EvaluationResult |
241 | GDS_DATACACHE_handle_get (const GNUNET_HashCode *key, | 247 | GDS_DATACACHE_handle_get (const GNUNET_HashCode *key, |
242 | enum GNUNET_BLOCK_Type type, | 248 | enum GNUNET_BLOCK_Type type, |
243 | const void *xquery, | 249 | const void *xquery, |
@@ -248,7 +254,8 @@ GDS_DATACACHE_handle_get (const GNUNET_HashCode *key, | |||
248 | struct GetRequestContext ctx; | 254 | struct GetRequestContext ctx; |
249 | 255 | ||
250 | if (datacache == NULL) | 256 | if (datacache == NULL) |
251 | return; | 257 | return GNUNET_BLOCK_EVALUATION_REQUEST_VALID; |
258 | ctx.eval = GNUNET_BLOCK_EVALUATION_REQUEST_VALID; | ||
252 | ctx.key = *key; | 259 | ctx.key = *key; |
253 | ctx.xquery = xquery; | 260 | ctx.xquery = xquery; |
254 | ctx.xquery_size = xquery_size; | 261 | ctx.xquery_size = xquery_size; |
@@ -256,6 +263,7 @@ GDS_DATACACHE_handle_get (const GNUNET_HashCode *key, | |||
256 | ctx.reply_bf_mutator = reply_bf_mutator; | 263 | ctx.reply_bf_mutator = reply_bf_mutator; |
257 | (void) GNUNET_DATACACHE_get (datacache, key, type, | 264 | (void) GNUNET_DATACACHE_get (datacache, key, type, |
258 | &datacache_get_iterator, &ctx); | 265 | &datacache_get_iterator, &ctx); |
266 | return ctx.eval; | ||
259 | } | 267 | } |
260 | 268 | ||
261 | 269 | ||