aboutsummaryrefslogtreecommitdiff
path: root/src/nse/test_nse_multipeer.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/nse/test_nse_multipeer.c')
-rw-r--r--src/nse/test_nse_multipeer.c52
1 files changed, 22 insertions, 30 deletions
diff --git a/src/nse/test_nse_multipeer.c b/src/nse/test_nse_multipeer.c
index 29e5cd6cc..1db00415f 100644
--- a/src/nse/test_nse_multipeer.c
+++ b/src/nse/test_nse_multipeer.c
@@ -72,8 +72,8 @@ shutdown_callback (void *cls, const char *emsg)
72 if (emsg != NULL) 72 if (emsg != NULL)
73 { 73 {
74#if VERBOSE 74#if VERBOSE
75 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 75 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutdown of peers failed: %s!\n",
76 "Shutdown of peers failed: %s!\n", emsg); 76 emsg);
77#endif 77#endif
78 if (ok == 0) 78 if (ok == 0)
79 ok = 666; 79 ok = 666;
@@ -117,17 +117,15 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
117 * 117 *
118 */ 118 */
119static void 119static void
120handle_estimate (void *cls, 120handle_estimate (void *cls, struct GNUNET_TIME_Absolute timestamp,
121 struct GNUNET_TIME_Absolute timestamp,
122 double estimate, double std_dev) 121 double estimate, double std_dev)
123{ 122{
124 struct NSEPeer *peer = cls; 123 struct NSEPeer *peer = cls;
125 124
126 fprintf (stderr, 125 fprintf (stderr,
127 "Received network size estimate from peer %s. logSize: %f std.dev. %f (%f/%u)\n", 126 "Received network size estimate from peer %s. logSize: %f std.dev. %f (%f/%u)\n",
128 GNUNET_i2s (&peer->daemon->id), 127 GNUNET_i2s (&peer->daemon->id), estimate, std_dev,
129 estimate, 128 GNUNET_NSE_log_estimate_to_n (estimate), num_peers);
130 std_dev, GNUNET_NSE_log_estimate_to_n (estimate), num_peers);
131} 129}
132 130
133 131
@@ -144,9 +142,9 @@ connect_nse_service (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
144 { 142 {
145 current_peer = GNUNET_malloc (sizeof (struct NSEPeer)); 143 current_peer = GNUNET_malloc (sizeof (struct NSEPeer));
146 current_peer->daemon = GNUNET_TESTING_daemon_get (pg, i); 144 current_peer->daemon = GNUNET_TESTING_daemon_get (pg, i);
147 current_peer->nse_handle = GNUNET_NSE_connect (current_peer->daemon->cfg, 145 current_peer->nse_handle =
148 &handle_estimate, 146 GNUNET_NSE_connect (current_peer->daemon->cfg, &handle_estimate,
149 current_peer); 147 current_peer);
150 GNUNET_assert (current_peer->nse_handle != NULL); 148 GNUNET_assert (current_peer->nse_handle != NULL);
151 GNUNET_CONTAINER_DLL_insert (peer_head, peer_tail, current_peer); 149 GNUNET_CONTAINER_DLL_insert (peer_head, peer_tail, current_peer);
152 } 150 }
@@ -169,8 +167,8 @@ my_cb (void *cls, const char *emsg)
169 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 167 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
170 "Peer Group started successfully, connecting to NSE service for each peer!\n"); 168 "Peer Group started successfully, connecting to NSE service for each peer!\n");
171#endif 169#endif
172 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 170 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Have %u connections\n",
173 "Have %u connections\n", total_connections); 171 total_connections);
174 172
175 GNUNET_SCHEDULER_add_now (&connect_nse_service, NULL); 173 GNUNET_SCHEDULER_add_now (&connect_nse_service, NULL);
176} 174}
@@ -191,10 +189,8 @@ my_cb (void *cls, const char *emsg)
191 * @param emsg error message (NULL on success) 189 * @param emsg error message (NULL on success)
192 */ 190 */
193static void 191static void
194connect_cb (void *cls, 192connect_cb (void *cls, const struct GNUNET_PeerIdentity *first,
195 const struct GNUNET_PeerIdentity *first, 193 const struct GNUNET_PeerIdentity *second, uint32_t distance,
196 const struct GNUNET_PeerIdentity *second,
197 uint32_t distance,
198 const struct GNUNET_CONFIGURATION_Handle *first_cfg, 194 const struct GNUNET_CONFIGURATION_Handle *first_cfg,
199 const struct GNUNET_CONFIGURATION_Handle *second_cfg, 195 const struct GNUNET_CONFIGURATION_Handle *second_cfg,
200 struct GNUNET_TESTING_Daemon *first_daemon, 196 struct GNUNET_TESTING_Daemon *first_daemon,
@@ -210,9 +206,8 @@ connect_cb (void *cls,
210 206
211 207
212static void 208static void
213run (void *cls, 209run (void *cls, char *const *args, const char *cfgfile,
214 char *const *args, 210 const struct GNUNET_CONFIGURATION_Handle *cfg)
215 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
216{ 211{
217 struct GNUNET_CONFIGURATION_Handle *testing_cfg; 212 struct GNUNET_CONFIGURATION_Handle *testing_cfg;
218 unsigned long long total_peers; 213 unsigned long long total_peers;
@@ -223,20 +218,17 @@ run (void *cls,
223 218
224#if VERBOSE 219#if VERBOSE
225 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting daemons.\n"); 220 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting daemons.\n");
226 GNUNET_CONFIGURATION_set_value_string (testing_cfg, 221 GNUNET_CONFIGURATION_set_value_string (testing_cfg, "testing",
227 "testing", "use_progressbars", "YES"); 222 "use_progressbars", "YES");
228#endif 223#endif
229 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (testing_cfg, 224 if (GNUNET_OK !=
230 "testing", 225 GNUNET_CONFIGURATION_get_value_number (testing_cfg, "testing",
231 "num_peers", 226 "num_peers", &total_peers))
232 &total_peers))
233 total_peers = NUM_PEERS; 227 total_peers = NUM_PEERS;
234 228
235 peers_left = total_peers; 229 peers_left = total_peers;
236 num_peers = peers_left; 230 num_peers = peers_left;
237 pg = GNUNET_TESTING_peergroup_start (testing_cfg, 231 pg = GNUNET_TESTING_peergroup_start (testing_cfg, peers_left, TIMEOUT,
238 peers_left,
239 TIMEOUT,
240 &connect_cb, &my_cb, NULL, NULL); 232 &connect_cb, &my_cb, NULL, NULL);
241 GNUNET_assert (pg != NULL); 233 GNUNET_assert (pg != NULL);
242 GNUNET_SCHEDULER_add_delayed (TIMEOUT, &shutdown_task, NULL); 234 GNUNET_SCHEDULER_add_delayed (TIMEOUT, &shutdown_task, NULL);
@@ -257,8 +249,8 @@ check ()
257 struct GNUNET_GETOPT_CommandLineOption options[] = { 249 struct GNUNET_GETOPT_CommandLineOption options[] = {
258 GNUNET_GETOPT_OPTION_END 250 GNUNET_GETOPT_OPTION_END
259 }; 251 };
260 GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, 252 GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv,
261 argv, "test-nse-multipeer", "nohelp", options, &run, &ok); 253 "test-nse-multipeer", "nohelp", options, &run, &ok);
262 return ok; 254 return ok;
263} 255}
264 256