aboutsummaryrefslogtreecommitdiff
path: root/src/consensus/consensus_api.c
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2014-02-03 21:25:53 +0000
committerFlorian Dold <florian.dold@gmail.com>2014-02-03 21:25:53 +0000
commit8a3563b5c242b60aa4b7d2b9a3c3607ef8dcbadb (patch)
treef4b85c248403ba6783db017930b2258f3e61e18a /src/consensus/consensus_api.c
parent694581b42a78419c1c8ffc31ee873484ff93d79b (diff)
downloadgnunet-8a3563b5c242b60aa4b7d2b9a3c3607ef8dcbadb.tar.gz
gnunet-8a3563b5c242b60aa4b7d2b9a3c3607ef8dcbadb.zip
- consensus and secretsharing have both start time and deadline
Diffstat (limited to 'src/consensus/consensus_api.c')
-rw-r--r--src/consensus/consensus_api.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/consensus/consensus_api.c b/src/consensus/consensus_api.c
index 14a1bf54e..5ebdf71e7 100644
--- a/src/consensus/consensus_api.c
+++ b/src/consensus/consensus_api.c
@@ -156,6 +156,9 @@ handle_conclude_done (void *cls,
156 * Inclusion of the local peer is optional. 156 * Inclusion of the local peer is optional.
157 * @param session_id session identifier 157 * @param session_id session identifier
158 * Allows a group of peers to have more than consensus session. 158 * Allows a group of peers to have more than consensus session.
159 * @param start start time of the consensus, conclude should be called before
160 * the start time.
161 * @param deadline time when the consensus should have concluded
159 * @param new_element_cb callback, called when a new element is added to the set by 162 * @param new_element_cb callback, called when a new element is added to the set by
160 * another peer 163 * another peer
161 * @param new_element_cls closure for new_element 164 * @param new_element_cls closure for new_element
@@ -166,6 +169,8 @@ GNUNET_CONSENSUS_create (const struct GNUNET_CONFIGURATION_Handle *cfg,
166 unsigned int num_peers, 169 unsigned int num_peers,
167 const struct GNUNET_PeerIdentity *peers, 170 const struct GNUNET_PeerIdentity *peers,
168 const struct GNUNET_HashCode *session_id, 171 const struct GNUNET_HashCode *session_id,
172 struct GNUNET_TIME_Absolute start,
173 struct GNUNET_TIME_Absolute deadline,
169 GNUNET_CONSENSUS_ElementCallback new_element_cb, 174 GNUNET_CONSENSUS_ElementCallback new_element_cb,
170 void *new_element_cls) 175 void *new_element_cls)
171{ 176{
@@ -196,6 +201,8 @@ GNUNET_CONSENSUS_create (const struct GNUNET_CONFIGURATION_Handle *cfg,
196 GNUNET_MESSAGE_TYPE_CONSENSUS_CLIENT_JOIN); 201 GNUNET_MESSAGE_TYPE_CONSENSUS_CLIENT_JOIN);
197 202
198 join_msg->session_id = consensus->session_id; 203 join_msg->session_id = consensus->session_id;
204 join_msg->start = GNUNET_TIME_absolute_hton (start);
205 join_msg->deadline = GNUNET_TIME_absolute_hton (deadline);
199 join_msg->num_peers = htonl (num_peers); 206 join_msg->num_peers = htonl (num_peers);
200 memcpy(&join_msg[1], 207 memcpy(&join_msg[1],
201 peers, 208 peers,
@@ -266,12 +273,10 @@ GNUNET_CONSENSUS_insert (struct GNUNET_CONSENSUS_Handle *consensus,
266 */ 273 */
267void 274void
268GNUNET_CONSENSUS_conclude (struct GNUNET_CONSENSUS_Handle *consensus, 275GNUNET_CONSENSUS_conclude (struct GNUNET_CONSENSUS_Handle *consensus,
269 struct GNUNET_TIME_Absolute deadline,
270 GNUNET_CONSENSUS_ConcludeCallback conclude, 276 GNUNET_CONSENSUS_ConcludeCallback conclude,
271 void *conclude_cls) 277 void *conclude_cls)
272{ 278{
273 struct GNUNET_MQ_Envelope *ev; 279 struct GNUNET_MQ_Envelope *ev;
274 struct GNUNET_CONSENSUS_ConcludeMessage *conclude_msg;
275 280
276 GNUNET_assert (NULL != conclude); 281 GNUNET_assert (NULL != conclude);
277 GNUNET_assert (NULL == consensus->conclude_cb); 282 GNUNET_assert (NULL == consensus->conclude_cb);
@@ -279,9 +284,7 @@ GNUNET_CONSENSUS_conclude (struct GNUNET_CONSENSUS_Handle *consensus,
279 consensus->conclude_cls = conclude_cls; 284 consensus->conclude_cls = conclude_cls;
280 consensus->conclude_cb = conclude; 285 consensus->conclude_cb = conclude;
281 286
282 ev = GNUNET_MQ_msg (conclude_msg, GNUNET_MESSAGE_TYPE_CONSENSUS_CLIENT_CONCLUDE); 287 ev = GNUNET_MQ_msg_header (GNUNET_MESSAGE_TYPE_CONSENSUS_CLIENT_CONCLUDE);
283 conclude_msg->deadline = GNUNET_TIME_absolute_hton (deadline);
284
285 GNUNET_MQ_send (consensus->mq, ev); 288 GNUNET_MQ_send (consensus->mq, ev);
286} 289}
287 290