From d49f81bb38f557a674b6bdfcf13fe3181dbab0bc Mon Sep 17 00:00:00 2001 From: "Nathan S. Evans" Date: Fri, 14 Jan 2011 18:40:06 +0000 Subject: [PATCH] printf debugging --- src/dht/gnunet-dht-driver.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/dht/gnunet-dht-driver.c b/src/dht/gnunet-dht-driver.c index 58dad873e..84a473b0d 100644 --- a/src/dht/gnunet-dht-driver.c +++ b/src/dht/gnunet-dht-driver.c @@ -2371,6 +2371,7 @@ choose_next_malicious (struct GNUNET_TESTING_PeerGroup *pg, struct GNUNET_CONTAI int nearest; int bits_match; int curr_distance; + int count; struct GNUNET_TESTING_Daemon *temp_daemon; GNUNET_HashCode uid_hash; @@ -2401,11 +2402,15 @@ choose_next_malicious (struct GNUNET_TESTING_PeerGroup *pg, struct GNUNET_CONTAI { nearest = GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, num_peers); hash_from_uid(nearest, &uid_hash); - while (GNUNET_YES == GNUNET_CONTAINER_bloomfilter_test (bloom, &uid_hash)) + while ((GNUNET_YES == GNUNET_CONTAINER_bloomfilter_test (bloom, &uid_hash)) && (count < num_peers)) { + GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Peer %d already in bloom (tried %d times)\n", nearest, count); nearest = GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, num_peers); hash_from_uid(nearest, &uid_hash); + count++; } + if (count == num_peers) + GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Tried %d times to find a peer, selecting %d at random!!\n", count, nearest); } return nearest; -- 2.25.1