+ if ( (NULL != pr->gh) &&
+ (0 != pr->replies_seen_count) )
+ GNUNET_DHT_get_filter_known_results (pr->gh,
+ pr->replies_seen_count,
+ pr->replies_seen);
+}
+
+
+/**
+ * Function called with a reply from the cadet.
+ *
+ * @param cls the pending request struct
+ * @param type type of the block, ANY on error
+ * @param expiration expiration time for the block
+ * @param data_size number of bytes in @a data, 0 on error
+ * @param data reply block data, NULL on error
+ */
+static void
+cadet_reply_proc (void *cls,
+ enum GNUNET_BLOCK_Type type,
+ struct GNUNET_TIME_Absolute expiration,
+ size_t data_size,
+ const void *data)
+{
+ struct GSF_PendingRequest *pr = cls;
+ struct ProcessReplyClosure prq;
+ struct GNUNET_HashCode query;
+
+ pr->cadet_request = NULL;
+ if (GNUNET_BLOCK_TYPE_ANY == type)
+ {
+ GNUNET_break (NULL == data);
+ GNUNET_break (0 == data_size);
+ pr->cadet_retry_count++;
+ if (pr->cadet_retry_count >= CADET_RETRY_MAX)
+ return; /* give up on cadet */
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Error retrieiving block via cadet\n");
+ /* retry -- without delay, as this is non-anonymous
+ and cadet/cadet connect will take some time anyway */
+ pr->cadet_request = GSF_cadet_query (pr->public_data.target,
+ &pr->public_data.query,
+ pr->public_data.type,
+ &cadet_reply_proc,
+ pr);
+ return;
+ }
+ if (GNUNET_YES !=
+ GNUNET_BLOCK_get_key (GSF_block_ctx,
+ type,
+ data, data_size, &query))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Failed to derive key for block of type %d\n",
+ (int) type);
+ GNUNET_break_op (0);
+ return;
+ }
+ GNUNET_STATISTICS_update (GSF_stats,
+ gettext_noop ("# Replies received from CADET"), 1,
+ GNUNET_NO);
+ memset (&prq, 0, sizeof (prq));
+ prq.data = data;
+ prq.expiration = expiration;
+ /* do not allow migrated content to live longer than 1 year */
+ prq.expiration = GNUNET_TIME_absolute_min (GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_YEARS),
+ prq.expiration);
+ prq.size = data_size;
+ prq.type = type;
+ prq.eo = GNUNET_BLOCK_EO_NONE;
+ process_reply (&prq, &query, pr);
+}
+
+
+/**
+ * Consider downloading via cadet (if possible)
+ *
+ * @param pr the pending request to process
+ */
+void
+GSF_cadet_lookup_ (struct GSF_PendingRequest *pr)
+{
+ if (0 != pr->public_data.anonymity_level)
+ return;
+ if (0 == pr->public_data.target)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Cannot do cadet-based download, target peer not known\n");
+ return;
+ }
+ if (NULL != pr->cadet_request)
+ return;
+ pr->cadet_request = GSF_cadet_query (pr->public_data.target,
+ &pr->public_data.query,
+ pr->public_data.type,
+ &cadet_reply_proc,
+ pr);