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