aboutsummaryrefslogtreecommitdiff
path: root/src/dht/gnunet-service-dht.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/dht/gnunet-service-dht.c')
-rw-r--r--src/dht/gnunet-service-dht.c59
1 files changed, 29 insertions, 30 deletions
diff --git a/src/dht/gnunet-service-dht.c b/src/dht/gnunet-service-dht.c
index 9e56e99b2..968f9a32f 100644
--- a/src/dht/gnunet-service-dht.c
+++ b/src/dht/gnunet-service-dht.c
@@ -285,19 +285,21 @@ struct PeerInfo
285 struct GNUNET_CORE_InformationRequestContext *info_ctx; 285 struct GNUNET_CORE_InformationRequestContext *info_ctx;
286 286
287 /** 287 /**
288 * What is the average latency for replies received? 288 * What is the identity of the peer?
289 */ 289 */
290 struct GNUNET_TIME_Relative latency; 290 struct GNUNET_PeerIdentity id;
291 291
292#if 0
292 /** 293 /**
293 * What is the identity of the peer? 294 * What is the average latency for replies received?
294 */ 295 */
295 struct GNUNET_PeerIdentity id; 296 struct GNUNET_TIME_Relative latency;
296 297
297 /** 298 /**
298 * Transport level distance to peer. 299 * Transport level distance to peer.
299 */ 300 */
300 unsigned int distance; 301 unsigned int distance;
302#endif
301 303
302 /** 304 /**
303 * Holds matching bits from peer to current target, 305 * Holds matching bits from peer to current target,
@@ -1380,7 +1382,6 @@ update_core_preference (void *cls,
1380 * 1382 *
1381 * @param cls closure 1383 * @param cls closure
1382 * @param peer identifies the peer 1384 * @param peer identifies the peer
1383 * @param bpm_in set to the current bandwidth limit (receiving) for this peer
1384 * @param bpm_out set to the current bandwidth limit (sending) for this peer 1385 * @param bpm_out set to the current bandwidth limit (sending) for this peer
1385 * @param amount set to the amount that was actually reserved or unreserved; 1386 * @param amount set to the amount that was actually reserved or unreserved;
1386 * either the full requested amount or zero (no partial reservations) 1387 * either the full requested amount or zero (no partial reservations)
@@ -1389,7 +1390,6 @@ update_core_preference (void *cls,
1389static void 1390static void
1390update_core_preference_finish (void *cls, 1391update_core_preference_finish (void *cls,
1391 const struct GNUNET_PeerIdentity * peer, 1392 const struct GNUNET_PeerIdentity * peer,
1392 struct GNUNET_BANDWIDTH_Value32NBO bpm_in,
1393 struct GNUNET_BANDWIDTH_Value32NBO bpm_out, 1393 struct GNUNET_BANDWIDTH_Value32NBO bpm_out,
1394 int amount, uint64_t preference) 1394 int amount, uint64_t preference)
1395{ 1395{
@@ -1416,7 +1416,7 @@ update_core_preference (void *cls,
1416 matching = 63; 1416 matching = 63;
1417 } 1417 }
1418 preference = 1LL << matching; 1418 preference = 1LL << matching;
1419 peer->info_ctx = GNUNET_CORE_peer_change_preference (cfg, 1419 peer->info_ctx = GNUNET_CORE_peer_change_preference (coreAPI,
1420 &peer->id, 1420 &peer->id,
1421 GNUNET_TIME_relative_get_forever(), 1421 GNUNET_TIME_relative_get_forever(),
1422 GNUNET_BANDWIDTH_value_init (UINT32_MAX), 1422 GNUNET_BANDWIDTH_value_init (UINT32_MAX),
@@ -1433,23 +1433,23 @@ update_core_preference (void *cls,
1433 * @param peer GNUNET_PeerIdentity of the peer to add 1433 * @param peer GNUNET_PeerIdentity of the peer to add
1434 * @param bucket the already figured out bucket to add 1434 * @param bucket the already figured out bucket to add
1435 * the peer to 1435 * the peer to
1436 * @param latency the core reported latency of this peer 1436 * @param atsi performance information
1437 * @param distance the transport level distance to this peer
1438 * 1437 *
1439 * @return the newly added PeerInfo 1438 * @return the newly added PeerInfo
1440 */ 1439 */
1441static struct PeerInfo * 1440static struct PeerInfo *
1442add_peer(const struct GNUNET_PeerIdentity *peer, 1441add_peer(const struct GNUNET_PeerIdentity *peer,
1443 unsigned int bucket, 1442 unsigned int bucket,
1444 struct GNUNET_TIME_Relative latency, 1443 const struct GNUNET_TRANSPORT_ATS_Information *atsi)
1445 unsigned int distance)
1446{ 1444{
1447 struct PeerInfo *new_peer; 1445 struct PeerInfo *new_peer;
1448 GNUNET_assert(bucket < MAX_BUCKETS); 1446 GNUNET_assert(bucket < MAX_BUCKETS);
1449 GNUNET_assert(peer != NULL); 1447 GNUNET_assert(peer != NULL);
1450 new_peer = GNUNET_malloc(sizeof(struct PeerInfo)); 1448 new_peer = GNUNET_malloc(sizeof(struct PeerInfo));
1449#if 0
1451 new_peer->latency = latency; 1450 new_peer->latency = latency;
1452 new_peer->distance = distance; 1451 new_peer->distance = distance;
1452#endif
1453 1453
1454 memcpy(&new_peer->id, peer, sizeof(struct GNUNET_PeerIdentity)); 1454 memcpy(&new_peer->id, peer, sizeof(struct GNUNET_PeerIdentity));
1455 1455
@@ -1769,8 +1769,7 @@ void schedule_ping_messages()
1769static struct PeerInfo * 1769static struct PeerInfo *
1770try_add_peer(const struct GNUNET_PeerIdentity *peer, 1770try_add_peer(const struct GNUNET_PeerIdentity *peer,
1771 unsigned int bucket, 1771 unsigned int bucket,
1772 struct GNUNET_TIME_Relative latency, 1772 const struct GNUNET_TRANSPORT_ATS_Information *atsi)
1773 unsigned int distance)
1774{ 1773{
1775 int peer_bucket; 1774 int peer_bucket;
1776 struct PeerInfo *new_peer; 1775 struct PeerInfo *new_peer;
@@ -1781,7 +1780,7 @@ try_add_peer(const struct GNUNET_PeerIdentity *peer,
1781 peer_bucket = find_current_bucket(&peer->hashPubKey); 1780 peer_bucket = find_current_bucket(&peer->hashPubKey);
1782 1781
1783 GNUNET_assert(peer_bucket >= lowest_bucket); 1782 GNUNET_assert(peer_bucket >= lowest_bucket);
1784 new_peer = add_peer(peer, peer_bucket, latency, distance); 1783 new_peer = add_peer(peer, peer_bucket, atsi);
1785 1784
1786 if ((k_buckets[lowest_bucket].peers_size) >= bucket_size) 1785 if ((k_buckets[lowest_bucket].peers_size) >= bucket_size)
1787 enable_next_bucket(); 1786 enable_next_bucket();
@@ -1991,7 +1990,8 @@ static int route_result_message(struct GNUNET_MessageHeader *msg,
1991 { 1990 {
1992 increment_stats(STAT_HELLOS_PROVIDED); 1991 increment_stats(STAT_HELLOS_PROVIDED);
1993 GNUNET_TRANSPORT_offer_hello(transport_handle, hello_msg); 1992 GNUNET_TRANSPORT_offer_hello(transport_handle, hello_msg);
1994 GNUNET_CORE_peer_request_connect(cfg, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 5), &new_peer, NULL, NULL); 1993 GNUNET_CORE_peer_request_connect(coreAPI,
1994 GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 5), &new_peer, NULL, NULL);
1995 } 1995 }
1996 } 1996 }
1997 } 1997 }
@@ -2420,7 +2420,8 @@ handle_dht_find_peer (const struct GNUNET_MessageHeader *find_msg,
2420 { 2420 {
2421 increment_stats(STAT_HELLOS_PROVIDED); 2421 increment_stats(STAT_HELLOS_PROVIDED);
2422 GNUNET_TRANSPORT_offer_hello(transport_handle, other_hello); 2422 GNUNET_TRANSPORT_offer_hello(transport_handle, other_hello);
2423 GNUNET_CORE_peer_request_connect(cfg, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 5), &peer_id, NULL, NULL); 2423 GNUNET_CORE_peer_request_connect(coreAPI,
2424 GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 5), &peer_id, NULL, NULL);
2424 route_message (find_msg, msg_ctx); 2425 route_message (find_msg, msg_ctx);
2425 GNUNET_free (other_hello); 2426 GNUNET_free (other_hello);
2426 return; 2427 return;
@@ -4228,7 +4229,7 @@ static int
4228handle_dht_p2p_route_request (void *cls, 4229handle_dht_p2p_route_request (void *cls,
4229 const struct GNUNET_PeerIdentity *peer, 4230 const struct GNUNET_PeerIdentity *peer,
4230 const struct GNUNET_MessageHeader *message, 4231 const struct GNUNET_MessageHeader *message,
4231 struct GNUNET_TIME_Relative latency, uint32_t distance) 4232 const struct GNUNET_TRANSPORT_ATS_Information *atsi)
4232{ 4233{
4233#if DEBUG_DHT 4234#if DEBUG_DHT
4234 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 4235 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -4284,7 +4285,7 @@ static int
4284handle_dht_p2p_route_result (void *cls, 4285handle_dht_p2p_route_result (void *cls,
4285 const struct GNUNET_PeerIdentity *peer, 4286 const struct GNUNET_PeerIdentity *peer,
4286 const struct GNUNET_MessageHeader *message, 4287 const struct GNUNET_MessageHeader *message,
4287 struct GNUNET_TIME_Relative latency, uint32_t distance) 4288 const struct GNUNET_TRANSPORT_ATS_Information *atsi)
4288{ 4289{
4289#if DEBUG_DHT 4290#if DEBUG_DHT
4290 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 4291 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -4472,13 +4473,12 @@ static struct GNUNET_CORE_MessageHandler core_handlers[] = {
4472 * 4473 *
4473 * @param cls closure 4474 * @param cls closure
4474 * @param peer peer identity this notification is about 4475 * @param peer peer identity this notification is about
4475 * @param latency reported latency of the connection with peer 4476 * @param atsi performance data
4476 * @param distance reported distance (DV) to peer
4477 */ 4477 */
4478void handle_core_connect (void *cls, 4478static void
4479 const struct GNUNET_PeerIdentity * peer, 4479handle_core_connect (void *cls,
4480 struct GNUNET_TIME_Relative latency, 4480 const struct GNUNET_PeerIdentity * peer,
4481 uint32_t distance) 4481 const struct GNUNET_TRANSPORT_ATS_Information *atsi)
4482{ 4482{
4483 struct PeerInfo *ret; 4483 struct PeerInfo *ret;
4484 4484
@@ -4497,8 +4497,7 @@ void handle_core_connect (void *cls,
4497 GNUNET_DATACACHE_put(datacache, &peer->hashPubKey, sizeof(struct GNUNET_PeerIdentity), (const char *)peer, GNUNET_BLOCK_TYPE_DHT_HELLO, GNUNET_TIME_absolute_get_forever()); 4497 GNUNET_DATACACHE_put(datacache, &peer->hashPubKey, sizeof(struct GNUNET_PeerIdentity), (const char *)peer, GNUNET_BLOCK_TYPE_DHT_HELLO, GNUNET_TIME_absolute_get_forever());
4498 ret = try_add_peer(peer, 4498 ret = try_add_peer(peer,
4499 find_current_bucket(&peer->hashPubKey), 4499 find_current_bucket(&peer->hashPubKey),
4500 latency, 4500 atsi);
4501 distance);
4502 if (ret != NULL) 4501 if (ret != NULL)
4503 { 4502 {
4504 newly_found_peers++; 4503 newly_found_peers++;
@@ -4517,9 +4516,10 @@ void handle_core_connect (void *cls,
4517 * @param cls closure 4516 * @param cls closure
4518 * @param peer peer identity this notification is about 4517 * @param peer peer identity this notification is about
4519 */ 4518 */
4520void handle_core_disconnect (void *cls, 4519static void
4521 const struct 4520handle_core_disconnect (void *cls,
4522 GNUNET_PeerIdentity * peer) 4521 const struct
4522 GNUNET_PeerIdentity * peer)
4523{ 4523{
4524 struct PeerInfo *to_remove; 4524 struct PeerInfo *to_remove;
4525 int current_bucket; 4525 int current_bucket;
@@ -4563,7 +4563,6 @@ run (void *cls,
4563 GNUNET_SERVER_disconnect_notify (server, &handle_client_disconnect, NULL); 4563 GNUNET_SERVER_disconnect_notify (server, &handle_client_disconnect, NULL);
4564 coreAPI = GNUNET_CORE_connect (cfg, /* Main configuration */ 4564 coreAPI = GNUNET_CORE_connect (cfg, /* Main configuration */
4565 1, /* queue size */ 4565 1, /* queue size */
4566 GNUNET_TIME_UNIT_FOREVER_REL,
4567 NULL, /* Closure passed to DHT functions */ 4566 NULL, /* Closure passed to DHT functions */
4568 &core_init, /* Call core_init once connected */ 4567 &core_init, /* Call core_init once connected */
4569 &handle_core_connect, /* Handle connects */ 4568 &handle_core_connect, /* Handle connects */