Electroneum
daemon_messages.h
Go to the documentation of this file.
1 // Copyright (c) 2016-2019, 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 #pragma once
30 
31 #include <unordered_map>
32 #include <vector>
33 
34 #include "message.h"
37 #include "rpc/daemon_rpc_version.h"
39 
40 #define BEGIN_RPC_MESSAGE_CLASS(classname) \
41 class classname \
42 { \
43  public: \
44  static const char* const name;
45 
46 #define BEGIN_RPC_MESSAGE_REQUEST \
47  class Request : public Message \
48  { \
49  public: \
50  Request() { } \
51  ~Request() { } \
52  rapidjson::Value toJson(rapidjson::Document& doc) const; \
53  void fromJson(rapidjson::Value& val);
54 
55 #define BEGIN_RPC_MESSAGE_RESPONSE \
56  class Response : public Message \
57  { \
58  public: \
59  Response() { } \
60  ~Response() { } \
61  rapidjson::Value toJson(rapidjson::Document& doc) const; \
62  void fromJson(rapidjson::Value& val);
63 
64 #define END_RPC_MESSAGE_REQUEST };
65 #define END_RPC_MESSAGE_RESPONSE };
66 #define END_RPC_MESSAGE_CLASS };
67 
68 // NOTE: when using a type with multiple template parameters,
69 // replace any comma in the template specifier with the macro
70 // above, or the preprocessor will eat the comma in a bad way.
71 #define RPC_MESSAGE_MEMBER(type, name) type name = {}
72 
73 
74 namespace cryptonote
75 {
76 
77 namespace rpc
78 {
79 
80 BEGIN_RPC_MESSAGE_CLASS(GetHeight);
87 
88 
89 BEGIN_RPC_MESSAGE_CLASS(GetBlocksFast);
91  RPC_MESSAGE_MEMBER(std::list<crypto::hash>, block_ids);
92  RPC_MESSAGE_MEMBER(uint64_t, start_height);
93  RPC_MESSAGE_MEMBER(bool, prune);
96  RPC_MESSAGE_MEMBER(std::vector<cryptonote::rpc::block_with_transactions>, blocks);
97  RPC_MESSAGE_MEMBER(uint64_t, start_height);
98  RPC_MESSAGE_MEMBER(uint64_t, current_height);
99  RPC_MESSAGE_MEMBER(std::vector<cryptonote::rpc::block_output_indices>, output_indices);
102 
103 
104 BEGIN_RPC_MESSAGE_CLASS(GetHashesFast);
106  RPC_MESSAGE_MEMBER(std::list<crypto::hash>, known_hashes);
107  RPC_MESSAGE_MEMBER(uint64_t, start_height);
110  RPC_MESSAGE_MEMBER(std::vector<crypto::hash>, hashes);
111  RPC_MESSAGE_MEMBER(uint64_t, start_height);
112  RPC_MESSAGE_MEMBER(uint64_t, current_height);
115 
116 
117 BEGIN_RPC_MESSAGE_CLASS(GetTransactions);
119  RPC_MESSAGE_MEMBER(std::vector<crypto::hash>, tx_hashes);
122  using txes_map = std::unordered_map<crypto::hash, transaction_info>;
124  RPC_MESSAGE_MEMBER(std::vector<crypto::hash>, missed_hashes);
127 
128 
129 BEGIN_RPC_MESSAGE_CLASS(KeyImagesSpent);
130  enum STATUS {
131  UNSPENT = 0,
134  };
136  RPC_MESSAGE_MEMBER(std::vector<crypto::key_image>, key_images);
139  RPC_MESSAGE_MEMBER(std::vector<uint64_t>, spent_status);
142 
143 
144 BEGIN_RPC_MESSAGE_CLASS(GetTxGlobalOutputIndices);
149  RPC_MESSAGE_MEMBER(std::vector<uint64_t>, output_indices);
152 
153 
154 BEGIN_RPC_MESSAGE_CLASS(GetRandomOutputsForAmounts);
156  RPC_MESSAGE_MEMBER(std::vector<uint64_t>, amounts);
160  RPC_MESSAGE_MEMBER(std::vector<amount_with_random_outputs>, amounts_with_outputs);
163 
164 BEGIN_RPC_MESSAGE_CLASS(SendRawTx);
167  RPC_MESSAGE_MEMBER(bool, relay);
170  RPC_MESSAGE_MEMBER(bool, relayed);
173 
174 BEGIN_RPC_MESSAGE_CLASS(SendRawTxHex);
176  RPC_MESSAGE_MEMBER(std::string, tx_as_hex);
177  RPC_MESSAGE_MEMBER(bool, relay);
181 
182 BEGIN_RPC_MESSAGE_CLASS(StartMining);
184  RPC_MESSAGE_MEMBER(std::string, miner_address);
185  RPC_MESSAGE_MEMBER(uint64_t, threads_count);
186  RPC_MESSAGE_MEMBER(bool, do_background_mining);
187  RPC_MESSAGE_MEMBER(bool, ignore_battery);
192 
193 BEGIN_RPC_MESSAGE_CLASS(GetInfo);
200 
201 BEGIN_RPC_MESSAGE_CLASS(StopMining);
207 
208 BEGIN_RPC_MESSAGE_CLASS(MiningStatus);
212  RPC_MESSAGE_MEMBER(bool, active);
214  RPC_MESSAGE_MEMBER(uint64_t, threads_count);
216  RPC_MESSAGE_MEMBER(bool, is_background_mining_enabled);
219 
226 
227 BEGIN_RPC_MESSAGE_CLASS(GetBlockHash);
235 
236 BEGIN_RPC_MESSAGE_CLASS(GetBlockTemplate);
242 
243 BEGIN_RPC_MESSAGE_CLASS(SubmitBlock);
249 
250 BEGIN_RPC_MESSAGE_CLASS(GetLastBlockHeader);
257 
258 BEGIN_RPC_MESSAGE_CLASS(GetBlockHeaderByHash);
266 
267 BEGIN_RPC_MESSAGE_CLASS(GetBlockHeaderByHeight);
275 
276 BEGIN_RPC_MESSAGE_CLASS(GetBlockHeadersByHeight);
278  RPC_MESSAGE_MEMBER(std::vector<uint64_t>, heights);
281  RPC_MESSAGE_MEMBER(std::vector<cryptonote::rpc::BlockHeaderResponse>, headers);
284 
285 BEGIN_RPC_MESSAGE_CLASS(GetBlock);
291 
292 BEGIN_RPC_MESSAGE_CLASS(GetPeerList);
296  RPC_MESSAGE_MEMBER(std::vector<peer>, white_list);
297  RPC_MESSAGE_MEMBER(std::vector<peer>, gray_list);
300 
301 BEGIN_RPC_MESSAGE_CLASS(SetLogHashRate);
307 
308 BEGIN_RPC_MESSAGE_CLASS(SetLogLevel);
310  RPC_MESSAGE_MEMBER(int8_t, level);
315 
316 BEGIN_RPC_MESSAGE_CLASS(GetTransactionPool);
320  RPC_MESSAGE_MEMBER(std::vector<cryptonote::rpc::tx_in_pool>, transactions);
324 
325 BEGIN_RPC_MESSAGE_CLASS(GetConnections);
331 
332 BEGIN_RPC_MESSAGE_CLASS(GetBlockHeadersRange);
338 
339 BEGIN_RPC_MESSAGE_CLASS(StopDaemon);
345 
346 BEGIN_RPC_MESSAGE_CLASS(StartSaveGraph);
352 
353 BEGIN_RPC_MESSAGE_CLASS(StopSaveGraph);
359 
360 BEGIN_RPC_MESSAGE_CLASS(HardForkInfo);
368 
369 BEGIN_RPC_MESSAGE_CLASS(GetBans);
375 
376 BEGIN_RPC_MESSAGE_CLASS(SetBans);
382 
383 BEGIN_RPC_MESSAGE_CLASS(FlushTransactionPool);
389 
390 BEGIN_RPC_MESSAGE_CLASS(GetOutputHistogram);
392  RPC_MESSAGE_MEMBER(std::vector<uint64_t>, amounts);
393  RPC_MESSAGE_MEMBER(uint64_t, min_count);
394  RPC_MESSAGE_MEMBER(uint64_t, max_count);
395  RPC_MESSAGE_MEMBER(bool, unlocked);
396  RPC_MESSAGE_MEMBER(uint64_t, recent_cutoff);
399  RPC_MESSAGE_MEMBER(std::vector<output_amount_count>, histogram);
402 
403 BEGIN_RPC_MESSAGE_CLASS(GetOutputKeys);
405  RPC_MESSAGE_MEMBER(std::vector<output_amount_and_index>, outputs);
408  RPC_MESSAGE_MEMBER(std::vector<output_key_mask_unlocked>, keys);
411 
412 BEGIN_RPC_MESSAGE_CLASS(GetRPCVersion);
419 
420 BEGIN_RPC_MESSAGE_CLASS(GetFeeEstimate);
422  RPC_MESSAGE_MEMBER(uint64_t, num_grace_blocks);
425  RPC_MESSAGE_MEMBER(uint64_t, estimated_base_fee);
426  RPC_MESSAGE_MEMBER(uint64_t, fee_mask);
427  RPC_MESSAGE_MEMBER(uint32_t, size_scale);
428  RPC_MESSAGE_MEMBER(uint8_t, hard_fork_version);
431 
432 BEGIN_RPC_MESSAGE_CLASS(GetOutputDistribution);
434  RPC_MESSAGE_MEMBER(std::vector<uint64_t>, amounts);
435  RPC_MESSAGE_MEMBER(uint64_t, from_height);
436  RPC_MESSAGE_MEMBER(uint64_t, to_height);
437  RPC_MESSAGE_MEMBER(bool, cumulative);
440  RPC_MESSAGE_MEMBER(std::vector<output_distribution>, distributions);
443 
444 } // namespace rpc
445 
446 } // namespace cryptonote
std::unordered_map< crypto::hash, transaction_info > txes_map
SendRawTx::Response Response
::std::string string
Definition: gtest-port.h:1097
uint64_t height
Definition: blockchain.cpp:91
unsigned char uint8_t
Definition: stdint.h:124
struct hash_func hashes[]
std::unordered_map< crypto::key_image, std::vector< crypto::hash > > key_images_with_tx_hashes
Holds cryptonote related classes and helpers.
Definition: ban.cpp:40
mdb_size_t count(MDB_cursor *cur)
unsigned int uint32_t
Definition: stdint.h:126
BEGIN_RPC_MESSAGE_CLASS(GetHeight)
unsigned __int64 uint64_t
Definition: stdint.h:136
signed char int8_t
Definition: stdint.h:121
RPC_MESSAGE_MEMBER(uint64_t, height)
version
Supported socks variants.
Definition: socks.h:57
CXA_THROW_INFO_T * info
Definition: stack_trace.cpp:91
POD_CLASS hash
Definition: hash.h:50
const char * address
Definition: multisig.cpp:37