aboutsummaryrefslogtreecommitdiff
path: root/src/rps
diff options
context:
space:
mode:
authorJulius Bünger <buenger@mytum.de>2015-06-11 23:25:51 +0000
committerJulius Bünger <buenger@mytum.de>2015-06-11 23:25:51 +0000
commite67bda650f6b6e4a34f70e7095b09b24bda2f6f7 (patch)
treef9f4f75c9bf7319dce377f5c3e04f351a33d2c69 /src/rps
parent143dd2c94830367338171222a2452d5e62c82a53 (diff)
downloadgnunet-e67bda650f6b6e4a34f70e7095b09b24bda2f6f7.tar.gz
gnunet-e67bda650f6b6e4a34f70e7095b09b24bda2f6f7.zip
learn about peers from peerinfo
Diffstat (limited to 'src/rps')
-rw-r--r--src/rps/gnunet-service-rps.c46
1 files changed, 45 insertions, 1 deletions
diff --git a/src/rps/gnunet-service-rps.c b/src/rps/gnunet-service-rps.c
index 8e81fa24e..7827919d5 100644
--- a/src/rps/gnunet-service-rps.c
+++ b/src/rps/gnunet-service-rps.c
@@ -26,6 +26,7 @@
26#include "platform.h" 26#include "platform.h"
27#include "gnunet_util_lib.h" 27#include "gnunet_util_lib.h"
28#include "gnunet_cadet_service.h" 28#include "gnunet_cadet_service.h"
29#include "gnunet_peerinfo_service.h"
29#include "gnunet_nse_service.h" 30#include "gnunet_nse_service.h"
30#include "rps.h" 31#include "rps.h"
31#include "rps-test_util.h" 32#include "rps-test_util.h"
@@ -317,6 +318,16 @@ static struct GNUNET_NSE_Handle *nse;
317 */ 318 */
318static struct GNUNET_CADET_Handle *cadet_handle; 319static struct GNUNET_CADET_Handle *cadet_handle;
319 320
321/**
322 * Handler to PEERINFO.
323 */
324static struct GNUNET_PEERINFO_Handle *peerinfo_handle;
325
326/**
327 * Handle for cancellation of iteration over peers.
328 */
329struct GNUNET_PEERINFO_NotifyContext *peerinfo_notify_handle;
330
320 331
321/** 332/**
322 * Request counter. 333 * Request counter.
@@ -1999,6 +2010,8 @@ do_round (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1999 2010
2000 LOG (GNUNET_ERROR_TYPE_DEBUG, 2011 LOG (GNUNET_ERROR_TYPE_DEBUG,
2001 "Printing gossip list:\n"); 2012 "Printing gossip list:\n");
2013 to_file (file_name_view_log,
2014 "___ new round ___");
2002 for (i = 0 ; i < gossip_list_size ; i++) 2015 for (i = 0 ; i < gossip_list_size ; i++)
2003 { 2016 {
2004 LOG (GNUNET_ERROR_TYPE_DEBUG, 2017 LOG (GNUNET_ERROR_TYPE_DEBUG,
@@ -2213,6 +2226,30 @@ init_peer_cb (void *cls,
2213 2226
2214 2227
2215/** 2228/**
2229 * Iterator over peers from peerinfo.
2230 *
2231 * @param cls closure
2232 * @param peer id of the peer, NULL for last call
2233 * @param hello hello message for the peer (can be NULL)
2234 * @param error message
2235 */
2236void
2237process_peerinfo_peers (void *cls,
2238 const struct GNUNET_PeerIdentity *peer,
2239 const struct GNUNET_HELLO_Message *hello,
2240 const char *err_msg)
2241{
2242 if (NULL != peer)
2243 {
2244 LOG (GNUNET_ERROR_TYPE_DEBUG,
2245 "Got peer_id %s from peerinfo\n",
2246 GNUNET_i2s (peer));
2247 new_peer_id (peer);
2248 }
2249}
2250
2251
2252/**
2216 * Clean the send channel of a peer 2253 * Clean the send channel of a peer
2217 */ 2254 */
2218void 2255void
@@ -2322,13 +2359,15 @@ shutdown_task (void *cls,
2322 2359
2323 LOG (GNUNET_ERROR_TYPE_DEBUG, "RPS is going down\n"); 2360 LOG (GNUNET_ERROR_TYPE_DEBUG, "RPS is going down\n");
2324 2361
2362 GNUNET_PEERINFO_notify_cancel (peerinfo_notify_handle);
2363 GNUNET_PEERINFO_disconnect (peerinfo_handle);
2364
2325 if (NULL != do_round_task) 2365 if (NULL != do_round_task)
2326 { 2366 {
2327 GNUNET_SCHEDULER_cancel (do_round_task); 2367 GNUNET_SCHEDULER_cancel (do_round_task);
2328 do_round_task = NULL; 2368 do_round_task = NULL;
2329 } 2369 }
2330 2370
2331
2332 { 2371 {
2333 if (GNUNET_SYSERR == 2372 if (GNUNET_SYSERR ==
2334 GNUNET_CONTAINER_multipeermap_iterate (peer_map, peer_remove_cb, NULL)) 2373 GNUNET_CONTAINER_multipeermap_iterate (peer_map, peer_remove_cb, NULL))
@@ -2656,6 +2695,7 @@ run (void *cls,
2656 cadet_handlers, 2695 cadet_handlers,
2657 ports); 2696 ports);
2658 2697
2698 peerinfo_handle = GNUNET_PEERINFO_connect (cfg);
2659 2699
2660 /* Initialise sampler */ 2700 /* Initialise sampler */
2661 struct GNUNET_TIME_Relative half_round_interval; 2701 struct GNUNET_TIME_Relative half_round_interval;
@@ -2683,6 +2723,10 @@ run (void *cls,
2683 GNUNET_CADET_get_peers (cadet_handle, &init_peer_cb, NULL); 2723 GNUNET_CADET_get_peers (cadet_handle, &init_peer_cb, NULL);
2684 // TODO send push/pull to each of those peers? 2724 // TODO send push/pull to each of those peers?
2685 2725
2726 peerinfo_notify_handle = GNUNET_PEERINFO_notify (cfg,
2727 GNUNET_NO,
2728 process_peerinfo_peers,
2729 NULL);
2686 2730
2687 rps_start (server); 2731 rps_start (server);
2688} 2732}