From 4346e3b1d6f830c8862fda17262fe0a41359be10 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sat, 18 Sep 2010 04:36:48 +0000 Subject: move mingle function --- src/block/Makefile.am | 1 + src/block/block.c | 22 ++++++++++++++++++++++ src/block/plugin_block_fs.c | 21 ++------------------- 3 files changed, 25 insertions(+), 19 deletions(-) (limited to 'src/block') diff --git a/src/block/Makefile.am b/src/block/Makefile.am index 238c48af3..2fc0c0081 100644 --- a/src/block/Makefile.am +++ b/src/block/Makefile.am @@ -19,6 +19,7 @@ plugin_LTLIBRARIES = \ libgnunet_plugin_block_fs_la_SOURCES = \ plugin_block_fs.c libgnunet_plugin_block_fs_la_LIBADD = \ + $(top_builddir)/src/block/libgnunetblock.la \ $(top_builddir)/src/util/libgnunetutil.la libgnunet_plugin_block_fs_la_LDFLAGS = \ $(GN_PLUGIN_LDFLAGS) diff --git a/src/block/block.c b/src/block/block.c index 8d8018b50..29382dad1 100644 --- a/src/block/block.c +++ b/src/block/block.c @@ -46,6 +46,7 @@ struct Plugin struct GNUNET_BLOCK_PluginFunctions *api; }; + /** * Handle to an initialized block library. */ @@ -63,6 +64,27 @@ struct GNUNET_BLOCK_Context }; +/** + * Mingle hash with the mingle_number to produce different bits. + * + * @param in original hash code + * @param mingle_number number for hash permutation + * @param hc where to store the result. + */ +void +GNUNET_BLOCK_mingle_hash (const GNUNET_HashCode * in, + int32_t mingle_number, + GNUNET_HashCode * hc) +{ + GNUNET_HashCode m; + + GNUNET_CRYPTO_hash (&mingle_number, + sizeof (int32_t), + &m); + GNUNET_CRYPTO_hash_xor (&m, in, hc); +} + + /** * Create a block context. Loads the block plugins. * diff --git a/src/block/plugin_block_fs.c b/src/block/plugin_block_fs.c index 0626e458c..a5219b706 100644 --- a/src/block/plugin_block_fs.c +++ b/src/block/plugin_block_fs.c @@ -37,23 +37,6 @@ */ #define BLOOMFILTER_K 16 -/** - * Mingle hash with the mingle_number to produce different bits. - */ -static void -mingle_hash (const GNUNET_HashCode * in, - int32_t mingle_number, - GNUNET_HashCode * hc) -{ - GNUNET_HashCode m; - - GNUNET_CRYPTO_hash (&mingle_number, - sizeof (int32_t), - &m); - GNUNET_CRYPTO_hash_xor (&m, in, hc); -} - - /** * Function called to validate a reply or a request. For * request evaluation, simply pass "NULL" for the reply_block. @@ -113,7 +96,7 @@ block_plugin_fs_evaluate (void *cls, GNUNET_CRYPTO_hash (reply_block, reply_block_size, &chash); - mingle_hash (&chash, bf_mutator, &mhash); + GNUNET_BLOCK_mingle_hash (&chash, bf_mutator, &mhash); if (NULL != *bf) { if (GNUNET_YES == GNUNET_CONTAINER_bloomfilter_test (*bf, @@ -154,7 +137,7 @@ block_plugin_fs_evaluate (void *cls, GNUNET_CRYPTO_hash (reply_block, reply_block_size, &chash); - mingle_hash (&chash, bf_mutator, &mhash); + GNUNET_BLOCK_mingle_hash (&chash, bf_mutator, &mhash); if (NULL != *bf) { if (GNUNET_YES == GNUNET_CONTAINER_bloomfilter_test (*bf, -- cgit v1.2.3