aboutsummaryrefslogtreecommitdiff
path: root/src/block/plugin_block_test.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-08-15 21:46:35 +0000
committerChristian Grothoff <christian@grothoff.org>2011-08-15 21:46:35 +0000
commit502af2167f7c218366666ca4944bd7cc54b5b19a (patch)
treea91fec5cc9769d260640bd91c6633cb9cf395524 /src/block/plugin_block_test.c
parent03af5a603b7cc53432249d5854cd412aa90dde0d (diff)
downloadgnunet-502af2167f7c218366666ca4944bd7cc54b5b19a.tar.gz
gnunet-502af2167f7c218366666ca4944bd7cc54b5b19a.zip
indentation
Diffstat (limited to 'src/block/plugin_block_test.c')
-rw-r--r--src/block/plugin_block_test.c61
1 files changed, 27 insertions, 34 deletions
diff --git a/src/block/plugin_block_test.c b/src/block/plugin_block_test.c
index 639a5c46e..b5c03eea9 100644
--- a/src/block/plugin_block_test.c
+++ b/src/block/plugin_block_test.c
@@ -54,42 +54,36 @@
54 */ 54 */
55static enum GNUNET_BLOCK_EvaluationResult 55static enum GNUNET_BLOCK_EvaluationResult
56block_plugin_test_evaluate (void *cls, 56block_plugin_test_evaluate (void *cls,
57 enum GNUNET_BLOCK_Type type, 57 enum GNUNET_BLOCK_Type type,
58 const GNUNET_HashCode *query, 58 const GNUNET_HashCode * query,
59 struct GNUNET_CONTAINER_BloomFilter **bf, 59 struct GNUNET_CONTAINER_BloomFilter **bf,
60 int32_t bf_mutator, 60 int32_t bf_mutator,
61 const void *xquery, 61 const void *xquery,
62 size_t xquery_size, 62 size_t xquery_size,
63 const void *reply_block, 63 const void *reply_block, size_t reply_block_size)
64 size_t reply_block_size)
65{ 64{
66 GNUNET_HashCode chash; 65 GNUNET_HashCode chash;
67 GNUNET_HashCode mhash; 66 GNUNET_HashCode mhash;
68 67
69 if (type != GNUNET_BLOCK_TYPE_TEST) 68 if (type != GNUNET_BLOCK_TYPE_TEST)
70 return GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED; 69 return GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED;
71 if (xquery_size != 0) 70 if (xquery_size != 0)
72 return GNUNET_BLOCK_EVALUATION_REQUEST_INVALID; 71 return GNUNET_BLOCK_EVALUATION_REQUEST_INVALID;
73 if (reply_block_size == 0) 72 if (reply_block_size == 0)
74 return GNUNET_BLOCK_EVALUATION_REQUEST_VALID; 73 return GNUNET_BLOCK_EVALUATION_REQUEST_VALID;
75 74
76 GNUNET_CRYPTO_hash (reply_block, 75 GNUNET_CRYPTO_hash (reply_block, reply_block_size, &chash);
77 reply_block_size,
78 &chash);
79 GNUNET_BLOCK_mingle_hash (&chash, bf_mutator, &mhash); 76 GNUNET_BLOCK_mingle_hash (&chash, bf_mutator, &mhash);
80 if (NULL != *bf) 77 if (NULL != *bf)
81 { 78 {
82 if (GNUNET_YES == GNUNET_CONTAINER_bloomfilter_test (*bf, 79 if (GNUNET_YES == GNUNET_CONTAINER_bloomfilter_test (*bf, &mhash))
83 &mhash)) 80 return GNUNET_BLOCK_EVALUATION_OK_DUPLICATE;
84 return GNUNET_BLOCK_EVALUATION_OK_DUPLICATE; 81 }
85 }
86 else 82 else
87 { 83 {
88 *bf = GNUNET_CONTAINER_bloomfilter_init (NULL, 84 *bf = GNUNET_CONTAINER_bloomfilter_init (NULL, 8, BLOOMFILTER_K);
89 8, 85 }
90 BLOOMFILTER_K); 86 GNUNET_CONTAINER_bloomfilter_add (*bf, &mhash);
91 }
92 GNUNET_CONTAINER_bloomfilter_add (*bf, &mhash);
93 return GNUNET_BLOCK_EVALUATION_OK_MORE; 87 return GNUNET_BLOCK_EVALUATION_OK_MORE;
94} 88}
95 89
@@ -107,16 +101,15 @@ block_plugin_test_evaluate (void *cls,
107 */ 101 */
108static int 102static int
109block_plugin_test_get_key (void *cls, 103block_plugin_test_get_key (void *cls,
110 enum GNUNET_BLOCK_Type type, 104 enum GNUNET_BLOCK_Type type,
111 const void *block, 105 const void *block,
112 size_t block_size, 106 size_t block_size, GNUNET_HashCode * key)
113 GNUNET_HashCode *key)
114{ 107{
115 /* always fails since there is no fixed relationship between 108 /* always fails since there is no fixed relationship between
116 keys and values for test values */ 109 * keys and values for test values */
117 return GNUNET_SYSERR; 110 return GNUNET_SYSERR;
118} 111}
119 112
120 113
121/** 114/**
122 * Entry point for the plugin. 115 * Entry point for the plugin.
@@ -124,11 +117,11 @@ block_plugin_test_get_key (void *cls,
124void * 117void *
125libgnunet_plugin_block_test_init (void *cls) 118libgnunet_plugin_block_test_init (void *cls)
126{ 119{
127 static enum GNUNET_BLOCK_Type types[] = 120 static enum GNUNET_BLOCK_Type types[] =
128 { 121 {
129 GNUNET_BLOCK_TYPE_TEST, 122 GNUNET_BLOCK_TYPE_TEST,
130 GNUNET_BLOCK_TYPE_ANY /* end of list */ 123 GNUNET_BLOCK_TYPE_ANY /* end of list */
131 }; 124 };
132 struct GNUNET_BLOCK_PluginFunctions *api; 125 struct GNUNET_BLOCK_PluginFunctions *api;
133 126
134 api = GNUNET_malloc (sizeof (struct GNUNET_BLOCK_PluginFunctions)); 127 api = GNUNET_malloc (sizeof (struct GNUNET_BLOCK_PluginFunctions));