diff options
author | Arthur Dewarumez <arthur.dewarumez@etudiant.univ-lille1.fr> | 2015-05-01 08:51:08 +0000 |
---|---|---|
committer | Arthur Dewarumez <arthur.dewarumez@etudiant.univ-lille1.fr> | 2015-05-01 08:51:08 +0000 |
commit | 7f8bcc9eb8c0362c44682b9cdc5675ae9527a1e8 (patch) | |
tree | a0f64275e849b46b7574629647d3bbeb6a601a4a /src/dht | |
parent | a3e4ea39cd0c5f1442c9fece58a521ea3c28fdf4 (diff) | |
download | gnunet-7f8bcc9eb8c0362c44682b9cdc5675ae9527a1e8.tar.gz gnunet-7f8bcc9eb8c0362c44682b9cdc5675ae9527a1e8.zip |
Adding a function pick_random_friend ()
Diffstat (limited to 'src/dht')
-rw-r--r-- | src/dht/gnunet-service-wdht_neighbours.c | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/src/dht/gnunet-service-wdht_neighbours.c b/src/dht/gnunet-service-wdht_neighbours.c index 77a9b852c..4e6ccf432 100644 --- a/src/dht/gnunet-service-wdht_neighbours.c +++ b/src/dht/gnunet-service-wdht_neighbours.c | |||
@@ -805,13 +805,13 @@ GDS_NEIGHBOURS_send_get_result (const struct GNUNET_HashCode *trail_id, | |||
805 | { | 805 | { |
806 | struct GNUNET_MessageHeader *payload; | 806 | struct GNUNET_MessageHeader *payload; |
807 | 807 | ||
808 | payload = GNUNET_malloc(sizeof(struct GNUNET_MessageHeader) + data_size); | 808 | payload = GNUNET_malloc (sizeof (struct GNUNET_MessageHeader) + data_size); |
809 | payload->size = data_size; | 809 | payload->size = data_size; |
810 | payload->type = GNUNET_MESSAGE_TYPE_WDHT_GET_RESULT; | 810 | payload->type = GNUNET_MESSAGE_TYPE_WDHT_GET_RESULT; |
811 | 811 | ||
812 | forward_message_on_trail (NULL /* FIXME: put something right */, | 812 | forward_message_on_trail (NULL /* FIXME: put something right */, |
813 | trail_id, | 813 | trail_id, |
814 | 0/* FIXME: put something right */, | 814 | 0 /* FIXME: put something right */, |
815 | &my_identity, | 815 | &my_identity, |
816 | put_path, | 816 | put_path, |
817 | put_path_length, | 817 | put_path_length, |
@@ -875,9 +875,23 @@ handle_core_disconnect (void *cls, | |||
875 | static struct FriendInfo * | 875 | static struct FriendInfo * |
876 | pick_random_friend () | 876 | pick_random_friend () |
877 | { | 877 | { |
878 | /* FIXME: in my opinion, if have to pick a random friend from the friend_map | 878 | GNUNET_CONTAINER_PeerMapIterator *it; |
879 | but i can't find a function to get a random friend from a mutlipeer_map */ | 879 | if (0 != GNUNET_CONTAINER_multipeermap_get_random (friends_peermap, |
880 | /* return GNUNET_CONTAINER_multipeermap_get_random (friends_peermap); */ | 880 | *it, |
881 | NULL) ){ | ||
882 | static struct FriendInfo **friend; | ||
883 | struct GNUNET_PeerIdentity *key; | ||
884 | |||
885 | /* FIXME: i am not sure of this one */ | ||
886 | key = NULL; | ||
887 | |||
888 | if(GNUNET_YES == GNUNET_CONTAINER_multipeermap_iterator_next (it, | ||
889 | key, | ||
890 | (void *) friend)) | ||
891 | { | ||
892 | return *friend; | ||
893 | } | ||
894 | } | ||
881 | return NULL; | 895 | return NULL; |
882 | } | 896 | } |
883 | 897 | ||
@@ -1205,7 +1219,8 @@ handle_dht_p2p_random_walk_response (void *cls, | |||
1205 | const struct RandomWalkResponseMessage *rwrm; | 1219 | const struct RandomWalkResponseMessage *rwrm; |
1206 | 1220 | ||
1207 | rwrm = (const struct RandomWalkResponseMessage *) message; | 1221 | rwrm = (const struct RandomWalkResponseMessage *) message; |
1208 | // 1) lookup trail => find Finger entry => fill in 'destination' and mark valid, move to end of sorted array, mark unsorted, update links from 'trails' | 1222 | // 1) lookup trail => find Finger entry => fill in 'destination' and mark valid, move to end of sorted array, |
1223 | //mark unsorted, update links from 'trails' | ||
1209 | /* | 1224 | /* |
1210 | * Steps : | 1225 | * Steps : |
1211 | * 1 check if we are the correct layer | 1226 | * 1 check if we are the correct layer |