This file is part of GNUnet
Copyright (C) 2010, 2013 GNUnet e.V.
- GNUnet is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published
- by the Free Software Foundation; either version 3, or (at your
- option) any later version.
+ GNUnet is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Affero General Public License as published
+ by the Free Software Foundation, either version 3 of the License,
+ or (at your option) any later version.
GNUnet is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
+ Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
- You should have received a copy of the GNU General Public License
- along with GNUnet; see the file COPYING. If not, write to the
- Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
+ SPDX-License-Identifier: AGPL3.0-or-later
*/
/**
#include "gnunet_fs_service.h"
#include "block_fs.h"
#include "gnunet_signatures.h"
-#include "gnunet_constants.h"
#include "gnunet_block_group_lib.h"
#define BLOOMFILTER_K 16
-/**
- * How many bytes should a bloomfilter be if we have already seen
- * entry_count responses? Note that #GNUNET_CONSTANTS_BLOOMFILTER_K
- * gives us the number of bits set per entry. Furthermore, we should
- * not re-size the filter too often (to keep it cheap).
- *
- * Since other peers will also add entries but not resize the filter,
- * we should generally pick a slightly larger size than what the
- * strict math would suggest.
- *
- * @param entry_count expected number of entries in the Bloom filter
- * @return must be a power of two and smaller or equal to 2^15.
- */
-static size_t
-compute_bloomfilter_size (unsigned int entry_count)
-{
- size_t size;
- unsigned int ideal = (entry_count * GNUNET_CONSTANTS_BLOOMFILTER_K) / 4;
- uint16_t max = 1 << 15;
-
- if (entry_count > max)
- return max;
- size = 8;
- while ((size < max) && (size < ideal))
- size *= 2;
- if (size > max)
- return max;
- return size;
-}
-
-
/**
* Create a new block group.
*
switch (type)
{
case GNUNET_BLOCK_TYPE_FS_DBLOCK:
+ GNUNET_break (NULL == va_arg (va, const char *));
return NULL;
case GNUNET_BLOCK_TYPE_FS_IBLOCK:
+ GNUNET_break (NULL == va_arg (va, const char *));
return NULL;
case GNUNET_BLOCK_TYPE_FS_UBLOCK:
guard = va_arg (va, const char *);
- if (0 != memcmp (guard,
- "fs-seen-set-size",
- strlen ("fs-seen-set-size")))
+ if (0 == strcmp (guard,
+ "seen-set-size"))
{
- /* va-args invalid! bad bug, complain! */
- GNUNET_break (0);
- size = 8;
+ size = GNUNET_BLOCK_GROUP_compute_bloomfilter_size (va_arg (va, unsigned int),
+ BLOOMFILTER_K);
+ }
+ else if (0 == strcmp (guard,
+ "filter-size"))
+ {
+ size = va_arg (va, unsigned int);
}
else
{
- size = compute_bloomfilter_size (va_arg (va, unsigned int));
+ /* va-args invalid! bad bug, complain! */
+ GNUNET_break (0);
+ size = 8;
}
if (0 == size)
size = raw_data_size; /* not for us to determine, use what we got! */
+ GNUNET_break (NULL == va_arg (va, const char *));
return GNUNET_BLOCK_GROUP_bf_create (cls,
size,
BLOOMFILTER_K,
raw_data,
raw_data_size);
default:
+ GNUNET_break (NULL == va_arg (va, const char *));
GNUNET_break (0);
return NULL;
}
* be done with the #GNUNET_BLOCK_get_key() function.
*
* @param cls closure
+ * @param ctx block context
* @param type block type
* @param bg group to use for evaluation
* @param eo control flags
*/
static enum GNUNET_BLOCK_EvaluationResult
block_plugin_fs_evaluate (void *cls,
+ struct GNUNET_BLOCK_Context *ctx,
enum GNUNET_BLOCK_Type type,
struct GNUNET_BLOCK_Group *bg,
enum GNUNET_BLOCK_EvaluationOptions eo,
void *
libgnunet_plugin_block_fs_done (void *cls)
{
- struct GNUNET_TRANSPORT_PluginFunctions *api = cls;
+ struct GNUNET_BLOCK_PluginFunctions *api = cls;
GNUNET_free (api);
return NULL;