diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-05-06 01:12:57 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-05-06 01:12:57 +0000 |
commit | 9fac6b6eefdc9144053f736fd388cb2199a97046 (patch) | |
tree | 82740a981b7f6ae973d915aa77797acd9db668b2 /src/nse | |
parent | 23d8d343d5c70481ecf78ec4fafc698907f3e8a9 (diff) | |
download | gnunet-9fac6b6eefdc9144053f736fd388cb2199a97046.tar.gz gnunet-9fac6b6eefdc9144053f736fd388cb2199a97046.zip |
-removing legacy ifdefs, fixing log statements
Diffstat (limited to 'src/nse')
-rw-r--r-- | src/nse/gnunet-service-nse.c | 18 | ||||
-rw-r--r-- | src/nse/nse_api.c | 8 | ||||
-rw-r--r-- | src/nse/test_nse_api.c | 11 |
3 files changed, 0 insertions, 37 deletions
diff --git a/src/nse/gnunet-service-nse.c b/src/nse/gnunet-service-nse.c index 8aff436cb..8373b621c 100644 --- a/src/nse/gnunet-service-nse.c +++ b/src/nse/gnunet-service-nse.c | |||
@@ -410,9 +410,7 @@ handle_start_message (void *cls, struct GNUNET_SERVER_Client *client, | |||
410 | { | 410 | { |
411 | struct GNUNET_NSE_ClientMessage em; | 411 | struct GNUNET_NSE_ClientMessage em; |
412 | 412 | ||
413 | #if DEBUG_NSE | ||
414 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received START message from client\n"); | 413 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received START message from client\n"); |
415 | #endif | ||
416 | GNUNET_SERVER_notification_context_add (nc, client); | 414 | GNUNET_SERVER_notification_context_add (nc, client); |
417 | setup_estimate_message (&em); | 415 | setup_estimate_message (&em); |
418 | GNUNET_SERVER_notification_context_unicast (nc, client, &em.header, | 416 | GNUNET_SERVER_notification_context_unicast (nc, client, &em.header, |
@@ -457,11 +455,9 @@ get_delay_randomization (uint32_t matching_bits) | |||
457 | 455 | ||
458 | d = get_matching_bits_delay (matching_bits); | 456 | d = get_matching_bits_delay (matching_bits); |
459 | i = (uint32_t) (d / (double) (hop_count_max + 1)); | 457 | i = (uint32_t) (d / (double) (hop_count_max + 1)); |
460 | #if DEBUG_NSE | ||
461 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 458 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
462 | "Randomizing flood using latencies up to %u ms\n", | 459 | "Randomizing flood using latencies up to %u ms\n", |
463 | (unsigned int) i); | 460 | (unsigned int) i); |
464 | #endif | ||
465 | ret.rel_value = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, i + 1); | 461 | ret.rel_value = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, i + 1); |
466 | return ret; | 462 | return ret; |
467 | #else | 463 | #else |
@@ -514,11 +510,9 @@ get_transmit_delay (int round_offset) | |||
514 | #else | 510 | #else |
515 | ret = GNUNET_TIME_UNIT_ZERO; | 511 | ret = GNUNET_TIME_UNIT_ZERO; |
516 | #endif | 512 | #endif |
517 | #if DEBUG_NSE | ||
518 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 513 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
519 | "Transmitting previous round behind schedule in %llu ms\n", | 514 | "Transmitting previous round behind schedule in %llu ms\n", |
520 | (unsigned long long) ret.rel_value); | 515 | (unsigned long long) ret.rel_value); |
521 | #endif | ||
522 | return ret; | 516 | return ret; |
523 | case 0: | 517 | case 0: |
524 | /* current round is based on best-known matching_bits */ | 518 | /* current round is based on best-known matching_bits */ |
@@ -527,13 +521,11 @@ get_transmit_delay (int round_offset) | |||
527 | dist_delay = get_matching_bits_delay (matching_bits); | 521 | dist_delay = get_matching_bits_delay (matching_bits); |
528 | dist_delay += get_delay_randomization (matching_bits).rel_value; | 522 | dist_delay += get_delay_randomization (matching_bits).rel_value; |
529 | ret.rel_value = (uint64_t) dist_delay; | 523 | ret.rel_value = (uint64_t) dist_delay; |
530 | #if DEBUG_NSE | ||
531 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 524 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
532 | "For round %llu, delay for %u matching bits is %llu ms\n", | 525 | "For round %llu, delay for %u matching bits is %llu ms\n", |
533 | (unsigned long long) current_timestamp.abs_value, | 526 | (unsigned long long) current_timestamp.abs_value, |
534 | (unsigned int) matching_bits, | 527 | (unsigned int) matching_bits, |
535 | (unsigned long long) ret.rel_value); | 528 | (unsigned long long) ret.rel_value); |
536 | #endif | ||
537 | /* now consider round start time and add delay to it */ | 529 | /* now consider round start time and add delay to it */ |
538 | tgt = GNUNET_TIME_absolute_add (current_timestamp, ret); | 530 | tgt = GNUNET_TIME_absolute_add (current_timestamp, ret); |
539 | return GNUNET_TIME_absolute_get_remaining (tgt); | 531 | return GNUNET_TIME_absolute_get_remaining (tgt); |
@@ -599,7 +591,6 @@ transmit_ready (void *cls, size_t size, void *buf) | |||
599 | 1, GNUNET_NO); | 591 | 1, GNUNET_NO); |
600 | return 0; | 592 | return 0; |
601 | } | 593 | } |
602 | #if DEBUG_NSE | ||
603 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 594 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
604 | "In round %llu, sending to `%s' estimate with %u bits\n", | 595 | "In round %llu, sending to `%s' estimate with %u bits\n", |
605 | (unsigned long long) | 596 | (unsigned long long) |
@@ -607,7 +598,6 @@ transmit_ready (void *cls, size_t size, void *buf) | |||
607 | timestamp).abs_value, | 598 | timestamp).abs_value, |
608 | GNUNET_i2s (&peer_entry->id), | 599 | GNUNET_i2s (&peer_entry->id), |
609 | (unsigned int) ntohl (size_estimate_messages[idx].matching_bits)); | 600 | (unsigned int) ntohl (size_estimate_messages[idx].matching_bits)); |
610 | #endif | ||
611 | if (ntohl (size_estimate_messages[idx].hop_count) == 0) | 601 | if (ntohl (size_estimate_messages[idx].hop_count) == 0) |
612 | GNUNET_STATISTICS_update (stats, "# flood messages started", 1, GNUNET_NO); | 602 | GNUNET_STATISTICS_update (stats, "# flood messages started", 1, GNUNET_NO); |
613 | GNUNET_STATISTICS_update (stats, "# flood messages transmitted", 1, | 603 | GNUNET_STATISTICS_update (stats, "# flood messages transmitted", 1, |
@@ -887,10 +877,8 @@ find_proof (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
887 | if (nse_work_required <= count_leading_zeroes (&result)) | 877 | if (nse_work_required <= count_leading_zeroes (&result)) |
888 | { | 878 | { |
889 | my_proof = counter; | 879 | my_proof = counter; |
890 | #if DEBUG_NSE | ||
891 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Proof of work found: %llu!\n", | 880 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Proof of work found: %llu!\n", |
892 | (unsigned long long) GNUNET_ntohll (counter)); | 881 | (unsigned long long) GNUNET_ntohll (counter)); |
893 | #endif | ||
894 | write_proof (); | 882 | write_proof (); |
895 | setup_flood_message (estimate_index, current_timestamp); | 883 | setup_flood_message (estimate_index, current_timestamp); |
896 | return; | 884 | return; |
@@ -900,10 +888,8 @@ find_proof (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
900 | } | 888 | } |
901 | if (my_proof / (100 * ROUND_SIZE) < counter / (100 * ROUND_SIZE)) | 889 | if (my_proof / (100 * ROUND_SIZE) < counter / (100 * ROUND_SIZE)) |
902 | { | 890 | { |
903 | #if DEBUG_NSE | ||
904 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testing proofs currently at %llu\n", | 891 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testing proofs currently at %llu\n", |
905 | (unsigned long long) counter); | 892 | (unsigned long long) counter); |
906 | #endif | ||
907 | /* remember progress every 100 rounds */ | 893 | /* remember progress every 100 rounds */ |
908 | my_proof = counter; | 894 | my_proof = counter; |
909 | write_proof (); | 895 | write_proof (); |
@@ -1207,10 +1193,8 @@ handle_core_connect (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
1207 | { | 1193 | { |
1208 | struct NSEPeerEntry *peer_entry; | 1194 | struct NSEPeerEntry *peer_entry; |
1209 | 1195 | ||
1210 | #if DEBUG_NSE | ||
1211 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer `%s' connected to us\n", | 1196 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer `%s' connected to us\n", |
1212 | GNUNET_i2s (peer)); | 1197 | GNUNET_i2s (peer)); |
1213 | #endif | ||
1214 | peer_entry = GNUNET_malloc (sizeof (struct NSEPeerEntry)); | 1198 | peer_entry = GNUNET_malloc (sizeof (struct NSEPeerEntry)); |
1215 | peer_entry->id = *peer; | 1199 | peer_entry->id = *peer; |
1216 | GNUNET_assert (GNUNET_OK == | 1200 | GNUNET_assert (GNUNET_OK == |
@@ -1236,10 +1220,8 @@ handle_core_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) | |||
1236 | { | 1220 | { |
1237 | struct NSEPeerEntry *pos; | 1221 | struct NSEPeerEntry *pos; |
1238 | 1222 | ||
1239 | #if DEBUG_NSE | ||
1240 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer `%s' disconnected from us\n", | 1223 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer `%s' disconnected from us\n", |
1241 | GNUNET_i2s (peer)); | 1224 | GNUNET_i2s (peer)); |
1242 | #endif | ||
1243 | pos = GNUNET_CONTAINER_multihashmap_get (peers, &peer->hashPubKey); | 1225 | pos = GNUNET_CONTAINER_multihashmap_get (peers, &peer->hashPubKey); |
1244 | if (NULL == pos) | 1226 | if (NULL == pos) |
1245 | { | 1227 | { |
diff --git a/src/nse/nse_api.c b/src/nse/nse_api.c index 2fa8af2e5..9a44197c0 100644 --- a/src/nse/nse_api.c +++ b/src/nse/nse_api.c | |||
@@ -149,11 +149,9 @@ reschedule_connect (struct GNUNET_NSE_Handle *h) | |||
149 | h->client = NULL; | 149 | h->client = NULL; |
150 | } | 150 | } |
151 | 151 | ||
152 | #if DEBUG_NSE | ||
153 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 152 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
154 | "Scheduling task to reconnect to nse service in %llu ms.\n", | 153 | "Scheduling task to reconnect to nse service in %llu ms.\n", |
155 | h->reconnect_delay.rel_value); | 154 | h->reconnect_delay.rel_value); |
156 | #endif | ||
157 | h->reconnect_task = | 155 | h->reconnect_task = |
158 | GNUNET_SCHEDULER_add_delayed (h->reconnect_delay, &reconnect, h); | 156 | GNUNET_SCHEDULER_add_delayed (h->reconnect_delay, &reconnect, h); |
159 | if (h->reconnect_delay.rel_value == 0) | 157 | if (h->reconnect_delay.rel_value == 0) |
@@ -187,16 +185,12 @@ send_start (void *cls, size_t size, void *buf) | |||
187 | if (buf == NULL) | 185 | if (buf == NULL) |
188 | { | 186 | { |
189 | /* Connect error... */ | 187 | /* Connect error... */ |
190 | #if DEBUG_NSE | ||
191 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 188 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
192 | "Shutdown while trying to transmit `%s' request.\n", "START"); | 189 | "Shutdown while trying to transmit `%s' request.\n", "START"); |
193 | #endif | ||
194 | reschedule_connect (h); | 190 | reschedule_connect (h); |
195 | return 0; | 191 | return 0; |
196 | } | 192 | } |
197 | #if DEBUG_NSE | ||
198 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Transmitting `%s' request.\n", "START"); | 193 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Transmitting `%s' request.\n", "START"); |
199 | #endif | ||
200 | GNUNET_assert (size >= sizeof (struct GNUNET_MessageHeader)); | 194 | GNUNET_assert (size >= sizeof (struct GNUNET_MessageHeader)); |
201 | 195 | ||
202 | msg = (struct GNUNET_MessageHeader *) buf; | 196 | msg = (struct GNUNET_MessageHeader *) buf; |
@@ -225,10 +219,8 @@ reconnect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
225 | /* shutdown, just give up */ | 219 | /* shutdown, just give up */ |
226 | return; | 220 | return; |
227 | } | 221 | } |
228 | #if DEBUG_NSE | ||
229 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 222 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
230 | "Connecting to network size estimation service.\n"); | 223 | "Connecting to network size estimation service.\n"); |
231 | #endif | ||
232 | GNUNET_assert (h->client == NULL); | 224 | GNUNET_assert (h->client == NULL); |
233 | h->client = GNUNET_CLIENT_connect ("nse", h->cfg); | 225 | h->client = GNUNET_CLIENT_connect ("nse", h->cfg); |
234 | GNUNET_assert (h->client != NULL); | 226 | GNUNET_assert (h->client != NULL); |
diff --git a/src/nse/test_nse_api.c b/src/nse/test_nse_api.c index f6cde3fe4..658c8b9a5 100644 --- a/src/nse/test_nse_api.c +++ b/src/nse/test_nse_api.c | |||
@@ -29,8 +29,6 @@ | |||
29 | #include "gnunet_scheduler_lib.h" | 29 | #include "gnunet_scheduler_lib.h" |
30 | #include "gnunet_nse_service.h" | 30 | #include "gnunet_nse_service.h" |
31 | 31 | ||
32 | #define DEBUG_NSE GNUNET_YES | ||
33 | |||
34 | #define START_ARM GNUNET_YES | 32 | #define START_ARM GNUNET_YES |
35 | 33 | ||
36 | static struct GNUNET_NSE_Handle *h; | 34 | static struct GNUNET_NSE_Handle *h; |
@@ -147,11 +145,7 @@ check () | |||
147 | char *const argv[] = { "test-nse-api", | 145 | char *const argv[] = { "test-nse-api", |
148 | "-c", | 146 | "-c", |
149 | "test_nse.conf", | 147 | "test_nse.conf", |
150 | #if DEBUG_NSE | ||
151 | "-L", "DEBUG", | ||
152 | #else | ||
153 | "-L", "WARNING", | 148 | "-L", "WARNING", |
154 | #endif | ||
155 | NULL | 149 | NULL |
156 | }; | 150 | }; |
157 | struct GNUNET_GETOPT_CommandLineOption options[] = { | 151 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
@@ -173,14 +167,9 @@ main (int argc, char *argv[]) | |||
173 | int ret; | 167 | int ret; |
174 | 168 | ||
175 | GNUNET_log_setup ("test_nse_api", | 169 | GNUNET_log_setup ("test_nse_api", |
176 | #if DEBUG_NSE | ||
177 | "DEBUG", | ||
178 | #else | ||
179 | "WARNING", | 170 | "WARNING", |
180 | #endif | ||
181 | NULL); | 171 | NULL); |
182 | ret = check (); | 172 | ret = check (); |
183 | |||
184 | return ret; | 173 | return ret; |
185 | } | 174 | } |
186 | 175 | ||