aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/consensus/gnunet-service-consensus.c9
-rw-r--r--src/set/plugin_block_set_test.c123
2 files changed, 132 insertions, 0 deletions
diff --git a/src/consensus/gnunet-service-consensus.c b/src/consensus/gnunet-service-consensus.c
index 44b6dc21b..c56741c67 100644
--- a/src/consensus/gnunet-service-consensus.c
+++ b/src/consensus/gnunet-service-consensus.c
@@ -487,6 +487,11 @@ struct ConsensusSession
487 * State of our early stopping scheme. 487 * State of our early stopping scheme.
488 */ 488 */
489 int early_stopping; 489 int early_stopping;
490
491 /**
492 * Our set size from the first round.
493 */
494 uint64_t first_size;
490}; 495};
491 496
492/** 497/**
@@ -1061,6 +1066,10 @@ set_result_cb (void *cls,
1061 { 1066 {
1062 rfn_commit (output_rfn, task_other_peer (task)); 1067 rfn_commit (output_rfn, task_other_peer (task));
1063 } 1068 }
1069 if (PHASE_KIND_ALL_TO_ALL == task->key->phase)
1070 {
1071 session->first_size = current_size;
1072 }
1064 finish_task (task); 1073 finish_task (task);
1065 break; 1074 break;
1066 case GNUNET_SET_STATUS_FAILURE: 1075 case GNUNET_SET_STATUS_FAILURE:
diff --git a/src/set/plugin_block_set_test.c b/src/set/plugin_block_set_test.c
new file mode 100644
index 000000000..c4f73abe0
--- /dev/null
+++ b/src/set/plugin_block_set_test.c
@@ -0,0 +1,123 @@
1/*
2 This file is part of GNUnet
3 Copyright (C) 2017 GNUnet e.V.
4
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
19*/
20
21/**
22 * @file set/plugin_block_set_test.c
23 * @brief set test block, recognizes elements with non-zero first byte as invalid
24 * @author Christian Grothoff
25 */
26
27#include "platform.h"
28#include "gnunet_block_plugin.h"
29#include "gnunet_block_group_lib.h"
30
31
32/**
33 * Function called to validate a reply or a request. For
34 * request evaluation, simply pass "NULL" for the reply_block.
35 *
36 * @param cls closure
37 * @param ctx block context
38 * @param type block type
39 * @param group block group to use
40 * @param eo control flags
41 * @param query original query (hash)
42 * @param xquery extrended query data (can be NULL, depending on type)
43 * @param xquery_size number of bytes in xquery
44 * @param reply_block response to validate
45 * @param reply_block_size number of bytes in reply block
46 * @return characterization of result
47 */
48static enum GNUNET_BLOCK_EvaluationResult
49block_plugin_set_test_evaluate (void *cls,
50 struct GNUNET_BLOCK_Context *ctx,
51 enum GNUNET_BLOCK_Type type,
52 struct GNUNET_BLOCK_Group *group,
53 enum GNUNET_BLOCK_EvaluationOptions eo,
54 const struct GNUNET_HashCode *query,
55 const void *xquery,
56 size_t xquery_size,
57 const void *reply_block,
58 size_t reply_block_size)
59{
60 if ( (NULL == reply_block) ||
61 (reply_block_size == 0) ||
62 (0 != ((char *) reply_block)[0]) )
63 return GNUNET_BLOCK_EVALUATION_RESULT_INVALID;
64 return GNUNET_BLOCK_EVALUATION_OK_MORE;
65}
66
67
68/**
69 * Function called to obtain the key for a block.
70 *
71 * @param cls closure
72 * @param type block type
73 * @param block block to get the key for
74 * @param block_size number of bytes in block
75 * @param key set to the key (query) for the given block
76 * @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)
78 */
79static int
80block_plugin_set_test_get_key (void *cls,
81 enum GNUNET_BLOCK_Type type,
82 const void *block,
83 size_t block_size,
84 struct GNUNET_HashCode *key)
85{
86 return GNUNET_SYSERR;
87}
88
89
90/**
91 * Entry point for the plugin.
92 */
93void *
94libgnunet_plugin_block_set_test_init (void *cls)
95{
96 static enum GNUNET_BLOCK_Type types[] =
97 {
98 GNUNET_BLOCK_TYPE_SET_TEST,
99 GNUNET_BLOCK_TYPE_ANY /* end of list */
100 };
101 struct GNUNET_BLOCK_PluginFunctions *api;
102
103 api = GNUNET_new (struct GNUNET_BLOCK_PluginFunctions);
104 api->evaluate = &block_plugin_set_test_evaluate;
105 api->get_key = &block_plugin_set_test_get_key;
106 api->types = types;
107 return api;
108}
109
110
111/**
112 * Exit point from the plugin.
113 */
114void *
115libgnunet_plugin_block_set_test_done (void *cls)
116{
117 struct GNUNET_TRANSPORT_PluginFunctions *api = cls;
118
119 GNUNET_free (api);
120 return NULL;
121}
122
123/* end of plugin_block_set_test.c */