- agc = 2;
- hello = GNUNET_HELLO_create (&pkey, &address_generator, &agc);
- GNUNET_assert (hello != NULL);
- GNUNET_PEERINFO_add_peer (cfg, sched, &pid, hello);
- GNUNET_PEERINFO_for_all (cfg,
- sched,
- NULL,
- 0,
- GNUNET_TIME_relative_multiply
- (GNUNET_TIME_UNIT_SECONDS, 15), &process, cls);
- GNUNET_free (hello);
+ h2 = GNUNET_HELLO_create (&pkey, &address_generator, &agc);
+ GNUNET_PEERINFO_add_peer (h, h2, NULL, NULL);
+ GNUNET_free (h2);
+
+}
+
+
+static void
+process (void *cls, const struct GNUNET_PeerIdentity *peer,
+ const struct GNUNET_HELLO_Message *hello, const char *err_msg)
+{
+ int *ok = cls;
+ unsigned int agc;
+
+ if (err_msg != NULL)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ _("Error in communication with PEERINFO service\n"));
+ }
+
+ if (peer == NULL)
+ {
+ ic = NULL;
+ if ((3 == *ok) && (retries < 50))
+ {
+ /* try again */
+ retries++;
+ add_peer ();
+ ic = GNUNET_PEERINFO_iterate (h, NULL,
+ GNUNET_TIME_relative_multiply
+ (GNUNET_TIME_UNIT_SECONDS, 15), &process,
+ cls);
+ return;
+ }
+ GNUNET_assert (peer == NULL);
+ GNUNET_assert (2 == *ok);
+ GNUNET_PEERINFO_disconnect (h);
+ h = NULL;
+ *ok = 0;
+ return;
+ }
+ if (hello != NULL)
+ {
+ GNUNET_assert (3 == *ok);
+ agc = 3;
+ GNUNET_HELLO_iterate_addresses (hello, GNUNET_NO, &check_it, &agc);
+ GNUNET_assert (agc == 0);
+ *ok = 2;
+ }
+}
+
+
+static void
+run (void *cls, char *const *args, const char *cfgfile,
+ const struct GNUNET_CONFIGURATION_Handle *c)
+{
+ cfg = c;
+ h = GNUNET_PEERINFO_connect (cfg);
+ GNUNET_assert (h != NULL);
+ add_peer ();
+ ic = GNUNET_PEERINFO_iterate (h, NULL,
+ GNUNET_TIME_relative_multiply
+ (GNUNET_TIME_UNIT_SECONDS, 15), &process, cls);