From: Nathan S. Evans Date: Tue, 25 Jan 2011 13:36:38 +0000 (+0000) Subject: bloom size fix X-Git-Tag: initial-import-from-subversion-38251~19254 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=8dd553709633200a2224d6010fd5c62f42a382a0;p=oweals%2Fgnunet.git bloom size fix --- diff --git a/src/dht/gnunet-dht-driver.c b/src/dht/gnunet-dht-driver.c index 456f19c3a..79ee22c1d 100644 --- a/src/dht/gnunet-dht-driver.c +++ b/src/dht/gnunet-dht-driver.c @@ -2412,6 +2412,7 @@ 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); + count = 0; 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); @@ -2710,7 +2711,7 @@ run (void *cls, int count; int ret; int line_number; - + int k; config = cfg; rounds_finished = 0; @@ -3077,8 +3078,13 @@ run (void *cls, } /* Create the bloomfilter for choosing which peers to set malicious */ + + /* Bloomfilter size must be 2^k for some integer k */ + k = 1; + while (1 << k < malicious_droppers) + k++; if (malicious_droppers > 0) - malicious_bloom = GNUNET_CONTAINER_bloomfilter_init (NULL, DHT_BLOOM_K * malicious_droppers, DHT_BLOOM_K); + malicious_bloom = GNUNET_CONTAINER_bloomfilter_init (NULL, 1 << k, DHT_BLOOM_K); /* The normal behavior of the DHT is to do find peer requests * on its own. Only if this is explicitly turned off should