consensus_protocol.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. /*
  2. This file is part of GNUnet
  3. Copyright (C) 2012 GNUnet e.V.
  4. GNUnet is free software: you can redistribute it and/or modify it
  5. under the terms of the GNU Affero General Public License as published
  6. by the Free Software Foundation, either version 3 of the License,
  7. or (at your option) any later version.
  8. GNUnet is distributed in the hope that it will be useful, but
  9. WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Affero General Public License for more details.
  12. You should have received a copy of the GNU Affero General Public License
  13. along with this program. If not, see <http://www.gnu.org/licenses/>.
  14. SPDX-License-Identifier: AGPL3.0-or-later
  15. */
  16. /**
  17. * @file consensus/consensus_protocol.h
  18. * @brief p2p message definitions for consensus
  19. * @author Florian Dold
  20. */
  21. #ifndef GNUNET_CONSENSUS_PROTOCOL_H
  22. #define GNUNET_CONSENSUS_PROTOCOL_H
  23. #include "platform.h"
  24. #include "gnunet_util_lib.h"
  25. #include "gnunet_common.h"
  26. #include "gnunet_protocols.h"
  27. GNUNET_NETWORK_STRUCT_BEGIN
  28. /**
  29. * Sent as context message for set reconciliation.
  30. *
  31. * Essentially contains all the fields
  32. * from 'struct TaskKey', but in NBO.
  33. */
  34. struct GNUNET_CONSENSUS_RoundContextMessage
  35. {
  36. /**
  37. * Type: #GNUNET_MESSAGE_TYPE_CONSENSUS_P2P_ROUND_CONTEXT
  38. */
  39. struct GNUNET_MessageHeader header;
  40. /**
  41. * A value from 'enum PhaseKind'.
  42. */
  43. uint16_t kind GNUNET_PACKED;
  44. /**
  45. * Number of the first peer
  46. * in canonical order.
  47. */
  48. int16_t peer1 GNUNET_PACKED;
  49. /**
  50. * Number of the second peer in canonical order.
  51. */
  52. int16_t peer2 GNUNET_PACKED;
  53. /**
  54. * Repetition of the gradecast phase.
  55. */
  56. int16_t repetition GNUNET_PACKED;
  57. /**
  58. * Leader in the gradecast phase.
  59. *
  60. * Can be different from both peer1 and peer2.
  61. */
  62. int16_t leader GNUNET_PACKED;
  63. /**
  64. * Non-zero if this set reconciliation
  65. * had elements removed because they were contested.
  66. *
  67. * Will be considered when grading broadcasts.
  68. *
  69. * Ignored for set operations that are not within gradecasts.
  70. */
  71. uint16_t is_contested GNUNET_PACKED;
  72. };
  73. enum {
  74. CONSENSUS_MARKER_CONTESTED = 1,
  75. CONSENSUS_MARKER_SIZE = 2,
  76. };
  77. /**
  78. * Consensus element, either marker or payload.
  79. */
  80. struct ConsensusElement
  81. {
  82. /**
  83. * Payload element_type, only valid
  84. * if this is not a marker element.
  85. */
  86. uint16_t payload_type GNUNET_PACKED;
  87. /**
  88. * Is this a marker element?
  89. */
  90. uint8_t marker;
  91. /* rest: element data */
  92. };
  93. struct ConsensusSizeElement
  94. {
  95. struct ConsensusElement ce;
  96. uint64_t size GNUNET_PACKED;
  97. uint8_t sender_index;
  98. };
  99. struct ConsensusStuffedElement
  100. {
  101. struct ConsensusElement ce;
  102. struct GNUNET_HashCode rand GNUNET_PACKED;
  103. };
  104. GNUNET_NETWORK_STRUCT_END
  105. #endif