GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
- by the Free Software Foundation; either version 2, or (at your
+ by the Free Software Foundation; either version 3, or (at your
option) any later version.
GNUnet is distributed in the hope that it will be useful, but
#include "gnunet_common.h"
#include "gnunet_time_lib.h"
#include "gnunet_configuration_lib.h"
-
-
-/**
- * An element of the consensus set.
- */
-struct GNUNET_CONSENSUS_Element
-{
- /**
- * The actual data of the element.
- */
- const void *data;
-
- /**
- * Size of the element's data.
- */
- uint16_t size;
-
- /**
- * Application specific element type
- */
- uint16_t type;
-};
+#include "gnunet_set_service.h"
/**
*
* @param cls closure
* @param element new element, NULL on error
- * @return GNUNET_OK if the valid is well-formed and should be added to the consensus,
- * GNUNET_SYSERR if the element should be ignored and not be propagated
*/
-typedef int (*GNUNET_CONSENSUS_ElementCallback) (void *cls,
- const struct GNUNET_CONSENSUS_Element *element);
+typedef void (*GNUNET_CONSENSUS_ElementCallback) (void *cls,
+ const struct GNUNET_SET_Element *element);
/**
* Create a consensus session. The set being reconciled is initially
- * empty. Only reconcile with other peers after
- * GNUNET_CONSENSUS_reconcile has been called.
+ * empty.
*
* @param cfg
* @param num_peers
* Inclusion of the local peer is optional.
* @param session_id session identifier
* Allows a group of peers to have more than consensus session.
+ * @param start start time of the consensus, conclude should be called before
+ * the start time.
+ * @param deadline time when the consensus should have concluded
* @param new_element_cb callback, called when a new element is added to the set by
- * another peer
+ * another peer. Also called when an error occurs.
* @param new_element_cls closure for new_element
* @return handle to use, NULL on error
*/
unsigned int num_peers,
const struct GNUNET_PeerIdentity *peers,
const struct GNUNET_HashCode *session_id,
+ struct GNUNET_TIME_Absolute start,
+ struct GNUNET_TIME_Absolute deadline,
GNUNET_CONSENSUS_ElementCallback new_element_cb,
void *new_element_cls);
/**
- * Called when an insertion (transmission to consensus service,
- * which does not imply fully consensus on this element with
- * all other peers) was successful.
- * May not call GNUNET_CONSENSUS_destroy; schedule a task to call
- * GNUNET_CONSENSUS_destroy instead.
+ * Called when an insertion (transmission to consensus service, which
+ * does not imply fully consensus on this element with all other
+ * peers) was successful. May not call GNUNET_CONSENSUS_destroy();
+ * schedule a task to call GNUNET_CONSENSUS_destroy() instead (if
+ * needed).
*
* @param cls
- * @param success GNUNET_OK on success, GNUNET_SYSERR if
+ * @param success #GNUNET_OK on success, #GNUNET_SYSERR if
* the insertion and thus the consensus failed for good
*/
typedef void (*GNUNET_CONSENSUS_InsertDoneCallback) (void *cls,
/**
* Insert an element in the set being reconsiled. Only transmit changes to
- * other peers if "GNUNET_CONSENSUS_begin" has been called.
- * Must not be called after "GNUNET_CONSENSUS_conclude".
- * May not call GNUNET_CONSENSUS_destroy; schedule a task to call
- * GNUNET_CONSENSUS_destroy instead.
+ * other peers if GNUNET_CONSENSUS_begin() has been called.
+ * Must not be called after GNUNET_CONSENSUS_conclude().
+ * May not call GNUNET_CONSENSUS_destroy(); schedule a task to call
+ * GNUNET_CONSENSUS_destroy() instead (if needed).
*
* @param consensus handle for the consensus session
* @param element the element to be inserted
- * @param idc function called when we are done with this element and it
- * is thus allowed to call GNUNET_CONSENSUS_insert again
- * @param idc_cls closure for 'idc'
+ * @param idc function called when we are done with this element and it
+ * is thus allowed to call GNUNET_CONSENSUS_insert() again
+ * @param idc_cls closure for @a idc
*/
void
GNUNET_CONSENSUS_insert (struct GNUNET_CONSENSUS_Handle *consensus,
- const struct GNUNET_CONSENSUS_Element *element,
+ const struct GNUNET_SET_Element *element,
GNUNET_CONSENSUS_InsertDoneCallback idc,
void *idc_cls);
-struct GNUNET_CONSENSUS_DeltaRequest;
-
-/**
- * FIXME
- *
- * @param consensus consensus session
- * @param remove_element_cb callback that receives the removed elements
- * @return a handle to cancel the request
- */
-struct GNUNET_CONSENSUS_DeltaRequest *
-GNUNET_CONSENSUS_get_delta (struct GNUNET_CONSENSUS_Handle *consensus,
- GNUNET_CONSENSUS_ElementCallback remove_element_cb,
- void *remove_element_cb_cls);
-
-
-void
-GNUNET_CONSENSUS_get_delta_cancel (struct GNUNET_CONSENSUS_DeltaRequest *dr);
-
/**
* Called when a conclusion was successful.
* try to conclude the consensus within a given time window.
*
* @param consensus consensus session
- * @param timeout timeout after which the conculde callback
- * must be called
* @param conclude called when the conclusion was successful
* @param conclude_cls closure for the conclude callback
*/
void
GNUNET_CONSENSUS_conclude (struct GNUNET_CONSENSUS_Handle *consensus,
- struct GNUNET_TIME_Relative timeout,
GNUNET_CONSENSUS_ConcludeCallback conclude,
void *conclude_cls);