glitch in the license text detected by hyazinthe, thank you!
[oweals/gnunet.git] / src / consensus / consensus_protocol.h
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
16
17 /**
18  * @file consensus/consensus_protocol.h
19  * @brief p2p message definitions for consensus
20  * @author Florian Dold
21  */
22
23 #ifndef GNUNET_CONSENSUS_PROTOCOL_H
24 #define GNUNET_CONSENSUS_PROTOCOL_H
25
26 #include "platform.h"
27 #include "gnunet_util_lib.h"
28 #include "gnunet_common.h"
29 #include "gnunet_protocols.h"
30
31
32 GNUNET_NETWORK_STRUCT_BEGIN
33
34 /**
35  * Sent as context message for set reconciliation.
36  *
37  * Essentially contains all the fields
38  * from 'struct TaskKey', but in NBO.
39  */
40 struct GNUNET_CONSENSUS_RoundContextMessage
41 {
42   /**
43    * Type: #GNUNET_MESSAGE_TYPE_CONSENSUS_P2P_ROUND_CONTEXT
44    */
45   struct GNUNET_MessageHeader header;
46
47   /**
48    * A value from 'enum PhaseKind'.
49    */
50   uint16_t kind GNUNET_PACKED;
51
52   /**
53    * Number of the first peer
54    * in canonical order.
55    */
56   int16_t peer1 GNUNET_PACKED;
57
58   /**
59    * Number of the second peer in canonical order.
60    */
61   int16_t peer2 GNUNET_PACKED;
62
63   /**
64    * Repetition of the gradecast phase.
65    */
66   int16_t repetition GNUNET_PACKED;
67
68   /**
69    * Leader in the gradecast phase.
70    *
71    * Can be different from both peer1 and peer2.
72    */
73   int16_t leader GNUNET_PACKED;
74
75   /**
76    * Non-zero if this set reconciliation
77    * had elements removed because they were contested.
78    *
79    * Will be considered when grading broadcasts.
80    *
81    * Ignored for set operations that are not within gradecasts.
82    */
83   uint16_t is_contested GNUNET_PACKED;
84 };
85
86
87 enum {
88   CONSENSUS_MARKER_CONTESTED = 1,
89   CONSENSUS_MARKER_SIZE = 2,
90 };
91
92
93 /**
94  * Consensus element, either marker or payload.
95  */
96 struct ConsensusElement
97 {
98   /**
99    * Payload element_type, only valid
100    * if this is not a marker element.
101    */
102   uint16_t payload_type GNUNET_PACKED;
103
104   /**
105    * Is this a marker element?
106    */
107   uint8_t marker;
108
109   /* rest: element data */
110 };
111
112
113 struct ConsensusSizeElement
114 {
115   struct ConsensusElement ce;
116
117   uint64_t size GNUNET_PACKED;
118   uint8_t sender_index;
119 };
120
121 struct ConsensusStuffedElement
122 {
123   struct ConsensusElement ce;
124   struct GNUNET_HashCode rand GNUNET_PACKED;
125 };
126
127
128 GNUNET_NETWORK_STRUCT_END
129
130 #endif