Monero
Loading...
Searching...
No Matches
cryptonote_protocol_defs.h
Go to the documentation of this file.
1// Copyright (c) 2014-2022, The Monero Project
2//
3// All rights reserved.
4//
5// Redistribution and use in source and binary forms, with or without modification, are
6// permitted provided that the following conditions are met:
7//
8// 1. Redistributions of source code must retain the above copyright notice, this list of
9// conditions and the following disclaimer.
10//
11// 2. Redistributions in binary form must reproduce the above copyright notice, this list
12// of conditions and the following disclaimer in the documentation and/or other
13// materials provided with the distribution.
14//
15// 3. Neither the name of the copyright holder nor the names of its contributors may be
16// used to endorse or promote products derived from this software without specific
17// prior written permission.
18//
19// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
20// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
22// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
27// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28//
29// Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers
30
31#pragma once
32
33#include <list>
37
38namespace cryptonote
39{
40
41
42#define BC_COMMANDS_POOL_BASE 2000
43
44 /************************************************************************/
45 /* P2P connection info, serializable to json */
46 /************************************************************************/
48 {
52 bool ssl;
53
54 std::string address;
55 std::string host;
56 std::string ip;
57 std::string port;
60
61 std::string peer_id;
62
65
68
69 std::string state;
70
72
75
78
80
81 std::string connection_id;
82
84
86
88
116 };
117
118 /************************************************************************/
119 /* */
120 /************************************************************************/
122 {
126 KV_SERIALIZE(blob)
127 KV_SERIALIZE_VAL_POD_AS_BLOB(prunable_hash)
129
130 tx_blob_entry(const blobdata &bd = {}, const crypto::hash &h = crypto::null_hash): blob(bd), prunable_hash(h) {}
131 };
133 {
134 bool pruned;
137 std::vector<tx_blob_entry> txs;
139 KV_SERIALIZE_OPT(pruned, false)
142 if (this_ref.pruned)
143 {
144 KV_SERIALIZE(txs)
145 }
146 else
147 {
148 std::vector<blobdata> txs;
149 if (is_store)
150 {
151 txs.reserve(this_ref.txs.size());
152 for (const auto &e: this_ref.txs) txs.push_back(e.blob);
153 }
154 epee::serialization::selector<is_store>::serialize(txs, stg, hparent_section, "txs");
155 if (!is_store)
156 {
157 block_complete_entry &self = const_cast<block_complete_entry&>(this_ref);
158 self.txs.clear();
159 self.txs.reserve(txs.size());
160 for (auto &e: txs) self.txs.push_back({std::move(e), crypto::null_hash});
161 }
162 }
164
166 };
167
168
169 /************************************************************************/
170 /* */
171 /************************************************************************/
173 {
174 const static int ID = BC_COMMANDS_POOL_BASE + 1;
175
177 {
180
183 KV_SERIALIZE(current_blockchain_height)
185 };
186 typedef epee::misc_utils::struct_init<request_t> request;
187 };
188
189 /************************************************************************/
190 /* */
191 /************************************************************************/
193 {
194 const static int ID = BC_COMMANDS_POOL_BASE + 2;
195
197 {
198 std::vector<blobdata> txs;
199 std::string _; // padding
200 bool dandelionpp_fluff; //zero initialization defaults to stem mode
201
203 KV_SERIALIZE(txs)
204 KV_SERIALIZE(_)
205 KV_SERIALIZE_OPT(dandelionpp_fluff, true) // backwards compatible mode is fluff
207 };
208 typedef epee::misc_utils::struct_init<request_t> request;
209 };
210 /************************************************************************/
211 /* */
212 /************************************************************************/
214 {
215 const static int ID = BC_COMMANDS_POOL_BASE + 3;
216
218 {
219 std::vector<crypto::hash> blocks;
220 bool prune;
221
226 };
227 typedef epee::misc_utils::struct_init<request_t> request;
228 };
229
231 {
232 const static int ID = BC_COMMANDS_POOL_BASE + 4;
233
235 {
236 std::vector<block_complete_entry> blocks;
237 std::vector<crypto::hash> missed_ids;
239
243 KV_SERIALIZE(current_blockchain_height)
245 };
246 typedef epee::misc_utils::struct_init<request_t> request;
247 };
248
249
251 {
258
260 KV_SERIALIZE(current_height)
261 KV_SERIALIZE(cumulative_difficulty)
262 if (is_store)
263 KV_SERIALIZE(cumulative_difficulty_top64)
264 else
265 KV_SERIALIZE_OPT(cumulative_difficulty_top64, (uint64_t)0)
267 KV_SERIALIZE_OPT(top_version, (uint8_t)0)
268 KV_SERIALIZE_OPT(pruning_seed, (uint32_t)0)
270 };
271
273 {
274 const static int ID = BC_COMMANDS_POOL_BASE + 6;
275
277 {
278 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 */
279 bool prune;
280
285 };
286 typedef epee::misc_utils::struct_init<request_t> request;
287 };
288
290 {
291 const static int ID = BC_COMMANDS_POOL_BASE + 7;
292
294 {
299 std::vector<crypto::hash> m_block_ids;
300 std::vector<uint64_t> m_block_weights;
302
304 KV_SERIALIZE(start_height)
305 KV_SERIALIZE(total_height)
306 KV_SERIALIZE(cumulative_difficulty)
307 if (is_store)
308 KV_SERIALIZE(cumulative_difficulty_top64)
309 else
310 KV_SERIALIZE_OPT(cumulative_difficulty_top64, (uint64_t)0)
313 KV_SERIALIZE(first_block)
315 };
316 typedef epee::misc_utils::struct_init<request_t> request;
317 };
318
319 /************************************************************************/
320 /* */
321 /************************************************************************/
323 {
324 const static int ID = BC_COMMANDS_POOL_BASE + 8;
325
327 {
330
333 KV_SERIALIZE(current_blockchain_height)
335 };
336 typedef epee::misc_utils::struct_init<request_t> request;
337 };
338
339 /************************************************************************/
340 /* */
341 /************************************************************************/
343 {
344 const static int ID = BC_COMMANDS_POOL_BASE + 9;
345
347 {
350 std::vector<uint64_t> missing_tx_indices;
351
354 KV_SERIALIZE(current_blockchain_height)
355 KV_SERIALIZE_CONTAINER_POD_AS_BLOB(missing_tx_indices)
357 };
358 typedef epee::misc_utils::struct_init<request_t> request;
359 };
360
361 /************************************************************************/
362 /* */
363 /************************************************************************/
365 {
366 const static int ID = BC_COMMANDS_POOL_BASE + 10;
367
369 {
370 std::vector<crypto::hash> hashes;
371
375 };
376 typedef epee::misc_utils::struct_init<request_t> request;
377 };
378
379}
cryptonote::block b
Definition: block.cpp:40
static void prune(MDB_env *env0, MDB_env *env1)
Definition: blockchain_prune.cpp:249
static uint64_t h
Definition: blockchain_stats.cpp:55
#define BC_COMMANDS_POOL_BASE
Definition: cryptonote_protocol_defs.h:42
#define const
Definition: ipfrdr.c:80
#define KV_SERIALIZE_VAL_POD_AS_BLOB(varialble)
Definition: keyvalue_serialization.h:119
#define KV_SERIALIZE(varialble)
Definition: keyvalue_serialization.h:118
#define KV_SERIALIZE_OPT(variable, default_value)
Definition: keyvalue_serialization.h:123
#define KV_SERIALIZE_CONTAINER_POD_AS_BLOB(varialble)
Definition: keyvalue_serialization.h:122
#define END_KV_SERIALIZE_MAP()
Definition: keyvalue_serialization.h:116
#define BEGIN_KV_SERIALIZE_MAP()
Definition: keyvalue_serialization.h:43
Definition: block_weight.py:1
Definition: blocks.cpp:13
static constexpr crypto::hash null_hash
Definition: hash.h:92
POD_CLASS hash
Definition: hash.h:48
Holds cryptonote related classes and helpers.
Definition: blockchain_db.cpp:45
std::string blobdata
Definition: blobdatatype.h:39
TODO: (mj-xmr) This will be reduced in an another PR.
Definition: byte_slice.h:40
if(!cryptonote::get_account_address_from_str_or_url(info, cryptonote::TESTNET, "9uVsvEryzpN8WH2t1WWhFFCG5tS8cBNdmJYNRuckLENFimfauV5pZKeS1P2CbxGkSDTUPHXWwiYE5ZGSXDAGbaZgDxobqDN"))
Definition: signature.cpp:53
#define true
Definition: stdbool.h:36
#define false
Definition: stdbool.h:37
unsigned short uint16_t
Definition: stdint.h:125
unsigned int uint32_t
Definition: stdint.h:126
unsigned char uint8_t
Definition: stdint.h:124
unsigned __int64 uint64_t
Definition: stdint.h:136
Definition: cryptonote_protocol_defs.h:251
uint64_t cumulative_difficulty_top64
Definition: cryptonote_protocol_defs.h:254
uint32_t pruning_seed
Definition: cryptonote_protocol_defs.h:257
uint64_t cumulative_difficulty
Definition: cryptonote_protocol_defs.h:253
uint8_t top_version
Definition: cryptonote_protocol_defs.h:256
uint64_t current_height
Definition: cryptonote_protocol_defs.h:252
crypto::hash top_id
Definition: cryptonote_protocol_defs.h:255
Definition: cryptonote_protocol_defs.h:369
std::vector< crypto::hash > hashes
Definition: cryptonote_protocol_defs.h:370
Definition: cryptonote_protocol_defs.h:365
Definition: cryptonote_protocol_defs.h:177
uint64_t current_blockchain_height
Definition: cryptonote_protocol_defs.h:179
block_complete_entry b
Definition: cryptonote_protocol_defs.h:178
Definition: cryptonote_protocol_defs.h:173
Definition: cryptonote_protocol_defs.h:327
uint64_t current_blockchain_height
Definition: cryptonote_protocol_defs.h:329
block_complete_entry b
Definition: cryptonote_protocol_defs.h:328
Definition: cryptonote_protocol_defs.h:323
Definition: cryptonote_protocol_defs.h:197
std::string _
Definition: cryptonote_protocol_defs.h:199
bool dandelionpp_fluff
Definition: cryptonote_protocol_defs.h:200
std::vector< blobdata > txs
Definition: cryptonote_protocol_defs.h:198
Definition: cryptonote_protocol_defs.h:193
Definition: cryptonote_protocol_defs.h:277
std::list< crypto::hash > block_ids
Definition: cryptonote_protocol_defs.h:278
bool prune
Definition: cryptonote_protocol_defs.h:279
Definition: cryptonote_protocol_defs.h:273
Definition: cryptonote_protocol_defs.h:347
uint64_t current_blockchain_height
Definition: cryptonote_protocol_defs.h:349
std::vector< uint64_t > missing_tx_indices
Definition: cryptonote_protocol_defs.h:350
crypto::hash block_hash
Definition: cryptonote_protocol_defs.h:348
Definition: cryptonote_protocol_defs.h:343
Definition: cryptonote_protocol_defs.h:218
bool prune
Definition: cryptonote_protocol_defs.h:220
std::vector< crypto::hash > blocks
Definition: cryptonote_protocol_defs.h:219
Definition: cryptonote_protocol_defs.h:214
Definition: cryptonote_protocol_defs.h:294
std::vector< uint64_t > m_block_weights
Definition: cryptonote_protocol_defs.h:300
uint64_t total_height
Definition: cryptonote_protocol_defs.h:296
uint64_t cumulative_difficulty_top64
Definition: cryptonote_protocol_defs.h:298
cryptonote::blobdata first_block
Definition: cryptonote_protocol_defs.h:301
uint64_t cumulative_difficulty
Definition: cryptonote_protocol_defs.h:297
std::vector< crypto::hash > m_block_ids
Definition: cryptonote_protocol_defs.h:299
uint64_t start_height
Definition: cryptonote_protocol_defs.h:295
Definition: cryptonote_protocol_defs.h:290
Definition: cryptonote_protocol_defs.h:235
std::vector< block_complete_entry > blocks
Definition: cryptonote_protocol_defs.h:236
std::vector< crypto::hash > missed_ids
Definition: cryptonote_protocol_defs.h:237
uint64_t current_blockchain_height
Definition: cryptonote_protocol_defs.h:238
Definition: cryptonote_protocol_defs.h:231
Definition: cryptonote_protocol_defs.h:133
uint64_t block_weight
Definition: cryptonote_protocol_defs.h:136
std::vector< tx_blob_entry > txs
Definition: cryptonote_protocol_defs.h:137
bool pruned
Definition: cryptonote_protocol_defs.h:134
blobdata block
Definition: cryptonote_protocol_defs.h:135
Definition: cryptonote_basic.h:475
Definition: cryptonote_protocol_defs.h:48
std::string connection_id
Definition: cryptonote_protocol_defs.h:81
uint32_t pruning_seed
Definition: cryptonote_protocol_defs.h:85
std::string address
Definition: cryptonote_protocol_defs.h:54
uint8_t address_type
Definition: cryptonote_protocol_defs.h:87
uint64_t recv_count
Definition: cryptonote_protocol_defs.h:63
uint64_t live_time
Definition: cryptonote_protocol_defs.h:71
uint32_t support_flags
Definition: cryptonote_protocol_defs.h:79
uint32_t rpc_credits_per_hash
Definition: cryptonote_protocol_defs.h:59
bool localhost
Definition: cryptonote_protocol_defs.h:50
std::string port
Definition: cryptonote_protocol_defs.h:57
uint64_t height
Definition: cryptonote_protocol_defs.h:83
uint64_t send_idle_time
Definition: cryptonote_protocol_defs.h:67
std::string host
Definition: cryptonote_protocol_defs.h:55
std::string ip
Definition: cryptonote_protocol_defs.h:56
uint64_t current_download
Definition: cryptonote_protocol_defs.h:74
uint64_t avg_download
Definition: cryptonote_protocol_defs.h:73
uint64_t recv_idle_time
Definition: cryptonote_protocol_defs.h:64
uint16_t rpc_port
Definition: cryptonote_protocol_defs.h:58
uint64_t send_count
Definition: cryptonote_protocol_defs.h:66
std::string state
Definition: cryptonote_protocol_defs.h:69
bool local_ip
Definition: cryptonote_protocol_defs.h:51
bool ssl
Definition: cryptonote_protocol_defs.h:52
bool incoming
Definition: cryptonote_protocol_defs.h:49
std::string peer_id
Definition: cryptonote_protocol_defs.h:61
uint64_t current_upload
Definition: cryptonote_protocol_defs.h:77
uint64_t avg_upload
Definition: cryptonote_protocol_defs.h:76
Definition: cryptonote_protocol_defs.h:122
crypto::hash prunable_hash
Definition: cryptonote_protocol_defs.h:124
blobdata blob
Definition: cryptonote_protocol_defs.h:123
Definition: misc_language.h:104
Definition: keyvalue_serialization_overloads.h:322
Definition: blake256.h:36
struct hash_func hashes[]