Electroneum
rpc_command_executor.h
Go to the documentation of this file.
1 
9 // Copyrights(c) 2017-2020, The Electroneum Project
10 // Copyrights(c) 2014-2019, The Monero Project
11 //
12 // All rights reserved.
13 //
14 // Redistribution and use in source and binary forms, with or without modification, are
15 // permitted provided that the following conditions are met:
16 //
17 // 1. Redistributions of source code must retain the above copyright notice, this list of
18 // conditions and the following disclaimer.
19 //
20 // 2. Redistributions in binary form must reproduce the above copyright notice, this list
21 // of conditions and the following disclaimer in the documentation and/or other
22 // materials provided with the distribution.
23 //
24 // 3. Neither the name of the copyright holder nor the names of its contributors may be
25 // used to endorse or promote products derived from this software without specific
26 // prior written permission.
27 //
28 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
29 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
30 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
31 // THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
32 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
33 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
34 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
35 // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
36 // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 //
38 // Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers
39 
40 #pragma once
41 
42 #include <boost/optional/optional_fwd.hpp>
43 
44 #include "common/common_fwd.h"
45 #include "common/rpc_client.h"
47 #include "net/net_fwd.h"
48 #include "rpc/core_rpc_server.h"
49 
50 #undef ELECTRONEUM_DEFAULT_LOG_CATEGORY
51 #define ELECTRONEUM_DEFAULT_LOG_CATEGORY "daemon"
52 
53 namespace daemonize {
54 
56 private:
59  bool m_is_rpc;
60 
61 public:
63  uint32_t ip
64  , uint16_t port
65  , const boost::optional<tools::login>& user
66  , const epee::net_utils::ssl_options_t& ssl_options
67  , bool is_rpc = true
68  , cryptonote::core_rpc_server* rpc_server = NULL
69  );
70 
72 
73  bool print_peer_list(bool white = true, bool gray = true, size_t limit = 0);
74 
75  bool print_peer_list_stats();
76 
77  bool save_blockchain();
78 
79  bool show_hash_rate();
80 
81  bool hide_hash_rate();
82 
83  bool show_difficulty();
84 
85  bool show_status();
86 
87  bool print_connections();
88 
89  bool print_blockchain_info(uint64_t start_block_index, uint64_t end_block_index);
90 
91  bool set_log_level(int8_t level);
92 
93  bool set_log_categories(const std::string &categories);
94 
95  bool print_height();
96 
97  bool print_block_by_hash(crypto::hash block_hash, bool include_hex);
98 
99  bool print_block_by_height(uint64_t height, bool include_hex);
100 
101  bool print_transaction(crypto::hash transaction_hash, bool include_hex, bool include_json);
102 
103  bool is_key_image_spent(const crypto::key_image &ki);
104 
106 
108 
110 
111  bool start_mining(cryptonote::account_public_address address, uint64_t num_threads, cryptonote::network_type nettype, bool do_background_mining = false, bool ignore_battery = false);
112 
113  bool stop_mining();
114 
115  bool mining_status();
116 
117  bool stop_daemon();
118 
119  bool print_status();
120 
121  bool get_limit();
122 
123  bool get_limit_up();
124 
125  bool get_limit_down();
126 
127  bool set_limit(int64_t limit_down, int64_t limit_up);
128 
129  bool out_peers(uint64_t limit);
130 
131  bool in_peers(uint64_t limit);
132 
133  bool start_save_graph();
134 
135  bool stop_save_graph();
136 
137  bool hard_fork_info(uint8_t version);
138 
139  bool print_bans();
140 
141  bool ban(const std::string &ip, time_t seconds);
142 
143  bool unban(const std::string &ip);
144 
145  bool flush_txpool(const std::string &txid);
146 
147  bool output_histogram(const std::vector<uint64_t> &amounts, uint64_t min_count, uint64_t max_count);
148 
149  bool print_coinbase_tx_sum(uint64_t height, uint64_t count);
150 
151  bool alt_chain_info(const std::string &tip);
152 
153  bool print_blockchain_dynamic_stats(uint64_t nblocks);
154 
155  bool update(const std::string &command);
156 
157  bool relay_tx(const std::string &txid);
158 
159  bool sync_info();
160 
161  bool pop_blocks(uint64_t num_blocks);
162 
163  bool prune_blockchain();
164 
166 
167  bool print_net_stats();
168 
169  bool set_validator_key(const std::string &key);
170 
172 
173  bool sign_message(const std::string privateKey, const std::string message);
174 };
175 
176 } // namespace daemonize
uint64_t height
Definition: blockchain.cpp:91
uint8_t version
Definition: blockchain.cpp:90
Definition: core_rpc_server.h:57
Definition: rpc_command_executor.h:55
bool stop_save_graph()
Definition: rpc_command_executor.cpp:1560
bool print_status()
Definition: rpc_command_executor.cpp:1336
bool print_height()
Definition: rpc_command_executor.cpp:792
bool set_limit(int64_t limit_down, int64_t limit_up)
Definition: rpc_command_executor.cpp:1384
bool check_blockchain_pruning()
Definition: rpc_command_executor.cpp:2242
bool get_limit_up()
Definition: rpc_command_executor.cpp:1415
bool ban(const std::string &ip, time_t seconds)
Definition: rpc_command_executor.cpp:1651
bool is_key_image_spent(const crypto::key_image &ki)
Definition: rpc_command_executor.cpp:981
bool hide_hash_rate()
Definition: rpc_command_executor.cpp:289
bool print_transaction_pool_stats()
Definition: rpc_command_executor.cpp:1154
bool output_histogram(const std::vector< uint64_t > &amounts, uint64_t min_count, uint64_t max_count)
Definition: rpc_command_executor.cpp:1753
bool print_block_by_height(uint64_t height, bool include_hex)
Definition: rpc_command_executor.cpp:853
bool get_limit()
Definition: rpc_command_executor.cpp:1356
bool show_difficulty()
Definition: rpc_command_executor.cpp:317
bool prune_blockchain()
Definition: rpc_command_executor.cpp:2213
bool print_transaction(crypto::hash transaction_hash, bool include_hex, bool include_json)
Definition: rpc_command_executor.cpp:887
bool print_transaction_pool_short()
Definition: rpc_command_executor.cpp:1103
cryptonote::core_rpc_server * m_rpc_server
Definition: rpc_command_executor.h:58
bool get_limit_down()
Definition: rpc_command_executor.cpp:1442
bool print_blockchain_info(uint64_t start_block_index, uint64_t end_block_index)
Definition: rpc_command_executor.cpp:692
bool hard_fork_info(uint8_t version)
Definition: rpc_command_executor.cpp:1586
bool print_connections()
Definition: rpc_command_executor.cpp:568
bool print_peer_list_stats()
Definition: rpc_command_executor.cpp:207
bool show_hash_rate()
Definition: rpc_command_executor.cpp:262
bool alt_chain_info(const std::string &tip)
Definition: rpc_command_executor.cpp:1827
bool set_validator_key(const std::string &key)
Definition: rpc_command_executor.cpp:2189
bool show_status()
Definition: rpc_command_executor.cpp:389
t_rpc_command_executor(uint32_t ip, uint16_t port, const boost::optional< tools::login > &user, const epee::net_utils::ssl_options_t &ssl_options, bool is_rpc=true, cryptonote::core_rpc_server *rpc_server=NULL)
Definition: rpc_command_executor.cpp:127
bool stop_daemon()
Definition: rpc_command_executor.cpp:1294
bool print_bans()
Definition: rpc_command_executor.cpp:1619
bool sign_message(const std::string privateKey, const std::string message)
Definition: rpc_command_executor.cpp:2301
bool print_transaction_pool_long()
Definition: rpc_command_executor.cpp:1017
bool generate_ed25519_keypair()
Definition: rpc_command_executor.cpp:2278
bool print_blockchain_dynamic_stats(uint64_t nblocks)
Definition: rpc_command_executor.cpp:1892
bool set_log_level(int8_t level)
Definition: rpc_command_executor.cpp:736
bool in_peers(uint64_t limit)
Definition: rpc_command_executor.cpp:1501
bool start_mining(cryptonote::account_public_address address, uint64_t num_threads, cryptonote::network_type nettype, bool do_background_mining=false, bool ignore_battery=false)
Definition: rpc_command_executor.cpp:1239
bool start_save_graph()
Definition: rpc_command_executor.cpp:1533
bool unban(const std::string &ip)
Definition: rpc_command_executor.cpp:1687
bool print_coinbase_tx_sum(uint64_t height, uint64_t count)
Definition: rpc_command_executor.cpp:1792
bool print_peer_list(bool white=true, bool gray=true, size_t limit=0)
Definition: rpc_command_executor.cpp:163
bool pop_blocks(uint64_t num_blocks)
Definition: rpc_command_executor.cpp:2162
bool mining_status()
Definition: rpc_command_executor.cpp:492
bool m_is_rpc
Definition: rpc_command_executor.h:59
bool update(const std::string &command)
Definition: rpc_command_executor.cpp:2013
bool sync_info()
Definition: rpc_command_executor.cpp:2094
bool print_net_stats()
Definition: rpc_command_executor.cpp:632
bool set_log_categories(const std::string &categories)
Definition: rpc_command_executor.cpp:764
bool flush_txpool(const std::string &txid)
Definition: rpc_command_executor.cpp:1723
bool relay_tx(const std::string &txid)
Definition: rpc_command_executor.cpp:2065
bool save_blockchain()
Definition: rpc_command_executor.cpp:235
bool out_peers(uint64_t limit)
Definition: rpc_command_executor.cpp:1469
bool stop_mining()
Definition: rpc_command_executor.cpp:1268
tools::t_rpc_client * m_rpc_client
Definition: rpc_command_executor.h:57
bool print_block_by_hash(crypto::hash block_hash, bool include_hex)
Definition: rpc_command_executor.cpp:819
~t_rpc_command_executor()
Definition: rpc_command_executor.cpp:155
Definition: rpc_client.h:46
POD_CLASS key_image
Definition: crypto.h:102
POD_CLASS hash
Definition: hash.h:50
network_type
Definition: cryptonote_config.h:243
Definition: command_parser_executor.cpp:38
mdb_size_t count(MDB_cursor *cur)
Definition: value_stream.cpp:39
Definition: cryptonote_basic.h:453