diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-03-04 12:46:38 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-03-04 12:46:38 +0000 |
commit | 2a16fa8a3584bc001b757885449bc189e2cea1e3 (patch) | |
tree | 9e614692f3287da0b82e648dbf03bb14d3e9a9e5 /src/fs/gnunet-service-fs_push.c | |
parent | e44d71c3f344950b0ce773afc9868be495f29af7 (diff) | |
download | gnunet-2a16fa8a3584bc001b757885449bc189e2cea1e3.tar.gz gnunet-2a16fa8a3584bc001b757885449bc189e2cea1e3.zip |
fixes
Diffstat (limited to 'src/fs/gnunet-service-fs_push.c')
-rw-r--r-- | src/fs/gnunet-service-fs_push.c | 34 |
1 files changed, 24 insertions, 10 deletions
diff --git a/src/fs/gnunet-service-fs_push.c b/src/fs/gnunet-service-fs_push.c index 2180a520d..0c67000d0 100644 --- a/src/fs/gnunet-service-fs_push.c +++ b/src/fs/gnunet-service-fs_push.c | |||
@@ -25,8 +25,22 @@ | |||
25 | * @author Christian Grothoff | 25 | * @author Christian Grothoff |
26 | */ | 26 | */ |
27 | #include "platform.h" | 27 | #include "platform.h" |
28 | #include "gnunet-service-fs.h" | ||
29 | #include "gnunet-service-fs_cp.h" | ||
30 | #include "gnunet-service-fs_indexing.h" | ||
28 | #include "gnunet-service-fs_push.h" | 31 | #include "gnunet-service-fs_push.h" |
29 | 32 | ||
33 | |||
34 | /** | ||
35 | * How long must content remain valid for us to consider it for migration? | ||
36 | * If content will expire too soon, there is clearly no point in pushing | ||
37 | * it to other peers. This value gives the threshold for migration. Note | ||
38 | * that if this value is increased, the migration testcase may need to be | ||
39 | * adjusted as well (especially the CONTENT_LIFETIME in fs_test_lib.c). | ||
40 | */ | ||
41 | #define MIN_MIGRATION_CONTENT_LIFETIME GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 30) | ||
42 | |||
43 | |||
30 | /** | 44 | /** |
31 | * Block that is ready for migration to other peers. Actual data is at the end of the block. | 45 | * Block that is ready for migration to other peers. Actual data is at the end of the block. |
32 | */ | 46 | */ |
@@ -234,7 +248,7 @@ transmit_content (struct MigrationReadyPeer *peer, | |||
234 | struct GSF_PeerPerformanceData *ppd; | 248 | struct GSF_PeerPerformanceData *ppd; |
235 | int ret; | 249 | int ret; |
236 | 250 | ||
237 | ppd = GSF_get_peer_performance_data (peer->peer); | 251 | ppd = GSF_get_peer_performance_data_ (peer->peer); |
238 | GNUNET_assert (NULL == peer->th); | 252 | GNUNET_assert (NULL == peer->th); |
239 | msize = sizeof (struct PutMessage) + block->size; | 253 | msize = sizeof (struct PutMessage) + block->size; |
240 | msg = GNUNET_malloc (msize); | 254 | msg = GNUNET_malloc (msize); |
@@ -310,12 +324,12 @@ score_content (struct MigrationReadyPeer *peer, | |||
310 | struct GNUNET_PeerIdentity id; | 324 | struct GNUNET_PeerIdentity id; |
311 | uint32_t dist; | 325 | uint32_t dist; |
312 | 326 | ||
313 | ppd = GSF_get_peer_performance_data (peer->peer); | 327 | ppd = GSF_get_peer_performance_data_ (peer->peer); |
314 | for (i=0;i<MIGRATION_LIST_SIZE;i++) | 328 | for (i=0;i<MIGRATION_LIST_SIZE;i++) |
315 | if (mb->target_list[i] == ppd->pid) | 329 | if (block->target_list[i] == ppd->pid) |
316 | return -1; | 330 | return -1; |
317 | GSF_connected_peer_get_identity (peer->peer, | 331 | GNUNET_PEER_resolve (ppd->pid, |
318 | &id); | 332 | &id); |
319 | dist = GNUNET_CRYPTO_hash_distance_u32 (&block->query, | 333 | dist = GNUNET_CRYPTO_hash_distance_u32 (&block->query, |
320 | &id.hashPubKey); | 334 | &id.hashPubKey); |
321 | /* closer distance, higher score: */ | 335 | /* closer distance, higher score: */ |
@@ -347,14 +361,14 @@ find_content (struct MigrationReadyPeer *mrp) | |||
347 | GNUNET_assert (NULL == mrp->th); | 361 | GNUNET_assert (NULL == mrp->th); |
348 | best = NULL; | 362 | best = NULL; |
349 | best_score = -1; | 363 | best_score = -1; |
350 | pos = mig_qe; | 364 | pos = mig_head; |
351 | while (NULL != pos) | 365 | while (NULL != pos) |
352 | { | 366 | { |
353 | score = score_content (mrp, pos); | 367 | score = score_content (mrp, pos); |
354 | if (score > best_score) | 368 | if (score > best_score) |
355 | { | 369 | { |
356 | best_score = score; | 370 | best_score = score; |
357 | best = mrp; | 371 | best = pos; |
358 | } | 372 | } |
359 | pos = pos->next; | 373 | pos = pos->next; |
360 | } | 374 | } |
@@ -365,14 +379,14 @@ find_content (struct MigrationReadyPeer *mrp) | |||
365 | queue is full, purge most-forwarded | 379 | queue is full, purge most-forwarded |
366 | block from queue to make room for more */ | 380 | block from queue to make room for more */ |
367 | score = 0; | 381 | score = 0; |
368 | pos = mig_qe; | 382 | pos = mig_head; |
369 | while (NULL != pos) | 383 | while (NULL != pos) |
370 | { | 384 | { |
371 | score = count_targets (pos); | 385 | score = count_targets (pos); |
372 | if (score >= best_score) | 386 | if (score >= best_score) |
373 | { | 387 | { |
374 | best_score = score; | 388 | best_score = score; |
375 | best = mrp; | 389 | best = pos; |
376 | } | 390 | } |
377 | pos = pos->next; | 391 | pos = pos->next; |
378 | } | 392 | } |
@@ -381,7 +395,7 @@ find_content (struct MigrationReadyPeer *mrp) | |||
381 | consider_gathering (); | 395 | consider_gathering (); |
382 | return; | 396 | return; |
383 | } | 397 | } |
384 | transmit_content (peer, best); | 398 | transmit_content (mrp, best); |
385 | } | 399 | } |
386 | 400 | ||
387 | 401 | ||