aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2011-10-21 11:38:31 +0000
committerBart Polot <bart@net.in.tum.de>2011-10-21 11:38:31 +0000
commit07a2599e4c8d4d69391749b98f4898a58c30d497 (patch)
tree0e06551284152357a06f48c0b1bc6daae5799a0c /src
parent29424a239722a6b30533b12553149760a9a761a8 (diff)
downloadgnunet-07a2599e4c8d4d69391749b98f4898a58c30d497.tar.gz
gnunet-07a2599e4c8d4d69391749b98f4898a58c30d497.zip
Refactored to use functions instead of duplicated code for starting DHT GET for ID
Diffstat (limited to 'src')
-rw-r--r--src/mesh/gnunet-service-mesh.c40
1 files changed, 2 insertions, 38 deletions
diff --git a/src/mesh/gnunet-service-mesh.c b/src/mesh/gnunet-service-mesh.c
index ca1fc0550..d5a457fbc 100644
--- a/src/mesh/gnunet-service-mesh.c
+++ b/src/mesh/gnunet-service-mesh.c
@@ -1341,7 +1341,6 @@ path_remove_from_peer (struct MeshPeerInfo *peer,
1341 GNUNET_PEER_Id p1, 1341 GNUNET_PEER_Id p1,
1342 GNUNET_PEER_Id p2) 1342 GNUNET_PEER_Id p2)
1343{ 1343{
1344 struct GNUNET_PeerIdentity id;
1345 struct MeshPeerPath *p; 1344 struct MeshPeerPath *p;
1346 struct MeshPeerPath *aux; 1345 struct MeshPeerPath *aux;
1347 struct MeshPeerInfo *peer_d; 1346 struct MeshPeerInfo *peer_d;
@@ -1404,26 +1403,7 @@ path_remove_from_peer (struct MeshPeerInfo *peer,
1404 } 1403 }
1405 else 1404 else
1406 { 1405 {
1407 struct MeshPathInfo *path_info; 1406 peer_info_connect (peer_d, peer->tunnels[i]);
1408
1409 if (NULL != peer_d->dhtget)
1410 return;
1411 path_info = GNUNET_malloc(sizeof(struct MeshPathInfo));
1412 path_info->path = p;
1413 path_info->peer = peer_d;
1414 path_info->t = peer->tunnels[i];
1415 peer_d->dhtget =
1416 GNUNET_DHT_get_start(dht_handle, /* handle */
1417 GNUNET_TIME_UNIT_FOREVER_REL, /* timeout */
1418 GNUNET_BLOCK_TYPE_TEST, /* type */
1419 &id.hashPubKey, /*key to search */
1420 4, /* replication level */
1421 GNUNET_DHT_RO_RECORD_ROUTE |
1422 GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE,
1423 NULL, /* xquery */
1424 0, /* xquery bits */
1425 &dht_get_id_handler,
1426 (void *) path_info);
1427 } 1407 }
1428 } 1408 }
1429} 1409}
@@ -3097,23 +3077,7 @@ dht_get_type_handler (void *cls, struct GNUNET_TIME_Absolute exp,
3097 if ((NULL == get_path || NULL == put_path) && NULL == peer_info->path_head && 3077 if ((NULL == get_path || NULL == put_path) && NULL == peer_info->path_head &&
3098 NULL == peer_info->dhtget) 3078 NULL == peer_info->dhtget)
3099 { 3079 {
3100 path_info = GNUNET_malloc (sizeof (struct MeshPathInfo)); 3080 peer_info_connect (peer_info, t);
3101 path_info->peer = peer_info;
3102 path_info->t = t;
3103 /* we don't have a route to the peer, let's try a direct lookup */
3104 peer_info->dhtget =
3105 GNUNET_DHT_get_start (dht_handle, /* handle */
3106 GNUNET_TIME_UNIT_FOREVER_REL, /* timeout */
3107 GNUNET_BLOCK_TYPE_TEST, /* block type */
3108 &pi->hashPubKey, /* key to look up */
3109 10U, /* replication level */
3110 GNUNET_DHT_RO_RECORD_ROUTE |
3111 GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE,
3112 /* option to dht: record route */
3113 NULL, /* xquery */
3114 0, /* xquery bits */
3115 dht_get_id_handler, /* callback */
3116 path_info); /* closure */
3117 return; 3081 return;
3118 } 3082 }
3119 3083