summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <grothoff@gnunet.org>2022-03-12 09:47:03 +0100
committerChristian Grothoff <grothoff@gnunet.org>2022-03-12 09:47:03 +0100
commite99cd96fd96ae03da1f73c0355eea77cf44c8375 (patch)
treeea1724ce430183e1cc5f8ae147af2a1662a9582c
parent51adbc5189c9255a551a35e321c05a8f103b2451 (diff)
-move function to more logical place, no semantic change
-rw-r--r--src/dht/gnunet-service-dht_neighbours.c114
1 files changed, 57 insertions, 57 deletions
diff --git a/src/dht/gnunet-service-dht_neighbours.c b/src/dht/gnunet-service-dht_neighbours.c
index 6d4534f8a..94513983e 100644
--- a/src/dht/gnunet-service-dht_neighbours.c
+++ b/src/dht/gnunet-service-dht_neighbours.c
@@ -2343,63 +2343,6 @@ check_dht_p2p_result (void *cls,
/**
- * Callback function used to extract URIs from a builder.
- * Called when we should consider connecting to a peer.
- *
- * @param cls closure pointing to a `struct GNUNET_PeerIdentity *`
- * @param uri one of the URIs
- */
-void
-GDS_try_connect (void *cls,
- const char *uri)
-{
- const struct GNUNET_PeerIdentity *pid = cls;
- struct GNUNET_HashCode phash;
- int peer_bucket;
- struct PeerBucket *bucket;
-
- if (0 == GNUNET_memcmp (&GDS_my_identity,
- pid))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Got a HELLO for my own PID, ignoring it\n");
- return; /* that's us! */
- }
- GNUNET_CRYPTO_hash (pid,
- sizeof(*pid),
- &phash);
- peer_bucket = find_bucket (&phash);
- GNUNET_assert ( (peer_bucket >= 0) &&
- ((unsigned int) peer_bucket < MAX_BUCKETS));
- bucket = &k_buckets[peer_bucket];
- if (bucket->peers_size >= bucket_size)
- return; /* do not care */
- for (struct PeerInfo *pi = bucket->head;
- NULL != pi;
- pi = pi->next)
- if (0 ==
- GNUNET_memcmp (&pi->id,
- pid))
- {
- /* already connected */
- /* TODO: maybe consider 'uri' anyway as an additional
- alternative address??? */
- return;
- }
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Discovered peer %s at %s suitable for bucket %d (%u/%u), trying to connect\n",
- GNUNET_i2s (pid),
- uri,
- peer_bucket,
- bucket->peers_size,
- bucket_size);
- /* new peer that we like! */
- GDS_u_try_connect (pid,
- uri);
-}
-
-
-/**
* Core handler for p2p result messages.
*
* @param cls closure
@@ -2655,6 +2598,63 @@ GDS_u_receive (void *cls,
/**
+ * Callback function used to extract URIs from a builder.
+ * Called when we should consider connecting to a peer.
+ *
+ * @param cls closure pointing to a `struct GNUNET_PeerIdentity *`
+ * @param uri one of the URIs
+ */
+void
+GDS_try_connect (void *cls,
+ const char *uri)
+{
+ const struct GNUNET_PeerIdentity *pid = cls;
+ struct GNUNET_HashCode phash;
+ int peer_bucket;
+ struct PeerBucket *bucket;
+
+ if (0 == GNUNET_memcmp (&GDS_my_identity,
+ pid))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Got a HELLO for my own PID, ignoring it\n");
+ return; /* that's us! */
+ }
+ GNUNET_CRYPTO_hash (pid,
+ sizeof(*pid),
+ &phash);
+ peer_bucket = find_bucket (&phash);
+ GNUNET_assert ( (peer_bucket >= 0) &&
+ ((unsigned int) peer_bucket < MAX_BUCKETS));
+ bucket = &k_buckets[peer_bucket];
+ if (bucket->peers_size >= bucket_size)
+ return; /* do not care */
+ for (struct PeerInfo *pi = bucket->head;
+ NULL != pi;
+ pi = pi->next)
+ if (0 ==
+ GNUNET_memcmp (&pi->id,
+ pid))
+ {
+ /* already connected */
+ /* TODO: maybe consider 'uri' anyway as an additional
+ alternative address??? */
+ return;
+ }
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Discovered peer %s at %s suitable for bucket %d (%u/%u), trying to connect\n",
+ GNUNET_i2s (pid),
+ uri,
+ peer_bucket,
+ bucket->peers_size,
+ bucket_size);
+ /* new peer that we like! */
+ GDS_u_try_connect (pid,
+ uri);
+}
+
+
+/**
* Send @a msg to all peers in our buckets.
*
* @param msg message to broadcast