aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2010-09-18 04:36:48 +0000
committerChristian Grothoff <christian@grothoff.org>2010-09-18 04:36:48 +0000
commit4346e3b1d6f830c8862fda17262fe0a41359be10 (patch)
treeb3f2add02a3d70c58c8b93cdaf619910ec2ce37a /src
parent29fa331cfde73bde39cb365f05a64fbe8583c41c (diff)
downloadgnunet-4346e3b1d6f830c8862fda17262fe0a41359be10.tar.gz
gnunet-4346e3b1d6f830c8862fda17262fe0a41359be10.zip
move mingle function
Diffstat (limited to 'src')
-rw-r--r--src/block/Makefile.am1
-rw-r--r--src/block/block.c22
-rw-r--r--src/block/plugin_block_fs.c21
3 files changed, 25 insertions, 19 deletions
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 = \
19libgnunet_plugin_block_fs_la_SOURCES = \ 19libgnunet_plugin_block_fs_la_SOURCES = \
20 plugin_block_fs.c 20 plugin_block_fs.c
21libgnunet_plugin_block_fs_la_LIBADD = \ 21libgnunet_plugin_block_fs_la_LIBADD = \
22 $(top_builddir)/src/block/libgnunetblock.la \
22 $(top_builddir)/src/util/libgnunetutil.la 23 $(top_builddir)/src/util/libgnunetutil.la
23libgnunet_plugin_block_fs_la_LDFLAGS = \ 24libgnunet_plugin_block_fs_la_LDFLAGS = \
24 $(GN_PLUGIN_LDFLAGS) 25 $(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
46 struct GNUNET_BLOCK_PluginFunctions *api; 46 struct GNUNET_BLOCK_PluginFunctions *api;
47}; 47};
48 48
49
49/** 50/**
50 * Handle to an initialized block library. 51 * Handle to an initialized block library.
51 */ 52 */
@@ -64,6 +65,27 @@ struct GNUNET_BLOCK_Context
64 65
65 66
66/** 67/**
68 * Mingle hash with the mingle_number to produce different bits.
69 *
70 * @param in original hash code
71 * @param mingle_number number for hash permutation
72 * @param hc where to store the result.
73 */
74void
75GNUNET_BLOCK_mingle_hash (const GNUNET_HashCode * in,
76 int32_t mingle_number,
77 GNUNET_HashCode * hc)
78{
79 GNUNET_HashCode m;
80
81 GNUNET_CRYPTO_hash (&mingle_number,
82 sizeof (int32_t),
83 &m);
84 GNUNET_CRYPTO_hash_xor (&m, in, hc);
85}
86
87
88/**
67 * Create a block context. Loads the block plugins. 89 * Create a block context. Loads the block plugins.
68 * 90 *
69 * @param cfg configuration to use 91 * @param cfg configuration to use
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
@@ -38,23 +38,6 @@
38#define BLOOMFILTER_K 16 38#define BLOOMFILTER_K 16
39 39
40/** 40/**
41 * Mingle hash with the mingle_number to produce different bits.
42 */
43static void
44mingle_hash (const GNUNET_HashCode * in,
45 int32_t mingle_number,
46 GNUNET_HashCode * hc)
47{
48 GNUNET_HashCode m;
49
50 GNUNET_CRYPTO_hash (&mingle_number,
51 sizeof (int32_t),
52 &m);
53 GNUNET_CRYPTO_hash_xor (&m, in, hc);
54}
55
56
57/**
58 * Function called to validate a reply or a request. For 41 * Function called to validate a reply or a request. For
59 * request evaluation, simply pass "NULL" for the reply_block. 42 * request evaluation, simply pass "NULL" for the reply_block.
60 * Note that it is assumed that the reply has already been 43 * Note that it is assumed that the reply has already been
@@ -113,7 +96,7 @@ block_plugin_fs_evaluate (void *cls,
113 GNUNET_CRYPTO_hash (reply_block, 96 GNUNET_CRYPTO_hash (reply_block,
114 reply_block_size, 97 reply_block_size,
115 &chash); 98 &chash);
116 mingle_hash (&chash, bf_mutator, &mhash); 99 GNUNET_BLOCK_mingle_hash (&chash, bf_mutator, &mhash);
117 if (NULL != *bf) 100 if (NULL != *bf)
118 { 101 {
119 if (GNUNET_YES == GNUNET_CONTAINER_bloomfilter_test (*bf, 102 if (GNUNET_YES == GNUNET_CONTAINER_bloomfilter_test (*bf,
@@ -154,7 +137,7 @@ block_plugin_fs_evaluate (void *cls,
154 GNUNET_CRYPTO_hash (reply_block, 137 GNUNET_CRYPTO_hash (reply_block,
155 reply_block_size, 138 reply_block_size,
156 &chash); 139 &chash);
157 mingle_hash (&chash, bf_mutator, &mhash); 140 GNUNET_BLOCK_mingle_hash (&chash, bf_mutator, &mhash);
158 if (NULL != *bf) 141 if (NULL != *bf)
159 { 142 {
160 if (GNUNET_YES == GNUNET_CONTAINER_bloomfilter_test (*bf, 143 if (GNUNET_YES == GNUNET_CONTAINER_bloomfilter_test (*bf,