aboutsummaryrefslogtreecommitdiff
path: root/src/consensus
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2017-02-26 23:39:29 +0100
committerFlorian Dold <florian.dold@gmail.com>2017-02-26 23:39:29 +0100
commit82242cae3bb6313ee10df20570e4c14627828033 (patch)
treec628b5323c1ec8cbf0915e04bb7a1fa7864d7ea9 /src/consensus
parentcc8f37a834298d95c233769d19eb9cd17e3dbcfd (diff)
add validation for inner consensus element
The nested block validation requires the block context, and thus the evaluate callback not also receives the block context.
Diffstat (limited to 'src/consensus')
-rw-r--r--src/consensus/plugin_block_consensus.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/src/consensus/plugin_block_consensus.c b/src/consensus/plugin_block_consensus.c
index 39e348b18e..3ad3357604 100644
--- a/src/consensus/plugin_block_consensus.c
+++ b/src/consensus/plugin_block_consensus.c
@@ -35,6 +35,7 @@
* request evaluation, simply pass "NULL" for the reply_block.
*
* @param cls closure
+ * @param ctx context
* @param type block type
* @param group block group to use
* @param eo control flags
@@ -47,6 +48,7 @@
*/
static enum GNUNET_BLOCK_EvaluationResult
block_plugin_consensus_evaluate (void *cls,
+ struct GNUNET_BLOCK_Context *ctx,
enum GNUNET_BLOCK_Type type,
struct GNUNET_BLOCK_Group *group,
enum GNUNET_BLOCK_EvaluationOptions eo,
@@ -57,10 +59,23 @@ block_plugin_consensus_evaluate (void *cls,
size_t reply_block_size)
{
if (reply_block_size < sizeof (struct ConsensusElement))
- {
return GNUNET_BLOCK_EVALUATION_RESULT_INVALID;
- }
- return GNUNET_BLOCK_EVALUATION_OK_MORE;
+
+ const struct ConsensusElement *ce = reply_block;
+
+ if ( (GNUNET_YES == ce->is_contested_marker) ||
+ (0 == ce->payload_type ) )
+ return GNUNET_BLOCK_EVALUATION_OK_MORE;
+
+ return GNUNET_BLOCK_evaluate (ctx,
+ type,
+ group,
+ eo,
+ query,
+ xquery,
+ xquery_size,
+ &ce[1],
+ reply_block_size - sizeof (struct ConsensusElement));
}