indentation
[oweals/gnunet.git] / src / util / container_bloomfilter.c
1 /*
2      This file is part of GNUnet.
3      (C) 2001, 2002, 2003, 2004, 2006, 2008 Christian Grothoff (and other contributing authors)
4
5      GNUnet is free software; you can redistribute it and/or modify
6      it under the terms of the GNU General Public License as published
7      by the Free Software Foundation; either version 2, or (at your
8      option) any later version.
9
10      GNUnet is distributed in the hope that it will be useful, but
11      WITHOUT ANY WARRANTY; without even the implied warranty of
12      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13      General Public License for more details.
14
15      You should have received a copy of the GNU General Public License
16      along with GNUnet; see the file COPYING.  If not, write to the
17      Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18      Boston, MA 02111-1307, USA.
19 */
20 /**
21  * @file util/container_bloomfilter.c
22  * @brief data structure used to reduce disk accesses.
23  *
24  * The idea basically: Create a signature for each element in the
25  * database. Add those signatures to a bit array. When doing a lookup,
26  * check if the bit array matches the signature of the requested
27  * element. If yes, address the disk, otherwise return 'not found'.
28  *
29  * A property of the bloom filter is that sometimes we will have
30  * a match even if the element is not on the disk (then we do
31  * an unnecessary disk access), but what's most important is that
32  * we never get a single "false negative".
33  *
34  * To be able to delete entries from the bloom filter, we maintain
35  * a 4 bit counter in the file on the drive (we still use only one
36  * bit in memory).
37  *
38  * @author Igor Wronsky
39  * @author Christian Grothoff
40  */
41
42 #include "platform.h"
43 #include "gnunet_common.h"
44 #include "gnunet_container_lib.h"
45 #include "gnunet_disk_lib.h"
46
47 struct GNUNET_CONTAINER_BloomFilter
48 {
49
50   /**
51    * The actual bloomfilter bit array
52    */
53   char *bitArray;
54
55   /**
56    * Filename of the filter
57    */
58   char *filename;
59
60   /**
61    * The bit counter file on disk
62    */
63   struct GNUNET_DISK_FileHandle *fh;
64
65   /**
66    * How many bits we set for each stored element
67    */
68   unsigned int addressesPerElement;
69
70   /**
71    * Size of bitArray in bytes
72    */
73   size_t bitArraySize;
74
75 };
76
77
78
79 /**
80  * Get size of the bloom filter.
81  *
82  * @param bf the filter
83  * @return number of bytes used for the data of the bloom filter
84  */
85 size_t
86 GNUNET_CONTAINER_bloomfilter_get_size (const struct GNUNET_CONTAINER_BloomFilter
87                                        *bf)
88 {
89   if (bf == NULL)
90     return 0;
91   return bf->bitArraySize;
92 }
93
94
95 /**
96  * Copy an existing memory.  Any association with a file
97  * on-disk will be lost in the process.
98  * @param bf the filter to copy
99  * @return copy of the bf
100  */
101 struct GNUNET_CONTAINER_BloomFilter *
102 GNUNET_CONTAINER_bloomfilter_copy (const struct GNUNET_CONTAINER_BloomFilter
103                                    *bf)
104 {
105   return GNUNET_CONTAINER_bloomfilter_init (bf->bitArray,
106                                             bf->bitArraySize,
107                                             bf->addressesPerElement);
108 }
109
110
111 /**
112  * Sets a bit active in the bitArray. Increment bit-specific
113  * usage counter on disk only if below 4bit max (==15).
114  *
115  * @param bitArray memory area to set the bit in
116  * @param bitIdx which bit to set
117  */
118 static void
119 setBit (char *bitArray, unsigned int bitIdx)
120 {
121   size_t arraySlot;
122   unsigned int targetBit;
123
124   arraySlot = bitIdx / 8;
125   targetBit = (1L << (bitIdx % 8));
126   bitArray[arraySlot] |= targetBit;
127 }
128
129 /**
130  * Clears a bit from bitArray. Bit is cleared from the array
131  * only if the respective usage counter on the disk hits/is zero.
132  *
133  * @param bitArray memory area to set the bit in
134  * @param bitIdx which bit to unset
135  */
136 static void
137 clearBit (char *bitArray, unsigned int bitIdx)
138 {
139   size_t slot;
140   unsigned int targetBit;
141
142   slot = bitIdx / 8;
143   targetBit = (1L << (bitIdx % 8));
144   bitArray[slot] = bitArray[slot] & (~targetBit);
145 }
146
147 /**
148  * Checks if a bit is active in the bitArray
149  *
150  * @param bitArray memory area to set the bit in
151  * @param bitIdx which bit to test
152  * @return GNUNET_YES if the bit is set, GNUNET_NO if not.
153  */
154 static int
155 testBit (char *bitArray, unsigned int bitIdx)
156 {
157   size_t slot;
158   unsigned int targetBit;
159
160   slot = bitIdx / 8;
161   targetBit = (1L << (bitIdx % 8));
162   if (bitArray[slot] & targetBit)
163     return GNUNET_YES;
164   else
165     return GNUNET_NO;
166 }
167
168 /**
169  * Sets a bit active in the bitArray and increments
170  * bit-specific usage counter on disk (but only if
171  * the counter was below 4 bit max (==15)).
172  *
173  * @param bitArray memory area to set the bit in
174  * @param bitIdx which bit to test
175  * @param fh A file to keep the 4 bit address usage counters in
176  */
177 static void
178 incrementBit (char *bitArray, unsigned int bitIdx,
179               const struct GNUNET_DISK_FileHandle *fh)
180 {
181   off_t fileSlot;
182   unsigned char value;
183   unsigned int high;
184   unsigned int low;
185   unsigned int targetLoc;
186
187   setBit (bitArray, bitIdx);
188   if (GNUNET_DISK_handle_invalid (fh))
189     return;
190   /* Update the counter file on disk */
191   fileSlot = bitIdx / 2;
192   targetLoc = bitIdx % 2;
193
194   GNUNET_assert (fileSlot ==
195                  GNUNET_DISK_file_seek (fh, fileSlot, GNUNET_DISK_SEEK_SET));
196   if (1 != GNUNET_DISK_file_read (fh, &value, 1))
197     value = 0;
198   low = value & 0xF;
199   high = (value & (~0xF)) >> 4;
200
201   if (targetLoc == 0)
202   {
203     if (low < 0xF)
204       low++;
205   }
206   else
207   {
208     if (high < 0xF)
209       high++;
210   }
211   value = ((high << 4) | low);
212   GNUNET_assert (fileSlot == GNUNET_DISK_file_seek (fh,
213                                                     fileSlot,
214                                                     GNUNET_DISK_SEEK_SET));
215   GNUNET_assert (1 == GNUNET_DISK_file_write (fh, &value, 1));
216 }
217
218 /**
219  * Clears a bit from bitArray if the respective usage
220  * counter on the disk hits/is zero.
221  *
222  * @param bitArray memory area to set the bit in
223  * @param bitIdx which bit to test
224  * @param fh A file to keep the 4bit address usage counters in
225  */
226 static void
227 decrementBit (char *bitArray, unsigned int bitIdx,
228               const struct GNUNET_DISK_FileHandle *fh)
229 {
230   off_t fileSlot;
231   unsigned char value;
232   unsigned int high;
233   unsigned int low;
234   unsigned int targetLoc;
235
236   if (GNUNET_DISK_handle_invalid (fh))
237     return;                     /* cannot decrement! */
238   /* Each char slot in the counter file holds two 4 bit counters */
239   fileSlot = bitIdx / 2;
240   targetLoc = bitIdx % 2;
241   GNUNET_DISK_file_seek (fh, fileSlot, GNUNET_DISK_SEEK_SET);
242   if (1 != GNUNET_DISK_file_read (fh, &value, 1))
243     value = 0;
244   low = value & 0xF;
245   high = (value & 0xF0) >> 4;
246
247   /* decrement, but once we have reached the max, never go back! */
248   if (targetLoc == 0)
249   {
250     if ((low > 0) && (low < 0xF))
251       low--;
252     if (low == 0)
253     {
254       clearBit (bitArray, bitIdx);
255     }
256   }
257   else
258   {
259     if ((high > 0) && (high < 0xF))
260       high--;
261     if (high == 0)
262     {
263       clearBit (bitArray, bitIdx);
264     }
265   }
266   value = ((high << 4) | low);
267   GNUNET_DISK_file_seek (fh, fileSlot, GNUNET_DISK_SEEK_SET);
268   GNUNET_assert (1 == GNUNET_DISK_file_write (fh, &value, 1));
269 }
270
271 #define BUFFSIZE 65536
272
273 /**
274  * Creates a file filled with zeroes
275  *
276  * @param fh the file handle
277  * @param size the size of the file
278  * @return GNUNET_OK if created ok, GNUNET_SYSERR otherwise
279  */
280 static int
281 makeEmptyFile (const struct GNUNET_DISK_FileHandle *fh, size_t size)
282 {
283   char *buffer;
284   size_t bytesleft = size;
285   int res = 0;
286
287   if (GNUNET_DISK_handle_invalid (fh))
288     return GNUNET_SYSERR;
289   buffer = GNUNET_malloc (BUFFSIZE);
290   memset (buffer, 0, BUFFSIZE);
291   GNUNET_DISK_file_seek (fh, 0, GNUNET_DISK_SEEK_SET);
292
293   while (bytesleft > 0)
294   {
295     if (bytesleft > BUFFSIZE)
296     {
297       res = GNUNET_DISK_file_write (fh, buffer, BUFFSIZE);
298       bytesleft -= BUFFSIZE;
299     }
300     else
301     {
302       res = GNUNET_DISK_file_write (fh, buffer, bytesleft);
303       bytesleft = 0;
304     }
305     GNUNET_assert (res != GNUNET_SYSERR);
306   }
307   GNUNET_free (buffer);
308   return GNUNET_OK;
309 }
310
311 /* ************** GNUNET_CONTAINER_BloomFilter iterator ********* */
312
313 /**
314  * Iterator (callback) method to be called by the
315  * bloomfilter iterator on each bit that is to be
316  * set or tested for the key.
317  *
318  * @param cls closure
319  * @param bf the filter to manipulate
320  * @param bit the current bit
321  */
322 typedef void (*BitIterator) (void *cls,
323                              const struct GNUNET_CONTAINER_BloomFilter * bf,
324                              unsigned int bit);
325
326 /**
327  * Call an iterator for each bit that the bloomfilter
328  * must test or set for this element.
329  *
330  * @param bf the filter
331  * @param callback the method to call
332  * @param arg extra argument to callback
333  * @param key the key for which we iterate over the BF bits
334  */
335 static void
336 iterateBits (const struct GNUNET_CONTAINER_BloomFilter *bf,
337              BitIterator callback, void *arg, const GNUNET_HashCode * key)
338 {
339   GNUNET_HashCode tmp[2];
340   int bitCount;
341   int round;
342   unsigned int slot = 0;
343
344   bitCount = bf->addressesPerElement;
345   memcpy (&tmp[0], key, sizeof (GNUNET_HashCode));
346   round = 0;
347   while (bitCount > 0)
348   {
349     while (slot < (sizeof (GNUNET_HashCode) / sizeof (uint32_t)))
350     {
351       callback (arg,
352                 bf,
353                 (((uint32_t *) & tmp[round & 1])[slot]) &
354                 ((bf->bitArraySize * 8) - 1));
355       slot++;
356       bitCount--;
357       if (bitCount == 0)
358         break;
359     }
360     if (bitCount > 0)
361     {
362       GNUNET_CRYPTO_hash (&tmp[round & 1], sizeof (GNUNET_HashCode),
363                           &tmp[(round + 1) & 1]);
364       round++;
365       slot = 0;
366     }
367   }
368 }
369
370 /**
371  * Callback: increment bit
372  *
373  * @param cls pointer to writeable form of bf
374  * @param bf the filter to manipulate
375  * @param bit the bit to increment
376  */
377 static void
378 incrementBitCallback (void *cls,
379                       const struct GNUNET_CONTAINER_BloomFilter *bf,
380                       unsigned int bit)
381 {
382   struct GNUNET_CONTAINER_BloomFilter *b = cls;
383
384   incrementBit (b->bitArray, bit, bf->fh);
385 }
386
387 /**
388  * Callback: decrement bit
389  *
390  * @param cls pointer to writeable form of bf
391  * @param bf the filter to manipulate
392  * @param bit the bit to decrement
393  */
394 static void
395 decrementBitCallback (void *cls,
396                       const struct GNUNET_CONTAINER_BloomFilter *bf,
397                       unsigned int bit)
398 {
399   struct GNUNET_CONTAINER_BloomFilter *b = cls;
400
401   decrementBit (b->bitArray, bit, bf->fh);
402 }
403
404 /**
405  * Callback: test if all bits are set
406  *
407  * @param cls pointer set to GNUNET_NO if bit is not set
408  * @param bf the filter
409  * @param bit the bit to test
410  */
411 static void
412 testBitCallback (void *cls,
413                  const struct GNUNET_CONTAINER_BloomFilter *bf,
414                  unsigned int bit)
415 {
416   int *arg = cls;
417
418   if (GNUNET_NO == testBit (bf->bitArray, bit))
419     *arg = GNUNET_NO;
420 }
421
422 /* *********************** INTERFACE **************** */
423
424 /**
425  * Load a bloom-filter from a file.
426  *
427  * @param filename the name of the file (or the prefix)
428  * @param size the size of the bloom-filter (number of
429  *        bytes of storage space to use)
430  * @param k the number of GNUNET_CRYPTO_hash-functions to apply per
431  *        element (number of bits set per element in the set)
432  * @return the bloomfilter
433  */
434 struct GNUNET_CONTAINER_BloomFilter *
435 GNUNET_CONTAINER_bloomfilter_load (const char *filename,
436                                    size_t size, unsigned int k)
437 {
438   struct GNUNET_CONTAINER_BloomFilter *bf;
439   char *rbuff;
440   off_t pos;
441   int i;
442   size_t ui;
443
444   GNUNET_assert (NULL != filename);
445   if ((k == 0) || (size == 0))
446     return NULL;
447   if (size < BUFFSIZE)
448     size = BUFFSIZE;
449   ui = 1;
450   while (ui < size)
451     ui *= 2;
452   size = ui;                    /* make sure it's a power of 2 */
453
454   bf = GNUNET_malloc (sizeof (struct GNUNET_CONTAINER_BloomFilter));
455   /* Try to open a bloomfilter file */
456   bf->fh = GNUNET_DISK_file_open (filename, GNUNET_DISK_OPEN_READWRITE
457                                   | GNUNET_DISK_OPEN_CREATE,
458                                   GNUNET_DISK_PERM_USER_READ |
459                                   GNUNET_DISK_PERM_USER_WRITE);
460   if (NULL == bf->fh)
461   {
462     GNUNET_free (bf);
463     return NULL;
464   }
465   bf->filename = GNUNET_strdup (filename);
466   /* Alloc block */
467   bf->bitArray = GNUNET_malloc_large (size);
468   if (bf->bitArray == NULL)
469   {
470     if (bf->fh != NULL)
471       GNUNET_DISK_file_close (bf->fh);
472     GNUNET_free (bf->filename);
473     GNUNET_free (bf);
474     return NULL;
475   }
476   bf->bitArraySize = size;
477   bf->addressesPerElement = k;
478   memset (bf->bitArray, 0, bf->bitArraySize);
479
480   /* Read from the file what bits we can */
481   rbuff = GNUNET_malloc (BUFFSIZE);
482   pos = 0;
483   while (pos < size * 8)
484   {
485     int res;
486
487     res = GNUNET_DISK_file_read (bf->fh, rbuff, BUFFSIZE);
488     if (res == -1)
489     {
490       GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING,
491                                 "read", bf->filename);
492     }
493     if (res == 0)
494       break;                    /* is ok! we just did not use that many bits yet */
495     for (i = 0; i < res; i++)
496     {
497       if ((rbuff[i] & 0x0F) != 0)
498         setBit (bf->bitArray, pos + i * 2);
499       if ((rbuff[i] & 0xF0) != 0)
500         setBit (bf->bitArray, pos + i * 2 + 1);
501     }
502     if (res < BUFFSIZE)
503       break;
504     pos += BUFFSIZE * 2;        /* 2 bits per byte in the buffer */
505   }
506   GNUNET_free (rbuff);
507   return bf;
508 }
509
510
511 /**
512  * Create a bloom filter from raw bits.
513  *
514  * @param data the raw bits in memory (maybe NULL,
515  *        in which case all bits should be considered
516  *        to be zero).
517  * @param size the size of the bloom-filter (number of
518  *        bytes of storage space to use); also size of data
519  *        -- unless data is NULL
520  * @param k the number of GNUNET_CRYPTO_hash-functions to apply per
521  *        element (number of bits set per element in the set)
522  * @return the bloomfilter
523  */
524 struct GNUNET_CONTAINER_BloomFilter *
525 GNUNET_CONTAINER_bloomfilter_init (const char *data,
526                                    size_t size, unsigned int k)
527 {
528   struct GNUNET_CONTAINER_BloomFilter *bf;
529   size_t ui;
530
531   if ((k == 0) || (size == 0))
532     return NULL;
533   ui = 1;
534   while (ui < size)
535     ui *= 2;
536   if (size != ui)
537   {
538     GNUNET_break (0);
539     return NULL;
540   }
541   bf = GNUNET_malloc (sizeof (struct GNUNET_CONTAINER_BloomFilter));
542   bf->filename = NULL;
543   bf->fh = NULL;
544   bf->bitArray = GNUNET_malloc_large (size);
545   if (bf->bitArray == NULL)
546   {
547     GNUNET_free (bf);
548     return NULL;
549   }
550   bf->bitArraySize = size;
551   bf->addressesPerElement = k;
552   if (data != NULL)
553     memcpy (bf->bitArray, data, size);
554   else
555     memset (bf->bitArray, 0, bf->bitArraySize);
556   return bf;
557 }
558
559
560 /**
561  * Copy the raw data of this bloomfilter into
562  * the given data array.
563  *
564  * @param bf bloomfilter to take the raw data from
565  * @param data where to write the data
566  * @param size the size of the given data array
567  * @return GNUNET_SYSERR if the data array is not big enough
568  */
569 int
570 GNUNET_CONTAINER_bloomfilter_get_raw_data (const struct
571                                            GNUNET_CONTAINER_BloomFilter *bf,
572                                            char *data, size_t size)
573 {
574   if (NULL == bf)
575     return GNUNET_SYSERR;
576   if (bf->bitArraySize != size)
577     return GNUNET_SYSERR;
578   memcpy (data, bf->bitArray, size);
579   return GNUNET_OK;
580 }
581
582 /**
583  * Free the space associated with a filter
584  * in memory, flush to drive if needed (do not
585  * free the space on the drive)
586  *
587  * @param bf the filter
588  */
589 void
590 GNUNET_CONTAINER_bloomfilter_free (struct GNUNET_CONTAINER_BloomFilter *bf)
591 {
592   if (NULL == bf)
593     return;
594   if (bf->fh != NULL)
595     GNUNET_DISK_file_close (bf->fh);
596   GNUNET_free_non_null (bf->filename);
597   GNUNET_free (bf->bitArray);
598   GNUNET_free (bf);
599 }
600
601 /**
602  * Reset a bloom filter to empty. Clears the file on disk.
603  *
604  * @param bf the filter
605  */
606 void
607 GNUNET_CONTAINER_bloomfilter_clear (struct GNUNET_CONTAINER_BloomFilter *bf)
608 {
609   if (NULL == bf)
610     return;
611
612   memset (bf->bitArray, 0, bf->bitArraySize);
613   if (bf->filename != NULL)
614     makeEmptyFile (bf->fh, bf->bitArraySize * 4);
615 }
616
617
618 /**
619  * Test if an element is in the filter.
620  *
621  * @param e the element
622  * @param bf the filter
623  * @return GNUNET_YES if the element is in the filter, GNUNET_NO if not
624  */
625 int
626 GNUNET_CONTAINER_bloomfilter_test (const struct GNUNET_CONTAINER_BloomFilter
627                                    *bf, const GNUNET_HashCode * e)
628 {
629   int res;
630
631   if (NULL == bf)
632     return GNUNET_YES;
633   res = GNUNET_YES;
634   iterateBits (bf, &testBitCallback, &res, e);
635   return res;
636 }
637
638 /**
639  * Add an element to the filter
640  *
641  * @param bf the filter
642  * @param e the element
643  */
644 void
645 GNUNET_CONTAINER_bloomfilter_add (struct GNUNET_CONTAINER_BloomFilter *bf,
646                                   const GNUNET_HashCode * e)
647 {
648
649   if (NULL == bf)
650     return;
651   iterateBits (bf, &incrementBitCallback, bf, e);
652 }
653
654
655 /**
656  * Or the entries of the given raw data array with the
657  * data of the given bloom filter.  Assumes that
658  * the size of the data array and the current filter
659  * match.
660  *
661  * @param bf the filter
662  * @param data the data to or-in
663  * @param size number of bytes in data
664  */
665 int
666 GNUNET_CONTAINER_bloomfilter_or (struct GNUNET_CONTAINER_BloomFilter *bf,
667                                  const char *data, size_t size)
668 {
669   unsigned int i;
670   unsigned int n;
671   unsigned long long *fc;
672   const unsigned long long *dc;
673
674   if (NULL == bf)
675     return GNUNET_YES;
676   if (bf->bitArraySize != size)
677     return GNUNET_SYSERR;
678   fc = (unsigned long long *) bf->bitArray;
679   dc = (const unsigned long long *) data;
680   n = size / sizeof (unsigned long long);
681
682   for (i = 0; i < n; i++)
683     fc[i] |= dc[i];
684   for (i = n * sizeof (unsigned long long); i < size; i++)
685     bf->bitArray[i] |= data[i];
686   return GNUNET_OK;
687 }
688
689 /**
690  * Or the entries of the given raw data array with the
691  * data of the given bloom filter.  Assumes that
692  * the size of the data array and the current filter
693  * match.
694  *
695  * @param bf the filter
696  * @param to_or the bloomfilter to or-in
697  * @param size number of bytes in data
698  */
699 int
700 GNUNET_CONTAINER_bloomfilter_or2 (struct GNUNET_CONTAINER_BloomFilter *bf,
701                                   const struct GNUNET_CONTAINER_BloomFilter
702                                   *to_or, size_t size)
703 {
704   unsigned int i;
705   unsigned int n;
706   unsigned long long *fc;
707   const unsigned long long *dc;
708
709   if (NULL == bf)
710     return GNUNET_YES;
711   if (bf->bitArraySize != size)
712     return GNUNET_SYSERR;
713   fc = (unsigned long long *) bf->bitArray;
714   dc = (const unsigned long long *) to_or->bitArray;
715   n = size / sizeof (unsigned long long);
716
717   for (i = 0; i < n; i++)
718     fc[i] |= dc[i];
719   for (i = n * sizeof (unsigned long long); i < size; i++)
720     bf->bitArray[i] |= to_or->bitArray[i];
721   return GNUNET_OK;
722 }
723
724 /**
725  * Remove an element from the filter.
726  *
727  * @param bf the filter
728  * @param e the element to remove
729  */
730 void
731 GNUNET_CONTAINER_bloomfilter_remove (struct GNUNET_CONTAINER_BloomFilter *bf,
732                                      const GNUNET_HashCode * e)
733 {
734   if (NULL == bf)
735     return;
736   if (bf->filename == NULL)
737     return;
738   iterateBits (bf, &decrementBitCallback, bf, e);
739 }
740
741 /**
742  * Resize a bloom filter.  Note that this operation
743  * is pretty costly.  Essentially, the bloom filter
744  * needs to be completely re-build.
745  *
746  * @param bf the filter
747  * @param iterator an iterator over all elements stored in the BF
748  * @param iterator_cls argument to the iterator function
749  * @param size the new size for the filter
750  * @param k the new number of GNUNET_CRYPTO_hash-function to apply per element
751  */
752 void
753 GNUNET_CONTAINER_bloomfilter_resize (struct GNUNET_CONTAINER_BloomFilter *bf,
754                                      GNUNET_HashCodeIterator iterator,
755                                      void *iterator_cls,
756                                      size_t size, unsigned int k)
757 {
758   GNUNET_HashCode hc;
759   unsigned int i;
760
761   GNUNET_free (bf->bitArray);
762   i = 1;
763   while (i < size)
764     i *= 2;
765   size = i;                     /* make sure it's a power of 2 */
766
767   bf->bitArraySize = size;
768   bf->bitArray = GNUNET_malloc (size);
769   memset (bf->bitArray, 0, bf->bitArraySize);
770   if (bf->filename != NULL)
771     makeEmptyFile (bf->fh, bf->bitArraySize * 4);
772   while (GNUNET_YES == iterator (iterator_cls, &hc))
773     GNUNET_CONTAINER_bloomfilter_add (bf, &hc);
774 }
775
776 /* end of container_bloomfilter.c */