aboutsummaryrefslogtreecommitdiff
path: root/src/dht/test_dht_api.c
diff options
context:
space:
mode:
authorNathan S. Evans <evans@in.tum.de>2010-04-05 19:40:07 +0000
committerNathan S. Evans <evans@in.tum.de>2010-04-05 19:40:07 +0000
commit602dd5a348d139cdc65095c21f3f05cf92013a54 (patch)
tree207c1000657d9bf4ac261349466aa7ae5e272231 /src/dht/test_dht_api.c
parentda0733704943528795d9798c89ecfda1078ca191 (diff)
downloadgnunet-602dd5a348d139cdc65095c21f3f05cf92013a54.tar.gz
gnunet-602dd5a348d139cdc65095c21f3f05cf92013a54.zip
basic find peer functionality, added to test_dht_api testcase
Diffstat (limited to 'src/dht/test_dht_api.c')
-rw-r--r--src/dht/test_dht_api.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/src/dht/test_dht_api.c b/src/dht/test_dht_api.c
index f9d9e008c..f09a00879 100644
--- a/src/dht/test_dht_api.c
+++ b/src/dht/test_dht_api.c
@@ -147,6 +147,28 @@ test_find_peer_stop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
147 147
148} 148}
149 149
150
151/**
152 * Iterator called on each result obtained from a find peer
153 * operation
154 *
155 * @param cls closure (NULL)
156 * @param peer the peer we learned about
157 * @param reply response
158 */
159void test_find_peer_processor (void *cls,
160 const struct GNUNET_PeerIdentity *peer,
161 const struct GNUNET_MessageHeader *reply)
162{
163
164 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
165 "test_find_peer_processor called (peer `%s'), stopping find peer request!\n", GNUNET_i2s(peer));
166
167 GNUNET_SCHEDULER_add_continuation (sched, &test_find_peer_stop, &p1,
168 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
169}
170
171
150/** 172/**
151 * Signature of the main function of a task. 173 * Signature of the main function of a task.
152 * 174 *
@@ -165,7 +187,7 @@ test_find_peer (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
165 187
166 peer->find_peer_handle = 188 peer->find_peer_handle =
167 GNUNET_DHT_find_peer_start (peer->dht_handle, TIMEOUT, 0, NULL, &hash, 189 GNUNET_DHT_find_peer_start (peer->dht_handle, TIMEOUT, 0, NULL, &hash,
168 NULL, NULL, &test_find_peer_stop, &p1); 190 &test_find_peer_processor, NULL, NULL, NULL);
169 191
170 if (peer->find_peer_handle == NULL) 192 if (peer->find_peer_handle == NULL)
171 GNUNET_SCHEDULER_add_now (sched, &end_badly, &p1); 193 GNUNET_SCHEDULER_add_now (sched, &end_badly, &p1);