- for (i=0;i<total;i++)
- daemons[i] = GNUNET_malloc (sizeof (struct GNUNET_FS_TestDaemon));
- sctx->group = GNUNET_TESTING_daemons_start (sched,
- sctx->cfg,
- total,
- ¬ify_running,
- sctx,
- NULL, NULL,
- NULL);
- sctx->timeout_task = GNUNET_SCHEDULER_add_delayed (sched,
- timeout,
- &start_timeout,
- sctx);
-}
-
-
-struct ConnectContext
-{
- struct GNUNET_SCHEDULER_Handle *sched;
- GNUNET_SCHEDULER_Task cont;
- void *cont_cls;
-};
-
-
-static void
-notify_connection (void *cls,
- const struct GNUNET_PeerIdentity *first,
- const struct GNUNET_PeerIdentity *second,
- const struct GNUNET_CONFIGURATION_Handle *first_cfg,
- const struct GNUNET_CONFIGURATION_Handle *second_cfg,
- struct GNUNET_TESTING_Daemon *first_daemon,
- struct GNUNET_TESTING_Daemon *second_daemon,
- const char *emsg)
-{
- struct ConnectContext *cc = cls;
-
- if (emsg != NULL)
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- _("Failed to connect peers: %s\n"),
- emsg);
- GNUNET_SCHEDULER_add_continuation (cc->sched,
- cc->cont,
- cc->cont_cls,
- (emsg != NULL)
- ? GNUNET_SCHEDULER_REASON_TIMEOUT
- : GNUNET_SCHEDULER_REASON_PREREQ_DONE);
- GNUNET_free (cc);
+ po->fs = ca_result;
+
+ bo.expiration_time = GNUNET_TIME_relative_to_absolute (CONTENT_LIFETIME);
+ bo.anonymity_level = po->anonymity;
+ bo.content_priority = 42;
+ bo.replication_level = 1;
+ if (GNUNET_YES == po->do_index)
+ {
+ po->publish_tmp_file = GNUNET_DISK_mktemp ("fs-test-publish-index");
+ GNUNET_assert (po->publish_tmp_file != NULL);
+ fh = GNUNET_DISK_file_open (po->publish_tmp_file,
+ GNUNET_DISK_OPEN_WRITE |
+ GNUNET_DISK_OPEN_CREATE,
+ GNUNET_DISK_PERM_USER_READ |
+ GNUNET_DISK_PERM_USER_WRITE);
+ GNUNET_assert (NULL != fh);
+ off = 0;
+ while (off < po->size)
+ {
+ bsize = GNUNET_MIN (sizeof (buf), po->size - off);
+ emsg = NULL;
+ GNUNET_assert (bsize == file_generator (&po->publish_seed, off, bsize, buf, &em));
+ GNUNET_assert (em == NULL);
+ GNUNET_assert (bsize == GNUNET_DISK_file_write (fh, buf, bsize));
+ off += bsize;
+ }
+ GNUNET_assert (GNUNET_OK == GNUNET_DISK_file_close (fh));
+ fi = GNUNET_FS_file_information_create_from_file (po->fs, po,
+ po->publish_tmp_file,
+ NULL, NULL, po->do_index,
+ &bo);
+ GNUNET_assert (NULL != fi);
+ }
+ else
+ {
+ fi = GNUNET_FS_file_information_create_from_reader (po->fs, po,
+ po->size,
+ &file_generator, &po->publish_seed,
+ NULL, NULL,
+ po->do_index, &bo);
+ GNUNET_assert (NULL != fi);
+ }
+ po->publish_context =
+ GNUNET_FS_publish_start (po->fs, fi, NULL, NULL, NULL,
+ GNUNET_FS_PUBLISH_OPTION_NONE);