+ if ((connection_count >= target_connection_count) &&
+ (friend_count >= minimum_friend_count))
+ return;
+ if (GNUNET_YES == pos->is_connected)
+ return;
+ if (GNUNET_OK != is_connection_allowed (pos))
+ return;
+ if (GNUNET_TIME_absolute_get_remaining (pos->greylisted_until).rel_value > 0)
+ return;
+ if (GNUNET_YES == pos->is_friend)
+ rem = GREYLIST_AFTER_ATTEMPT_FRIEND;
+ else
+ rem = GREYLIST_AFTER_ATTEMPT;
+ rem = GNUNET_TIME_relative_multiply (rem, connection_count);
+ rem = GNUNET_TIME_relative_divide (rem, target_connection_count);
+ if (pos->connect_attempts > 30)
+ pos->connect_attempts = 30;
+ rem = GNUNET_TIME_relative_multiply (rem, 1 << (++pos->connect_attempts));
+ rem = GNUNET_TIME_relative_max (rem, GREYLIST_AFTER_ATTEMPT_MIN);
+ rem = GNUNET_TIME_relative_min (rem, GREYLIST_AFTER_ATTEMPT_MAX);
+ pos->greylisted_until = GNUNET_TIME_relative_to_absolute (rem);
+ if (pos->greylist_clean_task != GNUNET_SCHEDULER_NO_TASK)
+ GNUNET_SCHEDULER_cancel (pos->greylist_clean_task);
+ pos->greylist_clean_task =
+ GNUNET_SCHEDULER_add_delayed (rem, &remove_from_greylist, pos);
+#if DEBUG_TOPOLOGY
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Asking to connect to `%s'\n",
+ GNUNET_i2s (&pos->pid));
+#endif
+ GNUNET_STATISTICS_update (stats,
+ gettext_noop ("# connect requests issued to core"),
+ 1, GNUNET_NO);
+ pos->connect_req =
+ GNUNET_CORE_peer_request_connect (handle, &pos->pid,
+ &connect_completed_callback, pos);