aboutsummaryrefslogtreecommitdiff
path: root/src/set/gnunet-set-profiler.c
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2015-09-27 04:32:52 +0000
committerFlorian Dold <florian.dold@gmail.com>2015-09-27 04:32:52 +0000
commit9aceae8a9f91642665fa28730c961c9f90360bc1 (patch)
tree5390aca855b836d17720a65671f994089cb93196 /src/set/gnunet-set-profiler.c
parent55ad4fa34348aaa05fadedeb830ea72cea5d7cc4 (diff)
downloadgnunet-9aceae8a9f91642665fa28730c961c9f90360bc1.tar.gz
gnunet-9aceae8a9f91642665fa28730c961c9f90360bc1.zip
SET service: accurate results for symmetric mode
Diffstat (limited to 'src/set/gnunet-set-profiler.c')
-rw-r--r--src/set/gnunet-set-profiler.c51
1 files changed, 41 insertions, 10 deletions
diff --git a/src/set/gnunet-set-profiler.c b/src/set/gnunet-set-profiler.c
index 1569c29b7..2ee1b762d 100644
--- a/src/set/gnunet-set-profiler.c
+++ b/src/set/gnunet-set-profiler.c
@@ -98,6 +98,7 @@ set_result_cb (void *cls,
98 enum GNUNET_SET_Status status) 98 enum GNUNET_SET_Status status)
99{ 99{
100 struct SetInfo *info = cls; 100 struct SetInfo *info = cls;
101 struct GNUNET_HashCode hash;
101 102
102 GNUNET_assert (GNUNET_NO == info->done); 103 GNUNET_assert (GNUNET_NO == info->done);
103 switch (status) 104 switch (status)
@@ -114,15 +115,22 @@ set_result_cb (void *cls,
114 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "failure\n"); 115 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "failure\n");
115 GNUNET_SCHEDULER_shutdown (); 116 GNUNET_SCHEDULER_shutdown ();
116 return; 117 return;
117 case GNUNET_SET_STATUS_OK: 118 case GNUNET_SET_STATUS_ADD_LOCAL:
119 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "set %s: local element\n", info->id);
118 break; 120 break;
121 case GNUNET_SET_STATUS_ADD_REMOTE:
122 GNUNET_CRYPTO_hash (element->data, element->size, &hash);
123 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "set %s: remote element %s\n", info->id,
124 GNUNET_h2s (&hash));
125 // XXX: record and check
126 return;
119 default: 127 default:
120 GNUNET_assert (0); 128 GNUNET_assert (0);
121 } 129 }
122 130
123 if (element->size != sizeof (struct GNUNET_HashCode)) 131 if (element->size != sizeof (struct GNUNET_HashCode))
124 { 132 {
125 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "wrong element size: %u\n", element->size); 133 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "wrong element size: %u, expected %u\n", element->size, sizeof (struct GNUNET_HashCode));
126 GNUNET_assert (0); 134 GNUNET_assert (0);
127 } 135 }
128 136
@@ -180,6 +188,8 @@ static void
180handle_shutdown (void *cls, 188handle_shutdown (void *cls,
181 const struct GNUNET_SCHEDULER_TaskContext *tc) 189 const struct GNUNET_SCHEDULER_TaskContext *tc)
182{ 190{
191 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
192 "Shutting down set profiler\n");
183 if (NULL != set_listener) 193 if (NULL != set_listener)
184 { 194 {
185 GNUNET_SET_listen_cancel (set_listener); 195 GNUNET_SET_listen_cancel (set_listener);
@@ -209,11 +219,13 @@ handle_shutdown (void *cls,
209 219
210 220
211static void 221static void
212run (void *cls, char *const *args, const char *cfgfile, 222run (void *cls,
213 const struct GNUNET_CONFIGURATION_Handle *cfg) 223 const struct GNUNET_CONFIGURATION_Handle *cfg,
224 struct GNUNET_TESTING_Peer *peer)
214{ 225{
215 unsigned int i; 226 unsigned int i;
216 struct GNUNET_HashCode hash; 227 struct GNUNET_HashCode hash;
228 struct GNUNET_HashCode hashhash;
217 229
218 config = cfg; 230 config = cfg;
219 231
@@ -239,6 +251,9 @@ run (void *cls, char *const *args, const char *cfgfile,
239 for (i = 0; i < num_a; i++) 251 for (i = 0; i < num_a; i++)
240 { 252 {
241 GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_STRONG, &hash); 253 GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_STRONG, &hash);
254 GNUNET_CRYPTO_hash (&hash, sizeof (struct GNUNET_HashCode), &hashhash);
255 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Set a: Created element %s\n",
256 GNUNET_h2s (&hashhash));
242 GNUNET_CONTAINER_multihashmap_put (info1.sent, &hash, NULL, 257 GNUNET_CONTAINER_multihashmap_put (info1.sent, &hash, NULL,
243 GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE); 258 GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE);
244 } 259 }
@@ -246,6 +261,9 @@ run (void *cls, char *const *args, const char *cfgfile,
246 for (i = 0; i < num_b; i++) 261 for (i = 0; i < num_b; i++)
247 { 262 {
248 GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_STRONG, &hash); 263 GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_STRONG, &hash);
264 GNUNET_CRYPTO_hash (&hash, sizeof (struct GNUNET_HashCode), &hashhash);
265 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Set b: Created element %s\n",
266 GNUNET_h2s (&hashhash));
249 GNUNET_CONTAINER_multihashmap_put (info2.sent, &hash, NULL, 267 GNUNET_CONTAINER_multihashmap_put (info2.sent, &hash, NULL,
250 GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE); 268 GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE);
251 } 269 }
@@ -253,12 +271,14 @@ run (void *cls, char *const *args, const char *cfgfile,
253 for (i = 0; i < num_c; i++) 271 for (i = 0; i < num_c; i++)
254 { 272 {
255 GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_STRONG, &hash); 273 GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_STRONG, &hash);
274 GNUNET_CRYPTO_hash (&hash, sizeof (struct GNUNET_HashCode), &hashhash);
275 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Set c: Created element %s\n",
276 GNUNET_h2s (&hashhash));
256 GNUNET_CONTAINER_multihashmap_put (common_sent, &hash, NULL, 277 GNUNET_CONTAINER_multihashmap_put (common_sent, &hash, NULL,
257 GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE); 278 GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE);
258 } 279 }
259 280
260 /* use last hash for app id */ 281 GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_STRONG, &app_id);
261 app_id = hash;
262 282
263 /* FIXME: also implement intersection etc. */ 283 /* FIXME: also implement intersection etc. */
264 info1.set = GNUNET_SET_create (config, GNUNET_SET_OPERATION_UNION); 284 info1.set = GNUNET_SET_create (config, GNUNET_SET_OPERATION_UNION);
@@ -281,6 +301,17 @@ run (void *cls, char *const *args, const char *cfgfile,
281} 301}
282 302
283 303
304static void
305pre_run (void *cls, char *const *args, const char *cfgfile,
306 const struct GNUNET_CONFIGURATION_Handle *cfg)
307{
308 if (0 != GNUNET_TESTING_peer_run ("set-profiler",
309 cfgfile,
310 &run, NULL))
311 ret = 2;
312}
313
314
284int 315int
285main (int argc, char **argv) 316main (int argc, char **argv)
286{ 317{
@@ -295,13 +326,13 @@ main (int argc, char **argv)
295 gettext_noop ("number of values"), 326 gettext_noop ("number of values"),
296 GNUNET_YES, &GNUNET_GETOPT_set_uint, &num_c }, 327 GNUNET_YES, &GNUNET_GETOPT_set_uint, &num_c },
297 { 'x', "operation", NULL, 328 { 'x', "operation", NULL,
298 gettext_noop ("oeration to execute"), 329 gettext_noop ("operation to execute"),
299 GNUNET_YES, &GNUNET_GETOPT_set_string, &op_str }, 330 GNUNET_YES, &GNUNET_GETOPT_set_string, &op_str },
300 GNUNET_GETOPT_OPTION_END 331 GNUNET_GETOPT_OPTION_END
301 }; 332 };
302 GNUNET_PROGRAM_run (argc, argv, "gnunet-set-profiler", 333 GNUNET_PROGRAM_run2 (argc, argv, "gnunet-set-profiler",
303 "help", 334 "help",
304 options, &run, NULL); 335 options, &pre_run, NULL, GNUNET_YES);
305 return ret; 336 return ret;
306} 337}
307 338