GNUnet  0.11.x
gnunet_consensus_service.h
Go to the documentation of this file.
1 /*
2  This file is part of GNUnet
3  Copyright (C) 2012 GNUnet e.V.
4 
5  GNUnet is free software: you can redistribute it and/or modify it
6  under the terms of the GNU Affero General Public License as published
7  by the Free Software Foundation, either version 3 of the License,
8  or (at your 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  Affero General Public License for more details.
14 
15  You should have received a copy of the GNU Affero General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17 
18  SPDX-License-Identifier: AGPL3.0-or-later
19  */
20 
32 #ifndef GNUNET_CONSENSUS_SERVICE_H
33 #define GNUNET_CONSENSUS_SERVICE_H
34 
35 #ifdef __cplusplus
36 extern "C"
37 {
38 #if 0 /* keep Emacsens' auto-indent happy */
39 }
40 #endif
41 #endif
42 
43 #include "gnunet_common.h"
44 #include "gnunet_time_lib.h"
46 #include "gnunet_set_service.h"
47 
48 
54 #define GNUNET_CONSENSUS_ELEMENT_TYPE_USER_MAX 0xFFF0
55 
56 
66 typedef void (*GNUNET_CONSENSUS_ElementCallback) (void *cls,
67  const struct
68  GNUNET_SET_Element *element);
69 
70 
75 
76 
97  unsigned int num_peers,
98  const struct GNUNET_PeerIdentity *peers,
99  const struct GNUNET_HashCode *session_id,
103  void *new_element_cls);
104 
105 
117 typedef void (*GNUNET_CONSENSUS_InsertDoneCallback) (void *cls,
118  int success);
119 
120 
134 void
136  const struct GNUNET_SET_Element *element,
138  void *idc_cls);
139 
140 
146 typedef void (*GNUNET_CONSENSUS_ConcludeCallback) (void *cls);
147 
148 
157 void
160  void *conclude_cls);
161 
162 
169 void
171 
172 
173 #if 0 /* keep Emacsens' auto-indent happy */
174 {
175 #endif
176 #ifdef __cplusplus
177 }
178 #endif
179 
180 #endif
181  /* end of group */
void * new_element_cls
Closure for new_element_cb.
Definition: consensus_api.c:55
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.
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
Definition: gnunet-abd.c:36
Element stored in a set.
static int start
Set if we are to start default services (including ARM).
Definition: gnunet-arm.c:39
static struct GNUNET_HashCode session_id
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_ConcludeCallback)(void *cls)
Called when a conclusion was successful.
A 512-bit hashcode.
void(* GNUNET_CONSENSUS_InsertDoneCallback)(void *cls, int success)
Called when an insertion (transmission to consensus service, which does not imply fully consensus on ...
static unsigned int num_peers
The identity of the host (wraps the signing key of the peer).
configuration data
Definition: configuration.c:85
static struct CadetPeer * peers
Operation to get peer ids.
void GNUNET_CONSENSUS_conclude(struct GNUNET_CONSENSUS_Handle *consensus, GNUNET_CONSENSUS_ConcludeCallback conclude, void *conclude_cls)
We are finished inserting new elements into the consensus; try to conclude the consensus within a giv...
Handle for the service.
Definition: consensus_api.c:40
static struct GNUNET_TIME_Absolute deadline
Deadline for all consensuses.
void * conclude_cls
Closure for the conclude_cb callback.
Definition: consensus_api.c:75
Time for absolute times used by GNUnet, in microseconds.
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.
commonly used definitions; globals in this file are exempt from the rule that the module name ("commo...
static void new_element_cb(void *cls, const struct GNUNET_SET_Element *element)