+ GNUNET_TRANSPORT_offer_hello_cancel (ci->oh);
+ ci->oh = NULL;
+ }
+ GNUNET_free (ci);
+ return GNUNET_YES;
+}
+
+
+/**
+ * Consider if we want to connect to a given peer, and if so
+ * let ATS know. If applicable, the HELLO is offered to the
+ * TRANSPORT service.
+ *
+ * @param pid peer to consider connectivity requirements for
+ * @param h a HELLO message, or NULL
+ */
+static void
+try_connect (const struct GNUNET_PeerIdentity *pid,
+ const struct GNUNET_MessageHeader *h)
+{
+ int bucket;
+ struct GNUNET_HashCode pid_hash;
+ struct ConnectInfo *ci;
+ uint32_t strength;
+
+ GNUNET_CRYPTO_hash (pid,
+ sizeof (struct GNUNET_PeerIdentity),
+ &pid_hash);
+ bucket = find_bucket (&pid_hash);
+ if (bucket < 0)
+ return; /* self? */
+ ci = GNUNET_CONTAINER_multipeermap_get (all_desired_peers,
+ pid);
+
+ if (k_buckets[bucket].peers_size < bucket_size)
+ strength = (bucket_size - k_buckets[bucket].peers_size) * bucket;
+ else
+ strength = bucket; /* minimum value of connectivity */
+ if (GNUNET_YES ==
+ GNUNET_CONTAINER_multipeermap_contains (all_connected_peers,
+ pid))
+ strength *= 2; /* double for connected peers */
+ else if (k_buckets[bucket].peers_size > bucket_size)
+ strength = 0; /* bucket full, we really do not care about more */
+
+ if ( (0 == strength) &&
+ (NULL != ci) )
+ {
+ /* release request */
+ GNUNET_assert (GNUNET_YES ==
+ free_connect_info (NULL,
+ pid,
+ ci));