+ }
+ if (MIGRATION_LIST_SIZE == i)
+ {
+ delete_migration_block (block);
+ ret = GNUNET_YES;
+ }
+ else
+ {
+ ret = GNUNET_NO;
+ }
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Asking for transmission of %u bytes to %s for migration\n",
+ (unsigned int) msize,
+ GNUNET_i2s (GSF_connected_peer_get_identity2_(peer->peer)));
+ peer->th = GSF_peer_transmit_ (peer->peer,
+ GNUNET_NO, 0 /* priority */ ,
+ GNUNET_TIME_UNIT_FOREVER_REL,
+ msize,
+ &transmit_message, peer);
+ return ret;
+}
+
+
+/**
+ * Count the number of peers this block has
+ * already been forwarded to.
+ *
+ * @param block the block
+ * @return number of times block was forwarded
+ */
+static unsigned int
+count_targets (struct MigrationReadyBlock *block)
+{
+ unsigned int i;
+
+ for (i = 0; i < MIGRATION_LIST_SIZE; i++)
+ if (block->target_list[i] == 0)
+ return i;
+ return i;
+}
+
+
+/**
+ * Check if sending this block to this peer would
+ * be a good idea.
+ *
+ * @param peer target peer
+ * @param block the block
+ * @return score (>= 0: feasible, negative: infeasible)
+ */
+static long
+score_content (struct MigrationReadyPeer *peer,
+ struct MigrationReadyBlock *block)
+{
+ unsigned int i;
+ struct GSF_PeerPerformanceData *ppd;
+ struct GNUNET_PeerIdentity id;
+ struct GNUNET_HashCode hc;
+ uint32_t dist;
+
+ ppd = GSF_get_peer_performance_data_ (peer->peer);
+ for (i = 0; i < MIGRATION_LIST_SIZE; i++)
+ if (block->target_list[i] == ppd->pid)
+ return -1;
+ GNUNET_assert (0 != ppd->pid);
+ GNUNET_PEER_resolve (ppd->pid, &id);
+ GNUNET_CRYPTO_hash (&id, sizeof (struct GNUNET_PeerIdentity), &hc);
+ dist = GNUNET_CRYPTO_hash_distance_u32 (&block->query, &hc);
+ /* closer distance, higher score: */
+ return UINT32_MAX - dist;
+}
+
+
+/**
+ * If the migration task is not currently running, consider
+ * (re)scheduling it with the appropriate delay.
+ */
+static void
+consider_gathering (void);