aboutsummaryrefslogtreecommitdiff
path: root/src/fs/plugin_block_fs.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2015-02-28 21:12:03 +0000
committerChristian Grothoff <christian@grothoff.org>2015-02-28 21:12:03 +0000
commit3a2737d76679c68331fad0be0b89d8efdcde5079 (patch)
tree5bd4ef163438954cdcb75558e6368a297629b56d /src/fs/plugin_block_fs.c
parent9c46ed792caae948fd99cca44deaf5a265af7614 (diff)
downloadgnunet-3a2737d76679c68331fad0be0b89d8efdcde5079.tar.gz
gnunet-3a2737d76679c68331fad0be0b89d8efdcde5079.zip
-extend block API to allow specifying flags, use this to allow reducing checks for replies from local DB
Diffstat (limited to 'src/fs/plugin_block_fs.c')
-rw-r--r--src/fs/plugin_block_fs.c51
1 files changed, 32 insertions, 19 deletions
diff --git a/src/fs/plugin_block_fs.c b/src/fs/plugin_block_fs.c
index bc2e2d507..c032899c5 100644
--- a/src/fs/plugin_block_fs.c
+++ b/src/fs/plugin_block_fs.c
@@ -42,25 +42,30 @@
42 * request evaluation, simply pass "NULL" for the reply_block. 42 * request evaluation, simply pass "NULL" for the reply_block.
43 * Note that it is assumed that the reply has already been 43 * Note that it is assumed that the reply has already been
44 * matched to the key (and signatures checked) as it would 44 * matched to the key (and signatures checked) as it would
45 * be done with the "get_key" function. 45 * be done with the #GNUNET_BLOCK_get_key() function.
46 * 46 *
47 * @param cls closure 47 * @param cls closure
48 * @param type block type 48 * @param type block type
49 * @param eo control flags
49 * @param query original query (hash) 50 * @param query original query (hash)
50 * @param bf pointer to bloom filter associated with query; possibly updated (!) 51 * @param bf pointer to bloom filter associated with query; possibly updated (!)
51 * @param bf_mutator mutation value for bf 52 * @param bf_mutator mutation value for @a bf
52 * @param xquery extrended query data (can be NULL, depending on type) 53 * @param xquery extrended query data (can be NULL, depending on type)
53 * @param xquery_size number of bytes in xquery 54 * @param xquery_size number of bytes in @a xquery
54 * @param reply_block response to validate 55 * @param reply_block response to validate
55 * @param reply_block_size number of bytes in reply block 56 * @param reply_block_size number of bytes in @a reply_block
56 * @return characterization of result 57 * @return characterization of result
57 */ 58 */
58static enum GNUNET_BLOCK_EvaluationResult 59static enum GNUNET_BLOCK_EvaluationResult
59block_plugin_fs_evaluate (void *cls, enum GNUNET_BLOCK_Type type, 60block_plugin_fs_evaluate (void *cls,
61 enum GNUNET_BLOCK_Type type,
62 enum GNUNET_BLOCK_EvaluationOptions eo,
60 const struct GNUNET_HashCode *query, 63 const struct GNUNET_HashCode *query,
61 struct GNUNET_CONTAINER_BloomFilter **bf, 64 struct GNUNET_CONTAINER_BloomFilter **bf,
62 int32_t bf_mutator, const void *xquery, 65 int32_t bf_mutator,
63 size_t xquery_size, const void *reply_block, 66 const void *xquery,
67 size_t xquery_size,
68 const void *reply_block,
64 size_t reply_block_size) 69 size_t reply_block_size)
65{ 70{
66 const struct UBlock *ub; 71 const struct UBlock *ub;
@@ -110,22 +115,28 @@ block_plugin_fs_evaluate (void *cls, enum GNUNET_BLOCK_Type type,
110 GNUNET_break_op (0); 115 GNUNET_break_op (0);
111 return GNUNET_BLOCK_EVALUATION_RESULT_INVALID; 116 return GNUNET_BLOCK_EVALUATION_RESULT_INVALID;
112 } 117 }
113 if (GNUNET_OK != 118 if ( (0 == (eo & GNUNET_BLOCK_EO_LOCAL_SKIP_CRYPTO)) &&
114 GNUNET_CRYPTO_ecdsa_verify (GNUNET_SIGNATURE_PURPOSE_FS_UBLOCK, 119 (GNUNET_OK !=
115 &ub->purpose, 120 GNUNET_CRYPTO_ecdsa_verify (GNUNET_SIGNATURE_PURPOSE_FS_UBLOCK,
116 &ub->signature, 121 &ub->purpose,
117 &ub->verification_key)) 122 &ub->signature,
123 &ub->verification_key)) )
118 { 124 {
119 GNUNET_break_op (0); 125 GNUNET_break_op (0);
120 return GNUNET_BLOCK_EVALUATION_RESULT_INVALID; 126 return GNUNET_BLOCK_EVALUATION_RESULT_INVALID;
121 } 127 }
122 if (NULL != bf) 128 if (NULL != bf)
123 { 129 {
124 GNUNET_CRYPTO_hash (reply_block, reply_block_size, &chash); 130 GNUNET_CRYPTO_hash (reply_block,
125 GNUNET_BLOCK_mingle_hash (&chash, bf_mutator, &mhash); 131 reply_block_size,
132 &chash);
133 GNUNET_BLOCK_mingle_hash (&chash,
134 bf_mutator,
135 &mhash);
126 if (NULL != *bf) 136 if (NULL != *bf)
127 { 137 {
128 if (GNUNET_YES == GNUNET_CONTAINER_bloomfilter_test (*bf, &mhash)) 138 if (GNUNET_YES ==
139 GNUNET_CONTAINER_bloomfilter_test (*bf, &mhash))
129 return GNUNET_BLOCK_EVALUATION_OK_DUPLICATE; 140 return GNUNET_BLOCK_EVALUATION_OK_DUPLICATE;
130 } 141 }
131 else 142 else
@@ -147,14 +158,16 @@ block_plugin_fs_evaluate (void *cls, enum GNUNET_BLOCK_Type type,
147 * @param cls closure 158 * @param cls closure
148 * @param type block type 159 * @param type block type
149 * @param block block to get the key for 160 * @param block block to get the key for
150 * @param block_size number of bytes in block 161 * @param block_size number of bytes in @a block
151 * @param key set to the key (query) for the given block 162 * @param key set to the key (query) for the given block
152 * @return GNUNET_OK on success, GNUNET_SYSERR if type not supported 163 * @return #GNUNET_OK on success, #GNUNET_SYSERR if type not supported
153 * (or if extracting a key from a block of this type does not work) 164 * (or if extracting a key from a block of this type does not work)
154 */ 165 */
155static int 166static int
156block_plugin_fs_get_key (void *cls, enum GNUNET_BLOCK_Type type, 167block_plugin_fs_get_key (void *cls,
157 const void *block, size_t block_size, 168 enum GNUNET_BLOCK_Type type,
169 const void *block,
170 size_t block_size,
158 struct GNUNET_HashCode *key) 171 struct GNUNET_HashCode *key)
159{ 172{
160 const struct UBlock *ub; 173 const struct UBlock *ub;