/*
This file is part of GNUnet.
- (C) 2001-2012 Christian Grothoff (and other contributing authors)
+ (C) 2001-2013 Christian Grothoff (and other contributing authors)
GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
struct GNUNET_SERVER_Client *handle;
/**
- * Messages that this client has declared interest in
+ * Messages that this client has declared interest in.
+ * Indexed by a GMC_hash32 (type), contains *Client.
*/
struct GNUNET_CONTAINER_MultiHashMap *types;
*
* @return GNUNET_YES or GNUNET_NO, depending on subscription status
*
- * FIXME: use of crypto_hash slows it down
- * The hash function alone takes 8-10us out of the ~55us for the whole
+ * A real hash function alone takes 8-10us out of the ~55us for the whole
* process of retransmitting the message from one local client to another.
- * Find faster implementation!
+ * GMC_hash32 aim to imporve this speed.
*/
static int
client_is_subscribed (uint16_t message_type, struct MeshClient *c)
if (NULL == c->types)
return GNUNET_NO;
- GNUNET_CRYPTO_hash (&message_type, sizeof (uint16_t), &hc);
+ GMC_hash32 ((uint32_t) message_type, &hc);
return GNUNET_CONTAINER_multihashmap_contains (c->types, &hc);
}
{
u16 = ntohs (t[i]);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " msg type: %u\n", u16);
- GNUNET_CRYPTO_hash (&u16, sizeof (u16), &hc); // FIXME pseudo hash
+ GMC_hash32 ((uint32_t) u16, &hc);
/* store in clients hashmap */
GNUNET_CONTAINER_multihashmap_put (c->types, &hc, c,
GMC_min_pid (uint32_t a, uint32_t b);
+/**
+ * Expand a 32 bit value (message type) into a hash for a MultiHashMap (fast).
+ * WARNING: do not use for anything other than MultiHashMap!
+ * does not alter anything other than bits used by idx_of !
+ *
+ * @param i 32 bit integer value.
+ * @param h Hash code to fill.
+ */
+void
+GMC_hash32 (uint32_t i, struct GNUNET_HashCode *h);
+
+
/**
* Convert a message type into a string to help debug
* Generated with:
#include "mesh.h"
-/**
- * Check if one pid is bigger than other, accounting for overflow.
- *
- * @param bigger Argument that should be bigger.
- * @param smaller Argument that should be smaller.
- *
- * @return True if bigger (arg1) has a higher value than smaller (arg 2).
- */
int
GMC_is_pid_bigger (uint32_t bigger, uint32_t smaller)
{
(bigger > smaller && GNUNET_NO == PID_OVERFLOW(bigger, smaller)));
}
-/**
- * Get the higher ACK value out of two values, taking in account overflow.
- *
- * @param a First ACK value.
- * @param b Second ACK value.
- *
- * @return Highest ACK value from the two.
- */
+
uint32_t
GMC_max_pid (uint32_t a, uint32_t b)
{
}
-/**
- * Get the lower ACK value out of two values, taking in account overflow.
- *
- * @param a First ACK value.
- * @param b Second ACK value.
- *
- * @return Lowest ACK value from the two.
- */
uint32_t
GMC_min_pid (uint32_t a, uint32_t b)
{
return a;
}
+void
+GMC_hash32 (uint32_t i, struct GNUNET_HashCode *h)
+{
+ *(unsigned int *) h = i;
+}
+
#if !defined(GNUNET_CULL_LOGGING)
const char *