33#define LOG(kind, ...) GNUNET_log_from (kind, "consensus-api", __VA_ARGS__)
128 "received new element\n");
130 element.
size = ntohs (
msg->header.
size) -
sizeof(
struct
153 consensus->
mq = NULL;
174 "consensus service disconnected us\n");
230 if (NULL == consensus->
mq)
337 if (NULL != consensus->
mq)
340 consensus->
mq = NULL;
struct GNUNET_MessageHeader * msg
static void mq_error_handler(void *cls, enum GNUNET_MQ_Error error)
Generic error handler, called with the appropriate error code and the same closure specified at the c...
static int check_new_element(void *cls, const struct GNUNET_CONSENSUS_ElementMessage *msg)
Called when the server has sent is a new element.
static void handle_new_element(void *cls, const struct GNUNET_CONSENSUS_ElementMessage *msg)
Called when the server has sent is a new element.
static void handle_conclude_done(void *cls, const struct GNUNET_MessageHeader *msg)
Called when the server has announced that the conclusion is over.
static void idc_adapter(void *cls)
static int start
Set if we are to start default services (including ARM).
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
struct GNUNET_CONTAINER_MultiPeerMap * peers
Map from PIDs to struct CadetPeer entries.
Multi-peer set reconciliation.
static unsigned int num_peers
Number of peers.
Constants for network protocols.
struct GNUNET_MQ_Handle * GNUNET_CLIENT_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *service_name, const struct GNUNET_MQ_MessageHandler *handlers, GNUNET_MQ_ErrorHandler error_handler, void *error_handler_cls)
Create a message queue to connect to a GNUnet service.
void GNUNET_CONSENSUS_destroy(struct GNUNET_CONSENSUS_Handle *consensus)
Destroy a consensus handle (free all state associated with it, no longer call any of the callbacks).
void(* GNUNET_CONSENSUS_ElementCallback)(void *cls, const struct GNUNET_SET_Element *element)
Called when a new element was received from another peer, or an error occurred.
void GNUNET_CONSENSUS_insert(struct GNUNET_CONSENSUS_Handle *consensus, const struct GNUNET_SET_Element *element, GNUNET_CONSENSUS_InsertDoneCallback idc, void *idc_cls)
Insert an element in the set being reconsiled.
void(* GNUNET_CONSENSUS_InsertDoneCallback)(void *cls, int success)
Called when an insertion (transmission to consensus service, which does not imply fully consensus on ...
void(* GNUNET_CONSENSUS_ConcludeCallback)(void *cls)
Called when a conclusion was successful.
struct GNUNET_CONSENSUS_Handle * GNUNET_CONSENSUS_create(const struct GNUNET_CONFIGURATION_Handle *cfg, 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)
Create a consensus session.
void GNUNET_CONSENSUS_conclude(struct GNUNET_CONSENSUS_Handle *consensus, GNUNET_CONSENSUS_ConcludeCallback conclude, void *conclude_cls)
We are done with inserting new elements into the consensus; try to conclude the consensus within a gi...
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
@ GNUNET_ERROR_TYPE_WARNING
@ GNUNET_ERROR_TYPE_DEBUG
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_free(ptr)
Wrapper around free.
GNUNET_MQ_Error
Error codes for the queue.
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct.
#define GNUNET_MQ_msg_header(type)
Allocate a GNUNET_MQ_Envelope, where the message only consists of a header.
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
void GNUNET_MQ_notify_sent(struct GNUNET_MQ_Envelope *ev, GNUNET_SCHEDULER_TaskCallback cb, void *cb_cls)
Call a callback once the envelope has been sent, that is, sending it can not be canceled anymore.
#define GNUNET_MQ_hd_fixed_size(name, code, str, ctx)
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
#define GNUNET_MESSAGE_TYPE_CONSENSUS_CLIENT_JOIN
Join a consensus session.
#define GNUNET_MESSAGE_TYPE_CONSENSUS_CLIENT_CONCLUDE_DONE
Sent by service to client in order to signal a completed consensus conclusion.
#define GNUNET_MESSAGE_TYPE_CONSENSUS_CLIENT_RECEIVED_ELEMENT
Sent by service when a new element is added.
#define GNUNET_MESSAGE_TYPE_CONSENSUS_CLIENT_INSERT
Insert an element.
#define GNUNET_MESSAGE_TYPE_CONSENSUS_CLIENT_CONCLUDE
Sent by client to service in order to start the consensus conclusion.
struct GNUNET_TIME_AbsoluteNBO GNUNET_TIME_absolute_hton(struct GNUNET_TIME_Absolute a)
Convert absolute time to network byte order.
GNUNET_CONSENSUS_ConcludeCallback conclude_cb
Called when the conclude operation finishes or fails.
int joined
GNUNET_YES iff the join message has been sent to the service.
void * conclude_cls
Closure for the conclude_cb callback.
void * new_element_cls
Closure for new_element_cb.
GNUNET_CONSENSUS_ElementCallback new_element_cb
Callback for new elements.
struct GNUNET_TIME_Absolute conclude_deadline
Deadline for the conclude operation.
struct GNUNET_HashCode session_id
The (local) session identifier for the consensus session.
struct GNUNET_MQ_Handle * mq
Message queue for the client.
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration to use.
Sent by the client to the service, when the client wants the service to join a consensus session.
struct GNUNET_HashCode session_id
Session id of the consensus.
struct GNUNET_TIME_AbsoluteNBO deadline
Deadline for conclude.
uint32_t num_peers
Number of peers (at the end of this message) that want to participate in the consensus.
struct GNUNET_TIME_AbsoluteNBO start
Start time for the consensus.
Handle to a message queue.
Message handler for a specific message type.
The identity of the host (wraps the signing key of the peer).
uint16_t size
Number of bytes in the buffer pointed to by data.
const void * data
Actual data of the element.
uint16_t element_type
Application-specific element type.
Time for absolute times used by GNUnet, in microseconds.
FIXME: this should not bee necessary when the API issue has been fixed.
GNUNET_CONSENSUS_InsertDoneCallback idc