aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2020-08-29 23:22:17 +0200
committerChristian Grothoff <christian@grothoff.org>2020-08-29 23:22:17 +0200
commit394cacf9fdb640c59a41ee60a233b4e3cce44aad (patch)
tree581800a26a80cd505d6a88489c259ffd1122f49a /src
parent94fa99870bce6f8bf87b37b15b538a9164dff50f (diff)
downloadgnunet-394cacf9fdb640c59a41ee60a233b4e3cce44aad.tar.gz
gnunet-394cacf9fdb640c59a41ee60a233b4e3cce44aad.zip
-mild refactoring of consensus, cleaning up the code a bit
Diffstat (limited to 'src')
-rw-r--r--src/consensus/gnunet-service-consensus.c15
-rw-r--r--src/consensus/plugin_block_consensus.c13
2 files changed, 11 insertions, 17 deletions
diff --git a/src/consensus/gnunet-service-consensus.c b/src/consensus/gnunet-service-consensus.c
index 3a8356635..24e285e77 100644
--- a/src/consensus/gnunet-service-consensus.c
+++ b/src/consensus/gnunet-service-consensus.c
@@ -848,7 +848,8 @@ diff_insert (struct DiffEntry *diff,
848 di->element = GNUNET_SET_element_dup (element); 848 di->element = GNUNET_SET_element_dup (element);
849 GNUNET_assert (GNUNET_OK == 849 GNUNET_assert (GNUNET_OK ==
850 GNUNET_CONTAINER_multihashmap_put (diff->changes, 850 GNUNET_CONTAINER_multihashmap_put (diff->changes,
851 &hash, di, 851 &hash,
852 di,
852 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST)); 853 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST));
853 } 854 }
854 855
@@ -1396,6 +1397,7 @@ commit_set (struct ConsensusSession *session,
1396 { 1397 {
1397 struct GNUNET_SET_Element element; 1398 struct GNUNET_SET_Element element;
1398 struct ConsensusElement ce = { 0 }; 1399 struct ConsensusElement ce = { 0 };
1400
1399 ce.marker = CONSENSUS_MARKER_CONTESTED; 1401 ce.marker = CONSENSUS_MARKER_CONTESTED;
1400 element.data = &ce; 1402 element.data = &ce;
1401 element.size = sizeof(struct ConsensusElement); 1403 element.size = sizeof(struct ConsensusElement);
@@ -3329,13 +3331,6 @@ handle_client_join (void *cls,
3329} 3331}
3330 3332
3331 3333
3332static void
3333client_insert_done (void *cls)
3334{
3335 // FIXME: implement
3336}
3337
3338
3339/** 3334/**
3340 * Called when a client performs an insert operation. 3335 * Called when a client performs an insert operation.
3341 * 3336 *
@@ -3400,8 +3395,8 @@ handle_client_insert (void *cls,
3400 3395
3401 GNUNET_SET_add_element (initial_set, 3396 GNUNET_SET_add_element (initial_set,
3402 &element, 3397 &element,
3403 &client_insert_done, 3398 NULL,
3404 session); 3399 NULL);
3405#ifdef GNUNET_EXTRA_LOGGING 3400#ifdef GNUNET_EXTRA_LOGGING
3406 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 3401 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
3407 "P%u: element %s added\n", 3402 "P%u: element %s added\n",
diff --git a/src/consensus/plugin_block_consensus.c b/src/consensus/plugin_block_consensus.c
index fb6da5bcd..cdac12ed5 100644
--- a/src/consensus/plugin_block_consensus.c
+++ b/src/consensus/plugin_block_consensus.c
@@ -58,13 +58,12 @@ block_plugin_consensus_evaluate (void *cls,
58 const void *reply_block, 58 const void *reply_block,
59 size_t reply_block_size) 59 size_t reply_block_size)
60{ 60{
61 if (reply_block_size < sizeof(struct ConsensusElement))
62 return GNUNET_BLOCK_EVALUATION_RESULT_INVALID;
63
64 const struct ConsensusElement *ce = reply_block; 61 const struct ConsensusElement *ce = reply_block;
65 62
66 if ((0 != ce->marker) || 63 if (reply_block_size < sizeof(struct ConsensusElement))
67 (0 == ce->payload_type)) 64 return GNUNET_BLOCK_EVALUATION_RESULT_INVALID;
65 if ( (0 != ce->marker) ||
66 (0 == ce->payload_type) )
68 return GNUNET_BLOCK_EVALUATION_OK_MORE; 67 return GNUNET_BLOCK_EVALUATION_OK_MORE;
69 68
70 return GNUNET_BLOCK_evaluate (ctx, 69 return GNUNET_BLOCK_evaluate (ctx,
@@ -75,8 +74,8 @@ block_plugin_consensus_evaluate (void *cls,
75 xquery, 74 xquery,
76 xquery_size, 75 xquery_size,
77 &ce[1], 76 &ce[1],
78 reply_block_size - sizeof(struct 77 reply_block_size
79 ConsensusElement)); 78 - sizeof(struct ConsensusElement));
80} 79}
81 80
82 81