aboutsummaryrefslogtreecommitdiff
path: root/src/setu
diff options
context:
space:
mode:
authorChristian Grothoff <grothoff@gnunet.org>2021-12-29 18:22:37 +0100
committerChristian Grothoff <grothoff@gnunet.org>2021-12-29 18:22:37 +0100
commitc0b6f577cb6866a8bfce22acbcec6983d5f610f6 (patch)
treea7cb3c59313b8cc44b3ec51baa9bdd97e25efd09 /src/setu
parentfd620976c140d5df43cf174a54a9f88c4808cad3 (diff)
downloadgnunet-c0b6f577cb6866a8bfce22acbcec6983d5f610f6.tar.gz
gnunet-c0b6f577cb6866a8bfce22acbcec6983d5f610f6.zip
-updating block plugins to new API
Diffstat (limited to 'src/setu')
-rw-r--r--src/setu/plugin_block_setu_test.c86
1 files changed, 85 insertions, 1 deletions
diff --git a/src/setu/plugin_block_setu_test.c b/src/setu/plugin_block_setu_test.c
index fd0c8a680..9872bba39 100644
--- a/src/setu/plugin_block_setu_test.c
+++ b/src/setu/plugin_block_setu_test.c
@@ -66,6 +66,87 @@ block_plugin_setu_test_evaluate (void *cls,
66 66
67 67
68/** 68/**
69 * Function called to validate a query.
70 *
71 * @param cls closure
72 * @param ctx block context
73 * @param type block type
74 * @param query original query (hash)
75 * @param xquery extrended query data (can be NULL, depending on type)
76 * @param xquery_size number of bytes in @a xquery
77 * @return #GNUNET_OK if the query is fine, #GNUNET_NO if not
78 */
79static enum GNUNET_GenericReturnValue
80block_plugin_setu_test_check_query (void *cls,
81 enum GNUNET_BLOCK_Type type,
82 const struct GNUNET_HashCode *query,
83 const void *xquery,
84 size_t xquery_size)
85{
86 return GNUNET_OK;
87}
88
89
90/**
91 * Function called to validate a block for storage.
92 *
93 * @param cls closure
94 * @param type block type
95 * @param query key for the block (hash), must match exactly
96 * @param block block data to validate
97 * @param block_size number of bytes in @a block
98 * @return #GNUNET_OK if the block is fine, #GNUNET_NO if not
99 */
100static enum GNUNET_GenericReturnValue
101block_plugin_setu_test_check_block (void *cls,
102 enum GNUNET_BLOCK_Type type,
103 const struct GNUNET_HashCode *query,
104 const void *block,
105 size_t block_size)
106{
107 if ( (NULL == block) ||
108 (0 == block_size) ||
109 (0 != ((char *) block)[0]) )
110 return GNUNET_SYSERR;
111 return GNUNET_OK;
112}
113
114
115/**
116 * Function called to validate a reply to a request. Note that it is assumed
117 * that the reply has already been matched to the key (and signatures checked)
118 * as it would be done with the GetKeyFunction and the
119 * BlockEvaluationFunction.
120 *
121 * @param cls closure
122 * @param type block type
123 * @param group which block group to use for evaluation
124 * @param query original query (hash)
125 * @param xquery extrended query data (can be NULL, depending on type)
126 * @param xquery_size number of bytes in @a xquery
127 * @param reply_block response to validate
128 * @param reply_block_size number of bytes in @a reply_block
129 * @return characterization of result
130 */
131static enum GNUNET_BLOCK_ReplyEvaluationResult
132block_plugin_setu_test_check_reply (void *cls,
133 enum GNUNET_BLOCK_Type type,
134 struct GNUNET_BLOCK_Group *group,
135 const struct GNUNET_HashCode *query,
136 const void *xquery,
137 size_t xquery_size,
138 const void *reply_block,
139 size_t reply_block_size)
140{
141 if ( (NULL == reply_block) ||
142 (0 == reply_block_size) ||
143 (0 != ((char *) reply_block)[0]) )
144 return GNUNET_BLOCK_REPLY_INVALID;
145 return GNUNET_BLOCK_REPLY_OK_MORE;
146}
147
148
149/**
69 * Function called to obtain the key for a block. 150 * Function called to obtain the key for a block.
70 * 151 *
71 * @param cls closure 152 * @param cls closure
@@ -76,7 +157,7 @@ block_plugin_setu_test_evaluate (void *cls,
76 * @return #GNUNET_OK on success, #GNUNET_SYSERR if type not supported 157 * @return #GNUNET_OK on success, #GNUNET_SYSERR if type not supported
77 * (or if extracting a key from a block of this type does not work) 158 * (or if extracting a key from a block of this type does not work)
78 */ 159 */
79static int 160static enum GNUNET_GenericReturnValue
80block_plugin_setu_test_get_key (void *cls, 161block_plugin_setu_test_get_key (void *cls,
81 enum GNUNET_BLOCK_Type type, 162 enum GNUNET_BLOCK_Type type,
82 const void *block, 163 const void *block,
@@ -102,6 +183,9 @@ libgnunet_plugin_block_setu_test_init (void *cls)
102 api = GNUNET_new (struct GNUNET_BLOCK_PluginFunctions); 183 api = GNUNET_new (struct GNUNET_BLOCK_PluginFunctions);
103 api->evaluate = &block_plugin_setu_test_evaluate; 184 api->evaluate = &block_plugin_setu_test_evaluate;
104 api->get_key = &block_plugin_setu_test_get_key; 185 api->get_key = &block_plugin_setu_test_get_key;
186 api->check_query = &block_plugin_setu_test_check_query;
187 api->check_block = &block_plugin_setu_test_check_block;
188 api->check_reply = &block_plugin_setu_test_check_reply;
105 api->types = types; 189 api->types = types;
106 return api; 190 return api;
107} 191}