-#if WAIT_FOR_HELLO
-/**
- * Function called after GNUNET_CORE_connect has succeeded
- * (or failed for good). Note that the private key of the
- * peer is intentionally not exposed here; if you need it,
- * your process should try to read the private key file
- * directly (which should work if you are authorized...).
- *
- * @param cls closure
- * @param server handle to the server, NULL if we failed
- * @param my_identity ID of this peer, NULL if we failed
- * @param publicKey public key of this peer, NULL if we failed
- */
-static void
-testing_init (void *cls,
- struct GNUNET_CORE_Handle *server,
- const struct GNUNET_PeerIdentity *my_identity,
- const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *publicKey)
-{
- struct GNUNET_TESTING_Daemon *d = cls;
-
- GNUNET_assert (d->phase == SP_START_CORE);
- d->phase = SP_GET_HELLO;
-
- if (server == NULL)
- {
- d->server = NULL;
- if (GNUNET_YES == d->dead)
- GNUNET_TESTING_daemon_stop (d,
- GNUNET_TIME_absolute_get_remaining
- (d->max_timeout), d->dead_cb,
- d->dead_cb_cls, GNUNET_YES, GNUNET_NO);
- else if (NULL != d->cb)
- d->cb (d->cb_cls, NULL, d->cfg, d,
- _("Failed to connect to core service\n"));
- return;
- }
-#if DEBUG_TESTING
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Successfully started peer `%4s'.\n", GNUNET_i2s (my_identity));
-#endif
- d->id = *my_identity; /* FIXME: shouldn't we already have this from reading the hostkey file? */
- if (d->shortname == NULL)
- d->shortname = strdup (GNUNET_i2s (my_identity));
- d->server = server;
- d->running = GNUNET_YES;
-
- if (GNUNET_NO == d->running)
- {
-#if DEBUG_TESTING
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Peer is dead (d->running == GNUNET_NO)\n");
-#endif
- return;
- }
-#if DEBUG_TESTING
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Successfully started peer `%4s', connecting to transport service.\n",
- GNUNET_i2s (my_identity));
-#endif
-
- d->th = GNUNET_TRANSPORT_connect (d->cfg, &d->id, d, NULL, NULL, NULL);
- if (d->th == NULL)
- {
- if (GNUNET_YES == d->dead)
- GNUNET_TESTING_daemon_stop (d,
- GNUNET_TIME_absolute_get_remaining
- (d->max_timeout), d->dead_cb,
- d->dead_cb_cls, GNUNET_YES, GNUNET_NO);
- else if (NULL != d->cb)
- d->cb (d->cb_cls, &d->id, d->cfg, d,
- _("Failed to connect to transport service!\n"));
- return;
- }
-#if DEBUG_TESTING
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Connected to transport service `%s', getting HELLO\n",
- GNUNET_i2s (my_identity));
-#endif
-
- GNUNET_TRANSPORT_get_hello (d->th, &process_hello, d);
- /* wait some more */
- if (d->task != GNUNET_SCHEDULER_NO_TASK)
- GNUNET_SCHEDULER_cancel (d->task);
- d->task
- = GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_EXEC_WAIT,
- &start_fsm, d);
-}
-#endif
-
-#if !WAIT_FOR_HELLO