Electroneum
cryptonote_protocol_defs.h
Go to the documentation of this file.
1 // Copyrights(c) 2017-2021, The Electroneum Project
2 // Copyrights(c) 2014-2019, The Monero Project
3 //
4 // All rights reserved.
5 //
6 // Redistribution and use in source and binary forms, with or without modification, are
7 // permitted provided that the following conditions are met:
8 //
9 // 1. Redistributions of source code must retain the above copyright notice, this list of
10 // conditions and the following disclaimer.
11 //
12 // 2. Redistributions in binary form must reproduce the above copyright notice, this list
13 // of conditions and the following disclaimer in the documentation and/or other
14 // materials provided with the distribution.
15 //
16 // 3. Neither the name of the copyright holder nor the names of its contributors may be
17 // used to endorse or promote products derived from this software without specific
18 // prior written permission.
19 //
20 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
21 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
22 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
23 // THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
27 // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
28 // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 //
30 // Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers
31 
32 #pragma once
33 
34 #include <list>
38 
39 namespace cryptonote
40 {
41 
42 
43 #define BC_COMMANDS_POOL_BASE 2000
44 
45  /************************************************************************/
46  /* P2P connection info, serializable to json */
47  /************************************************************************/
49  {
50  bool incoming;
51  bool localhost;
52  bool local_ip;
53  bool ssl;
54 
60 
62 
65 
68 
70 
72 
75 
78 
80 
82 
84 
86 
112  };
113 
114  /************************************************************************/
115  /* */
116  /************************************************************************/
118  {
120  std::vector<blobdata> txs;
123  KV_SERIALIZE(txs)
125  };
126 
127 
128  /************************************************************************/
129  /* */
130  /************************************************************************/
132  {
133  const static int ID = BC_COMMANDS_POOL_BASE + 1;
134 
135  struct request_t
136  {
139 
141  KV_SERIALIZE(b)
142  KV_SERIALIZE(current_blockchain_height)
144  };
145  typedef epee::misc_utils::struct_init<request_t> request;
146  };
147 
148  /************************************************************************/
149  /* */
150  /************************************************************************/
152  {
153  const static int ID = BC_COMMANDS_POOL_BASE + 2;
154 
155  struct request_t
156  {
157  std::vector<blobdata> txs;
158  std::string _; // padding
159 
161  KV_SERIALIZE(txs)
162  KV_SERIALIZE(_)
164  };
165  typedef epee::misc_utils::struct_init<request_t> request;
166  };
167  /************************************************************************/
168  /* */
169  /************************************************************************/
171  {
172  const static int ID = BC_COMMANDS_POOL_BASE + 3;
173 
174  struct request_t
175  {
176  std::vector<crypto::hash> txs;
177  std::vector<crypto::hash> blocks;
178 
183  };
184  typedef epee::misc_utils::struct_init<request_t> request;
185  };
186 
188  {
189  const static int ID = BC_COMMANDS_POOL_BASE + 4;
190 
191  struct request_t
192  {
193  std::vector<blobdata> txs;
194  std::vector<block_complete_entry> blocks;
195  std::vector<crypto::hash> missed_ids;
197 
199  KV_SERIALIZE(txs)
202  KV_SERIALIZE(current_blockchain_height)
204  };
205  typedef epee::misc_utils::struct_init<request_t> request;
206  };
207 
208 
210  {
217 
219  KV_SERIALIZE(current_height)
220  KV_SERIALIZE(cumulative_difficulty)
221  KV_SERIALIZE(cumulative_difficulty_top64)
223  KV_SERIALIZE_OPT(top_version, (uint8_t)0)
226  };
227 
229  {
230  const static int ID = BC_COMMANDS_POOL_BASE + 6;
231 
232  struct request_t
233  {
234  std::list<crypto::hash> block_ids; /*IDs of the first 10 blocks are sequential, next goes with pow(2,n) offset, like 2, 4, 8, 16, 32, 64 and so on, and the last one is always genesis block */
235 
239  };
240  typedef epee::misc_utils::struct_init<request_t> request;
241  };
242 
244  {
245  const static int ID = BC_COMMANDS_POOL_BASE + 7;
246 
247  struct request_t
248  {
253  std::vector<crypto::hash> m_block_ids;
254 
256  KV_SERIALIZE(start_height)
257  KV_SERIALIZE(total_height)
258  KV_SERIALIZE(cumulative_difficulty)
259  KV_SERIALIZE(cumulative_difficulty_top64)
262  };
263  typedef epee::misc_utils::struct_init<request_t> request;
264  };
265 
266  /************************************************************************/
267  /* */
268  /************************************************************************/
270  {
271  const static int ID = BC_COMMANDS_POOL_BASE + 8;
272 
273  struct request_t
274  {
277 
279  KV_SERIALIZE(b)
280  KV_SERIALIZE(current_blockchain_height)
282  };
283  typedef epee::misc_utils::struct_init<request_t> request;
284  };
285 
286  /************************************************************************/
287  /* */
288  /************************************************************************/
290  {
291  const static int ID = BC_COMMANDS_POOL_BASE + 9;
292 
293  struct request_t
294  {
297  std::vector<uint64_t> missing_tx_indices;
298 
300  KV_SERIALIZE_VAL_POD_AS_BLOB(block_hash)
301  KV_SERIALIZE(current_blockchain_height)
302  KV_SERIALIZE_CONTAINER_POD_AS_BLOB(missing_tx_indices)
304  };
305  typedef epee::misc_utils::struct_init<request_t> request;
306  };
307 
308  /************************************************************************/
309  /* */
310  /************************************************************************/
312  {
313  const static int ID = BC_COMMANDS_POOL_BASE + 10;
314 
315  struct request_t
316  {
319  };
321 
322  struct response_t
323  {
325 
327  KV_SERIALIZE(serialized_v_list)
329  };
330  typedef epee::misc_utils::struct_init<response_t> response;
331 
334  };
335 
336  /************************************************************************/
337  /* */
338  /************************************************************************/
339 
341  {
342  const static int ID = BC_COMMANDS_POOL_BASE + 11;
343 
344  struct request_t
345  {
347 
349  KV_SERIALIZE(serialized_v_list)
351  };
352  typedef epee::misc_utils::struct_init<request_t> request;
353  };
354 }
#define BC_COMMANDS_POOL_BASE
::std::string string
Definition: gtest-port.h:1097
std::vector< blobdata > txs
unsigned short uint16_t
Definition: stdint.h:125
epee::misc_utils::struct_init< request_t > request
unsigned char uint8_t
Definition: stdint.h:124
#define KV_SERIALIZE(varialble)
Holds cryptonote related classes and helpers.
Definition: ban.cpp:40
unsigned int uint32_t
Definition: stdint.h:126
unsigned __int64 uint64_t
Definition: stdint.h:136
#define KV_SERIALIZE_CONTAINER_POD_AS_BLOB(varialble)
blobdata block
#define KV_SERIALIZE_VAL_POD_AS_BLOB(varialble)
std::string blobdata
Definition: blobdatatype.h:39
Definition: blake256.h:37
const internal::AnythingMatcher _
POD_CLASS hash
Definition: hash.h:50
#define END_KV_SERIALIZE_MAP()
#define KV_SERIALIZE_OPT(variable, default_value)
#define BEGIN_KV_SERIALIZE_MAP()