static int byzantine;
static int force_delta;
static int force_full;
-
-static unsigned int element_length = 32;
+static unsigned int element_size = 32;
/**
* Handle to the statistics service.
GNUNET_assert (NULL != key);
- ret = GNUNET_CONTAINER_multihashmap_remove (m, key, NULL);
+ ret = GNUNET_CONTAINER_multihashmap_remove_all (m, key);
if (GNUNET_OK != ret)
printf ("spurious element\n");
return GNUNET_YES;
GNUNET_assert (0);
}
- if (element->size != sizeof (struct GNUNET_HashCode))
+ if (element->size != element_size)
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"wrong element size: %u, expected %u\n",
GNUNET_log (GNUNET_ERROR_TYPE_INFO, "set %s: got element (%s)\n",
info->id, GNUNET_h2s (element->data));
GNUNET_assert (NULL != element->data);
+ struct GNUNET_HashCode data_hash;
+ GNUNET_CRYPTO_hash (element->data, element_size, &data_hash);
GNUNET_CONTAINER_multihashmap_put (info->received,
- element->data, NULL,
+ &data_hash, NULL,
GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE);
}
struct GNUNET_SET_Handle *set = cls;
struct GNUNET_SET_Element el;
- GNUNET_assert (element_length > 0);
- char payload[element_length];
-
- GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK, payload, element_length);
-
el.element_type = 0;
- el.data = payload;
- el.size = element_length;
+ el.data = value;
+ el.size = element_size;
GNUNET_SET_add_element (set, &el, NULL, NULL);
return GNUNET_YES;
}
config = cfg;
+ GNUNET_assert (element_size > 0);
+
if (GNUNET_OK != GNUNET_CRYPTO_get_peer_identity (cfg, &local_peer))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "could not retrieve host identity\n");
for (i = 0; i < num_a; i++)
{
- GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_STRONG, &hash);
- GNUNET_CONTAINER_multihashmap_put (info1.sent, &hash, NULL,
+ char *data = GNUNET_malloc (element_size);
+ GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK, data, element_size);
+ GNUNET_CRYPTO_hash (data, element_size, &hash);
+ GNUNET_CONTAINER_multihashmap_put (info1.sent, &hash, data,
GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE);
}
for (i = 0; i < num_b; i++)
{
- GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_STRONG, &hash);
- GNUNET_CONTAINER_multihashmap_put (info2.sent, &hash, NULL,
+ char *data = GNUNET_malloc (element_size);
+ GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK, data, element_size);
+ GNUNET_CRYPTO_hash (data, element_size, &hash);
+ GNUNET_CONTAINER_multihashmap_put (info2.sent, &hash, data,
GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE);
}
for (i = 0; i < num_c; i++)
{
- GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_STRONG, &hash);
- GNUNET_CONTAINER_multihashmap_put (common_sent, &hash, NULL,
+ char *data = GNUNET_malloc (element_size);
+ GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK, data, element_size);
+ GNUNET_CRYPTO_hash (data, element_size, &hash);
+ GNUNET_CONTAINER_multihashmap_put (common_sent, &hash, data,
GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE);
}
{ 'f', "force-full", NULL,
gettext_noop ("force sending full set"),
GNUNET_NO, &GNUNET_GETOPT_set_uint, &force_full },
- { 'w', "element-length", NULL,
- gettext_noop ("element length in byte"),
- GNUNET_NO, &GNUNET_GETOPT_set_uint, &element_length },
{ 'd', "force-delta", NULL,
gettext_noop ("number delta operation"),
GNUNET_NO, &GNUNET_GETOPT_set_uint, &force_delta },
{ 'x', "operation", NULL,
gettext_noop ("operation to execute"),
GNUNET_YES, &GNUNET_GETOPT_set_string, &op_str },
+ { 'w', "element-size", NULL,
+ gettext_noop ("element size"),
+ GNUNET_YES, &GNUNET_GETOPT_set_uint, &element_size },
{ 's', "statistics", NULL,
gettext_noop ("write statistics to file"),
GNUNET_YES, &GNUNET_GETOPT_set_filename, &statistics_filename },