Debian Codegraph @

src/rpc/message_data_structs.h

raw symbols SCIP
1 // Copyright (c) 2016-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 #pragma once
30
31 #include "crypto/hash.h"
32 #include "cryptonote_basic/cryptonote_basic.h"
33 #include "cryptonote_basic/difficulty.h"
34 #include "ringct/rctSigs.h"
35 #include "rpc/rpc_handler.h"
36
37 #include <unordered_map>
38 #include <vector>
39
40 namespace cryptonote
41 {
42
43 namespace rpc
44 {
45
46 struct block_with_transactions
47 {
48 cryptonote::block block;
49 std::vector<cryptonote::transaction> transactions;
50 };
51
52 typedef std::vector<uint64_t> tx_output_indices;
53
54 typedef std::vector<tx_output_indices> block_output_indices;
55
56 struct transaction_info
57 {
58 cryptonote::transaction transaction;
59 bool in_pool;
60 uint64_t height;
61 };
62
63 struct output_key_and_amount_index
64 {
65 uint64_t amount_index;
66 crypto::public_key key;
67 };
68
69 typedef std::vector<output_key_and_amount_index> outputs_for_amount;
70
71 struct amount_with_random_outputs
72 {
73 uint64_t amount;
74 outputs_for_amount outputs;
75 };
76
77 struct peer
78 {
79 uint64_t id;
80 uint32_t ip;
81 uint16_t port;
82 uint16_t rpc_port;
83 uint32_t rpc_credits_per_hash;
84 uint64_t last_seen;
85 uint32_t pruning_seed;
86 };
87
88 struct tx_in_pool
89 {
90 cryptonote::transaction tx;
91 crypto::hash tx_hash;
92 uint64_t blob_size;
93 uint64_t weight;
94 uint64_t fee;
95 crypto::hash max_used_block_hash;
96 uint64_t max_used_block_height;
97 bool kept_by_block;
98 crypto::hash last_failed_block_hash;
99 uint64_t last_failed_block_height;
100 uint64_t receive_time;
101 uint64_t last_relayed_time;
102 bool relayed;
103 bool do_not_relay;
104 bool double_spend_seen;
105 };
106
107 typedef std::unordered_map<crypto::key_image, std::vector<crypto::hash> > key_images_with_tx_hashes;
108
109 struct output_amount_count
110 {
111 uint64_t amount;
112 uint64_t total_count;
113 uint64_t unlocked_count;
114 uint64_t recent_count;
115 };
116
117 struct output_amount_and_index
118 {
119 uint64_t amount;
120 uint64_t index;
121 };
122
123 struct output_key_mask_unlocked
124 {
125 crypto::public_key key;
126 rct::key mask;
127 bool unlocked;
128 };
129
130 struct hard_fork_info
131 {
132 uint8_t version;
133 bool enabled;
134 uint32_t window;
135 uint32_t votes;
136 uint32_t threshold;
137 uint8_t voting;
138 uint32_t state;
139 uint64_t earliest_height;
140 };
141
142 //required by JSON-RPC 2.0 spec
143 struct error
144 {
145 // not really using code, maybe later.
146 error() : use(false), code(1) { }
147
148 bool use; // do not serialize
149
150 int32_t code;
151
152 // not required by spec, but int error codes aren't perfect
153 std::string error_str;
154
155 std::string message;
156
157 //TODO: data member? not required, may want later.
158 };
159
160 struct BlockHeaderResponse
161 {
162 uint64_t major_version;
163 uint64_t minor_version;
164 uint64_t timestamp;
165 crypto::hash prev_id;
166 uint32_t nonce;
167 uint64_t height;
168 uint64_t depth;
169 crypto::hash hash;
170 cryptonote::difficulty_type wide_difficulty;
171 uint64_t difficulty;
172 uint64_t reward;
173 };
174
175 struct DaemonInfo
176 {
177 uint64_t height;
178 uint64_t target_height;
179 uint64_t top_block_height;
180 cryptonote::difficulty_type wide_difficulty;
181 uint64_t difficulty;
182 uint64_t target;
183 uint64_t tx_count;
184 uint64_t tx_pool_size;
185 uint64_t alt_blocks_count;
186 uint64_t outgoing_connections_count;
187 uint64_t incoming_connections_count;
188 uint64_t white_peerlist_size;
189 uint64_t grey_peerlist_size;
190 bool mainnet;
191 bool testnet;
192 bool stagenet;
193 std::string nettype;
194 crypto::hash top_block_hash;
195 cryptonote::difficulty_type wide_cumulative_difficulty;
196 uint64_t cumulative_difficulty;
197 uint64_t block_size_limit;
198 uint64_t block_weight_limit;
199 uint64_t block_size_median;
200 uint64_t adjusted_time;
201 uint64_t block_weight_median;
202 uint64_t start_time;
203 std::string version;
204 };
205
206 struct output_distribution
207 {
208 output_distribution_data data;
209 uint64_t amount;
210 bool cumulative;
211 };
212 } // namespace rpc
213
214 } // namespace cryptonote